-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathapp.py
304 lines (266 loc) · 10.2 KB
/
app.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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#=================================================================================================
# Copyright (C) 2022 by szsupunma@Github, < https://github.com/szsupunma >.
# Released under the "GNU v3.0 License Agreement".
# All rights reserved.
#=================================================================================================
import os
import asyncio
import requests
import random
import bs4
from pykeyboard import InlineKeyboard
from pyrogram.errors import UserNotParticipant
from pyrogram import filters, Client
from RandomWordGenerator import RandomWord
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, Message, CallbackQuery
from pyrogram.errors import InputUserDeactivated, UserNotParticipant, FloodWait, UserIsBlocked, PeerIdInvalid, bad_request_400
from database import (
get_served_users,
add_served_user,
remove_served_user,
get_served_chats,
add_served_chat,
remove_served_chat
)
app = Client(
"Fake_mail_bot",
api_hash= os.environ["API_HASH"],
api_id= int(os.environ["API_ID"]),
bot_token=os.environ["BOT_TOKEN"]
)
CHANNEL_ID = int(os.environ['CHANNEL_ID'])
CHANNEL = os.environ['CHANNEL']
OWNER = int(os.environ['OWNER'])
start_text = """
Hello {} , Welcome To The Temp| Fake Mail Bot
On this bot you can create a temporary (disposable) email in a second, that self-destructs after some time. Stay safe, avoid spam - take care of your anonymity. You can select from many domains and create own nick. Smart, huh?
Send /new to set-up your MailBox! """
start_button = InlineKeyboardMarkup(
[[
InlineKeyboardButton("Support Group", url="https://t.me/slbotzone"),
InlineKeyboardButton("News Channel", url="https://t.me/szteambots")
]])
fsub_text = """
**❗️ ATTENTION**
You see this message because you are not subscribed to the channel:
@szteambots
It is important that you are up to date with the latest updates and aware of the brand new functionality."""
async def get_user(message):
ok = True
try:
await message._client.get_chat_member(CHANNEL_ID, message.from_user.id)
ok = True
except UserNotParticipant:
ok = False
return ok
@app.on_message(filters.command("start"))
async def start(_, message: Message):
if not await get_user(message):
return await app.send_message(
chat_id=message.from_user.id,
text=fsub_text)
name = message.from_user.id
await app.send_message(
name,
text = start_text.format(message.from_user.mention),
reply_markup = start_button)
return await add_served_user(message.from_user.id)
#********************************************************************************
API1='https://www.1secmail.com/api/v1/?action=getDomainList'
API2='https://www.1secmail.com/api/v1/?action=getMessages&login='
API3='https://www.1secmail.com/api/v1/?action=readMessage&login='
#********************************************************************************
create = InlineKeyboardMarkup(
[[InlineKeyboardButton("SZ team bots 🇱🇰", url="https://t.me/szteambots")]])
#********************************************************************************
@app.on_message(filters.command("new"))
async def fakemailgen(_, message: Message):
name = message.from_user.id
m = await app.send_message(name,text=f"Please Wait...",reply_markup = create)
rp = RandomWord(max_word_size=8, include_digits=True)
email = rp.generate()
xx = requests.get(API1).json()
domain = random.choice(xx)
#print(email)
mes = await app.send_message(
name,
text = f"""
**📬Done,Your Email Address Created!**
📧 **Email** : `{email}@{domain}`
📨 **Mail BOX** : `empty`
**Powered by** : @szteambots """,
reply_markup = InlineKeyboardMarkup([[InlineKeyboardButton("🔰Update Mail Box🔰", callback_data = f"mailbox |{email}|{domain}")]]))
pi = await mes.pin(disable_notification=True, both_sides=True)
await m.delete()
await pi.delete()
async def gen_keyboard(mails, email, domain):
num = 0
i_kbd = InlineKeyboard(row_width=1)
data = []
for mail in mails:
id = mail['id']
data.append(
InlineKeyboardButton(f"{mail['subject']}", f"mail |{email}|{domain}|{id}")
)
num += 1
data.append(
InlineKeyboardButton(f"🔰Update Mail Box🔰", f"mailbox |{email}|{domain}")
)
i_kbd.add(*data)
return i_kbd
#********************************************************************************
@app.on_callback_query(filters.regex("mailbox"))
async def mail_box(_, query : CallbackQuery):
Data = query.data
callback_request = Data.split(None, 1)[1]
m, email , domain = callback_request.split("|")
mails = requests.get(f'{API2}{email}&domain={domain}').json()
if mails == []:
await query.answer("🤷♂️ No Mails found! 🤷♂️")
else:
try:
smail = f"{email}@{domain}"
mbutton = await gen_keyboard(mails,email, domain)
await query.message.edit(f"""
**📬Done,Your Email Address Created!**
📧 **Email** : `{smail}`
📨 **Mail BOX** : ✅
**Powered by** : @szteambots""",
reply_markup = mbutton
)
except bad_request_400.MessageNotModified as e:
await query.answer("🤷♂️ No New Mails found! 🤷♂️")
#********************************************************************************
@app.on_callback_query(filters.regex("mail"))
async def mail_box(_, query : CallbackQuery):
Data = query.data
callback_request = Data.split(None, 1)[1]
m, email , domain, id = callback_request.split("|")
mail = requests.get(f'{API3}{email}&domain={domain}&id={id}').json()
froms = mail['from']
subject = mail['subject']
date = mail['date']
if mail['textBody'] == "":
kk = mail['htmlBody']
body = bs4.BeautifulSoup(kk, 'lxml')
txt = body.get_text()
text = " ".join(txt.split())
url_part = body.find('a')
link = url_part['href']
mbutton = InlineKeyboardMarkup(
[
[
InlineKeyboardButton("🔗 Open Link", url=link)
],
[
InlineKeyboardButton("◀️ Back", f"mailbox |{email}|{domain}")
]
]
)
await query.message.edit(f"""
**From:** `{froms}`
**Subject:** `{subject}`
**Date**: `{date}`
{text}
""",
reply_markup = mbutton
)
else:
body = mail['textBody']
mbutton = InlineKeyboardMarkup(
[
[
InlineKeyboardButton("◀️ Back", f"mailbox |{email}|{domain}")
]
]
)
await query.message.edit(f"""
**From:** `{froms}`
**Subject:** `{subject}`
**Date**: `{date}`
{body}
""",
reply_markup = mbutton
)
#********************************************************************************
@app.on_message(filters.command("domains"))
async def fakemailgen(_, message: Message):
name = message.from_user.id
x = requests.get(f'https://www.1secmail.com/api/v1/?action=getDomainList').json()
xx = str(",".join(x))
email = xx.replace(",", "\n")
await app.send_message(
name,
text = f"""
**{email}**
""",
reply_markup = create)
#============================================================================================
#Owner commands pannel here
#user_count, broadcast_tool
@app.on_message(filters.command("stats") & filters.user(OWNER))
async def stats(_, message: Message):
name = message.from_user.id
served_chats = len(await get_served_chats())
served_chats = []
chats = await get_served_chats()
for chat in chats:
served_chats.append(int(chat["chat_id"]))
served_users = len(await get_served_users())
served_users = []
users = await get_served_users()
for user in users:
served_users.append(int(user["bot_users"]))
await app.send_message(
name,
text=f"""
🍀 Chats Stats 🍀
🙋♂️ Users : `{len(served_users)}`
👥 Groups : `{len(served_chats)}`
🚧 Total users & groups : {int((len(served_chats) + len(served_users)))} """)
async def broadcast_messages(user_id, message):
try:
await message.forward(chat_id=user_id)
return True, "Success"
except FloodWait as e:
await asyncio.sleep(e.x)
return await broadcast_messages(user_id, message)
except InputUserDeactivated:
await remove_served_user(user_id)
return False, "Deleted"
except UserIsBlocked:
await remove_served_user(user_id)
return False, "Blocked"
except PeerIdInvalid:
await remove_served_user(user_id)
return False, "Error"
except Exception as e:
return False, "Error"
@app.on_message(filters.private & filters.command("bcast") & filters.user(OWNER) & filters.reply)
async def broadcast_message(_, message):
b_msg = message.reply_to_message
chats = await get_served_users()
m = await message.reply_text("Broadcast in progress")
for chat in chats:
try:
await broadcast_messages(int(chat['bot_users']), b_msg)
await asyncio.sleep(1)
except FloodWait as e:
await asyncio.sleep(int(e.x))
except Exception:
pass
await m.edit(f"""
Broadcast Completed:.""")
@app.on_message(filters.command("ads"))
async def ads_message(_, message):
await message.reply_text(
""" 📮Advertise On Telegram 🚀
Want to promote anything ?
Rose Bot is here with your basic needs. We work in around 2.5 thousand chats with thousand of userbase. One promotional broadcast reaches to thousands of peoples.
Want to promote your online business ? Want to get people engagement? We are here!
Promote whatever you want at lowest and affordable prices.
https://telega.io/catalog_bots/szrosebot/card
🔥Your broadcast will reach group also so minimum 50k users see your message.
""")
print("I'm Alive Now!")
app.run()