forked from TeamUltroid/UltroidAddons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fun.py
116 lines (90 loc) · 2.94 KB
/
fun.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Ultroid - UserBot
# Copyright (C) 2020 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available
• `{i}joke`
To get joke.
• `{i}insult`
Insult someone..
• `{i}url <long url>`
To get a shorten link of long link.
• `{i}decide`
Decide something.
• `{i}xo`
Opens tic tac game only where using inline mode is allowed.
• `{i}wordi`
Opens word game only where using inline mode is allowed.
• `{i}gps <name of place>`
Shows the desired place in the map.
"""
import random
import requests
from bs4 import BeautifulSoup as bs
from pyjokes import get_joke
from telethon.errors import ChatSendMediaForbiddenError
from . import *
@ultroid_cmd(pattern="joke$")
async def _(ult):
await eor(ult, get_joke())
@ultroid_cmd(pattern="insult$")
async def gtruth(ult):
m = await eor(ult, "Generating...")
nl = "https://fungenerators.com/random/insult/new-age-insult/"
ct = requests.get(nl).content
bsc = bs(ct, "html.parser", from_encoding="utf-8")
cm = bsc.find_all("h2")[0].text
await m.edit(f"{cm}")
@ultroid_cmd(pattern="url ?(.*)")
async def _(event):
input_str = event.pattern_match.group(1)
if not input_str:
await eor(event, "Give some url")
return
sample_url = "https://da.gd/s?url={}".format(input_str)
response_api = requests.get(sample_url).text
if response_api:
await eor(
event,
"**Shortened url**==> {}\n**Given url**==> {}.".format(
response_api, input_str
),
)
else:
await eor(event, "`Something went wrong. Please try again Later.`")
@ultroid_cmd(pattern="decide$")
async def _(event):
hm = await eor(event, "`Deciding`")
r = requests.get("https://yesno.wtf/api").json()
try:
await event.reply(r["answer"], file=r["image"])
await hm.delete()
except ChatSendMediaForbiddenError:
await eor(event, r["answer"])
@ultroid_cmd(pattern="xo$")
async def xo(ult):
xox = await ult.client.inline_query("xobot", "play")
await xox[random.randrange(0, len(xox) - 1)].click(
ult.chat_id, reply_to=ult.reply_to_msg_id, silent=True, hide_via=True
)
await ult.delete()
@ultroid_cmd(pattern="wordi$")
async def word(ult):
game = await ult.client.inline_query("wordibot", "play")
await game[0].click(
ult.chat_id, reply_to=ult.reply_to_msg_id, silent=True, hide_via=True
)
await ult.delete()
@ultroid_cmd(pattern="gps (.*)")
async def map(ult):
get = ult.pattern_match.group(1)
if not get:
return await eor(ult, "Use this command as `.gps <query>`")
gps = await ult.client.inline_query("openmap_bot", f"{get}")
await gps[0].click(
ult.chat_id, reply_to=ult.reply_to_msg_id, silent=True, hide_via=True
)
await ult.delete()