-
Notifications
You must be signed in to change notification settings - Fork 1
/
federation.py
117 lines (106 loc) · 4.24 KB
/
federation.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
117
import asyncio
import os
from telethon.errors.rpcerrorlist import YouBlockedUserError
from telethon.tl.functions.account import UpdateNotifySettingsRequest
from telethon import functions, types, events
from . import *
logs_id = Config.FBAN_LOG_GROUP
fbot = "@MissRose_bot"
@bot.on(d3vil_cmd(pattern="newfed ?(.*)", outgoing=True))
@bot.on(sudo_cmd(pattern="newfed ?(.*)", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
d3vil_input = event.pattern_match.group(1)
chat = "@MissRose_Bot"
await eor(event, "`Making new fed...`")
async with bot.conversation(chat) as conv:
try:
response = conv.wait_event(
events.NewMessage(incoming=True, from_users=609517172)
)
await event.client.send_message(chat, f"/newfed {d3vil_input}")
response = await response
except YouBlockedUserError:
await eod(event, "`Please unblock` @MissRose_Bot `and try again`")
return
if response.text.startswith("You already have a federation"):
await eod(event,
"You already have a federation. Do .renamefed to rename your current fed."
)
else:
await eod(event, f"{response.message.message}", 7)
@bot.on(d3vil_cmd(pattern="renamefed ?(.*)"))
@bot.on(sudo_cmd(pattern="renamefed ?(.*)", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
d3vil_input = event.pattern_match.group(1)
chat = "@MissRose_Bot"
await event.edit("`Trying to rename your fed...`")
async with event.client.conversation(chat) as conv:
try:
response = conv.wait_event(events.NewMessage(incoming=True,from_users=609517172))
await event.client.send_message(chat, f"/renamefed {d3vil_input}")
response = await response
except YouBlockedUserError:
await event.reply("Please Unblock @MissRose_Bot")
return
else:
await event.delete()
await event.client.send_message(event.chat_id, response.message)
@bot.on(d3vil_cmd(pattern="fstat ?(.*)"))
@bot.on(sudo_cmd(pattern="fstat ?(.*)", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
d3vil = await eor(event, "`Collecting fstat....`")
thumb = d3vil_logo
if event.reply_to_msg_id:
previous_message = await event.get_reply_message()
lavde = str(previous_message.sender_id)
user = f"[user](tg://user?id={lavde})"
else:
lavde = event.pattern_match.group(1)
user = lavde
if lavde == "":
await d3vil.edit(
"`Need username/id to check fstat`"
)
return
else:
async with bot.conversation(fbot) as conv:
try:
await conv.send_message("/fedstat " + lavde)
await asyncio.sleep(4)
response = await conv.get_response()
await asyncio.sleep(2)
await bot.send_message(event.chat_id, response)
await event.delete()
except YouBlockedUserError:
await d3vil.edit("`Please Unblock` @MissRose_Bot")
@bot.on(d3vil_cmd(pattern="fedinfo ?(.*)"))
@bot.on(sudo_cmd(pattern="fedinfo ?(.*)", allow_sudo=True))
async def _(event):
if event.fwd_from:
return
d3vil = await eor(event, "`Fetching fed info.... please wait`")
lavde = event.pattern_match.group(1)
async with bot.conversation(fbot) as conv:
try:
await conv.send_message("/start")
await conv.get_response()
await conv.send_message("/fedinfo " + lavde)
massive = await conv.get_response()
await d3vil.edit(massive.text + "\n\n**🎖️ʟɛɢɛռɖǟʀʏ ǟʄ ᗪ3ʋɨʟɮօȶ🎖️**")
except YouBlockedUserError:
await d3vil.edit("`Please Unblock` @MissRose_Bot")
CmdHelp("federation").add_command(
"newfed", "<newfed name>", "Makes a federation of Rose bot"
).add_command(
"renamefed", "<new name>", "Renames the fed of Rose Bot"
).add_command(
"fstat", "<username/id>", "Gets the fban stats of the user from rose bot federation"
).add_command(
"fedinfo", "<fed id>", "Gives details of the given fed id"
).add()