-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
103 lines (90 loc) · 3.07 KB
/
bot.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
import asyncio
import os
import re
import time
from telethon import functions
from telethon.errors.rpcerrorlist import YouBlockedUserError
from telethon.tl.functions.channels import LeaveChannelRequest
from . import *
@bot.on(d3vil_cmd("kickme", outgoing=True))
async def leave(e):
if not e.text[0].isalpha() and e.text[0] not in ("/", "#", "@", "!"):
await e.edit("😪 **I am leaving this group** See u all in `@D3VIL_BOT_SUPPORT`!!")
time.sleep(1)
if "-" in str(e.chat_id):
await bot(LeaveChannelRequest(e.chat_id))
else:
await eod(e, "**Iz this even a grp?😑**")
@bot.on(d3vil_cmd(pattern=r"dc"))
@bot.on(sudo_cmd(pattern=r"dc", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
result = await borg(functions.help.GetNearestDcRequest())
await eor(event, result.stringify())
@bot.on(d3vil_cmd(pattern=r"config"))
@bot.on(sudo_cmd(pattern=r"config", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
result = await borg(functions.help.GetConfigRequest())
result = result.stringify()
logger.info(result)
await eor("Config Saved In You Heroku Logs.")
@bot.on(d3vil_cmd(pattern="schd ?(.*)", outgoing=True))
@bot.on(sudo_cmd(pattern="schd ?(.*)", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
input_str = event.pattern_match.group(1)
ttl = 0
message = f"SYNTAX: `{hl}schd <time_in_seconds> - <message to send>`"
if input_str:
await event.delete()
if "-" in input_str:
ttl, message = input_str.split("-")
elif event.reply_to_msg_id:
await event.delete()
ttl = int(input_str)
message = await event.get_reply_message()
await asyncio.sleep(int(ttl))
await event.respond(message)
else:
await event.edit(message)
@bot.on(d3vil_cmd(pattern="dm ?(.*)"))
@bot.on(sudo_cmd(pattern="dm ?(.*)", allow_sudo=True))
async def _(event):
if len(event.text) > 3:
if not event.text[3] == " ":
return
d = event.pattern_match.group(1)
c = d.split(" ")
try:
chat_id = await get_user_id(c[0])
except Exception as e:
return await eod(event, f"`{e}`")
msg = ""
hunter = await event.get_reply_message()
if event.reply_to_msg_id:
await bot.send_message(chat_id, hunter)
await eod(event, "**[Done]**")
for i in c[1:]:
msg += i + " "
if msg == "":
return
try:
await bot.send_message(chat_id, msg)
await eod(event, "**[Done]**")
except BaseException:
await eod(f"**Invalid Syntax !!**\n\n`{hl}dm <Username or UserID> <message>`")
CmdHelp("bot").add_command(
"dc", None, "Gets the DataCenter Number"
).add_command(
"config", None, "😒"
).add_command(
"kickme", None, "Kicks Yourself from the group."
).add_command(
"schd", "<secs> - <message>", "Sends your message in given secs", "schd 10 - Hello"
).add_command(
"dm", "<username or user id> <message>", "Sends a DM to given username with required msg"
).add()