-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyro.py
More file actions
193 lines (170 loc) Β· 8.13 KB
/
Pyro.py
File metadata and controls
193 lines (170 loc) Β· 8.13 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import asyncio
from pyrogram import Client, filters
from pyrogram.raw.functions.account import ReportPeer
from pyrogram.raw.types import InputPeerChannel, InputPeerUser, InputReportReasonSpam, InputReportReasonPornography, InputReportReasonViolence, InputReportReasonChildAbuse, InputReportReasonOther, InputReportReasonCopyright, InputReportReasonFake, InputReportReasonGeoIrrelevant, InputReportReasonIllegalDrugs, InputReportReasonPersonalDetails
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
# Your provided details
BOT_TOKEN = "7561524299:AAFjfBmLNx0R9-5IZaN2tz2iJlQK1z3WXlU"
STRING_SESSION = "BQHAnfYASMR-fjRi6DH3WS4E3CpvD5voiRN04SFib13F6D7TWkZyAiblSuwWYiIxjfmZm7vc-mJJqqBJlIoOQHKOkWnE1EJSnoUWqcwz0x_6ITB1PTSuIaKPJUgNz1AVuqBb01VIA6rus7_UVlbw1tmsApqYsu_-S22Bo3AqYrY-Me8nSKhdEaIMmdvt9QwpGQsUTEx0eSDT9d6ZfBPCHbALXOoMCP6xEwC5j7kPgUpSr42-ltnRhhkssPAnqvjbIAheILJHKWRyM3lS290g8KdkL-s1uj6LPAqbJumQC-Q9M7zc3Jawc5jmVvQ7dBRsbrDBwOVzJckRZ6HTQLt1ILtIdcrmaQAAAAGlMTQvAA"
api_id = "29400566"
api_hash = "8fd30dc496aea7c14cf675f59b74ec6f"
# Initialize the bot and userbot clients
app = Client("reporter_bot", api_id=api_id, api_hash=api_hash, bot_token=BOT_TOKEN)
userbot_client = Client("userbot", api_id=api_id, api_hash=api_hash, session_string=STRING_SESSION)
userbot_connected = False
is_reporting = False
target_user = None
report_reason = None
def get_report_reason(text):
if text == "Spam":
return InputReportReasonSpam()
elif text == "Pornography":
return InputReportReasonPornography()
elif text == "Violence":
return InputReportReasonViolence()
elif text == "Child Abuse":
return InputReportReasonChildAbuse()
elif text == "Other":
return InputReportReasonOther()
elif text == "Copyright":
return InputReportReasonCopyright()
elif text == "Fake":
return InputReportReasonFake()
elif text == "Geo Irrelevant":
return InputReportReasonGeoIrrelevant()
elif text == "Illegal Drugs":
return InputReportReasonIllegalDrugs()
elif text == "Personal Details":
return InputReportReasonPersonalDetails()
return InputReportReasonOther()
@app.on_message(filters.command("start"))
async def start(client, message):
await message.reply(
"π€ **Welcome to Reporter Bot!**\n\n"
"Userbot is not yet connected. Use `/connect` to connect the userbot."
)
@app.on_message(filters.command("connect"))
async def connect(client, message):
global userbot_connected
if not userbot_connected:
await message.reply("π Connecting Userbot...")
await userbot_client.start()
userbot_connected = True
await message.reply("β
Userbot connected!")
else:
await message.reply("β Userbot is already connected.")
@app.on_message(filters.command("report"))
async def report_start(client, message):
global userbot_connected, target_user
if not userbot_connected:
await message.reply("β **Userbot is not connected.**")
return
await message.reply("Kindly enter the username or chat ID of the target:")
target_user_message = await client.listen(message.chat.id)
target_user = target_user_message.text
try:
# Attempt to join the channel or group
await userbot_client.join_chat(target_user)
target_entity = await userbot_client.get_chat(target_user)
entity_type = "Channel" if target_entity.type == "channel" else "Group"
await message.reply(
f"β
**Target Details:**\n"
f"**Target:** `{target_user}`\n"
f"**Target Name:** {target_entity.title}\n"
f"Successfully joined the {entity_type}!"
)
# Send report buttons
buttons = [
[InlineKeyboardButton("Spam", callback_data="1"), InlineKeyboardButton("Pornography", callback_data="2"),
InlineKeyboardButton("Violence", callback_data="3"), InlineKeyboardButton("Child Abuse", callback_data="4"),
InlineKeyboardButton("Other", callback_data="5")],
[InlineKeyboardButton("Copyright", callback_data="6"), InlineKeyboardButton("Fake", callback_data="7"),
InlineKeyboardButton("Geo Irrelevant", callback_data="8"), InlineKeyboardButton("Illegal Drugs", callback_data="9"),
InlineKeyboardButton("Personal Details", callback_data="10")]
]
reply_markup = InlineKeyboardMarkup(buttons)
await message.reply(
"Select the report type:", reply_markup=reply_markup
)
except Exception as e:
await message.reply(f"β **Failed to find or join the target:** {e}")
@app.on_callback_query()
async def select_report_type(client, callback_query):
global report_reason
try:
report_type = int(callback_query.data)
reasons = [
"Spam", "Pornography", "Violence", "Child Abuse", "Other",
"Copyright", "Fake", "Geo Irrelevant", "Illegal Drugs", "Personal Details"
]
report_reason = get_report_reason(reasons[report_type - 1])
await callback_query.message.reply("Kindly enter the number of reports to send (or type `default` for continuous reports):")
except Exception as e:
await callback_query.message.reply(f"β **Error selecting report type:** {e}")
@app.on_message(filters.text)
async def send_reports(client, message):
global userbot_client, is_reporting, report_reason, target_user
if not is_reporting and target_user and report_reason:
is_reporting = True
try:
target_entity = await userbot_client.get_chat(target_user)
except Exception as e:
await message.reply(f"β **Failed to find the target:** {e}")
is_reporting = False
return
num_reports = message.text.strip().lower()
if num_reports == "default":
num_reports = -1
else:
try:
num_reports = int(num_reports)
if num_reports <= 0:
raise ValueError("Invalid number")
except ValueError:
await message.reply("β **Invalid number. Enter a valid number or `default` for continuous.**")
is_reporting = False
return
await message.reply("π **Starting the reporting process...**")
count = 0
try:
while num_reports != 0:
try:
peer = app.resolve_peer(target_user)
if isinstance(peer, dict) and "channel_id" in peer:
channel = InputPeerChannel(channel_id=peer["channel_id"], access_hash=peer["access_hash"])
else:
channel = InputPeerUser(user_id=peer["user_id"], access_hash=peer["access_hash"])
report_peer = ReportPeer(
peer=channel,
reason=report_reason,
message="Automated report using Reporter Bot"
)
await app.send(report_peer)
count += 1
await asyncio.sleep(2)
if num_reports > 0:
num_reports -= 1
except Exception as e:
await message.reply(f"β **Error during reporting:** {e}")
break
except Exception as e:
await message.reply(f"β **Userbot disconnected:** {e}")
await message.reply(f"β
**Reporting process completed!**\n\nTotal Reports Sent: `{count}`")
is_reporting = False
@app.on_message(filters.command("disconnect"))
async def disconnect_userbot(client, message):
global userbot_connected
if not userbot_connected:
await message.reply("β **No userbot is connected.**")
return
if is_reporting:
await message.reply("β οΈ Reporting is in progress. Disconnecting will stop the process.")
is_reporting = False
try:
await userbot_client.stop()
userbot_connected = False
await message.reply("β
**Userbot disconnected successfully!**")
except Exception as e:
await message.reply(f"β **Failed to disconnect:** {e}")
print("π€ Reporter Bot is running...")
app.run()