-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathbot.py
More file actions
167 lines (145 loc) · 5.59 KB
/
bot.py
File metadata and controls
167 lines (145 loc) · 5.59 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
import os, logging, asyncio
from telegraph import upload_file
from telethon import Button
from telethon import TelegramClient, events
from telethon.sessions import StringSession
from telethon.tl.types import ChannelParticipantsAdmins
logging.basicConfig(
level=logging.INFO,
format='%(name)s - [%(levelname)s] - %(message)s'
)
LOGGER = logging.getLogger(__name__)
api_id = int(os.environ.get("APP_ID"))
api_hash = os.environ.get("API_HASH")
bot_token = os.environ.get("TOKEN")
client = TelegramClient('client', api_id, api_hash).start(bot_token=bot_token)
moment_worker = []
#start
@client.on(events.NewMessage(pattern="^/start$"))
async def start(event):
await event.reply("^_^ Hey, Welcome To TAG Help Bot's Menu\nI can tag 15,000 Members in Group and 300 Members In Channel.\nNeed Help /help ",
buttons=(
[
Button.url('📣 UPDATES', 'https://t.me/DeeCodeBots'),
Button.url('⭐SUPPORT', 'https://t.me/DeCodeSupport'),
],
[
Button.url('➕ ADD ME TO YOUR GROUP', 'https://t.me/MEMBER_TAGERBOT?startgroup=true'),
]
),
link_preview=False
)
#help
@client.on(events.NewMessage(pattern="^/help$"))
async def help(event):
helptext = "**Tag Help Bot's Help Menu**\n\nCommand: /all \n You can use this command with text you want to tell others. \n`Example: /all Good morning!` \nYou can use this command as an answer. any message Bot will tag users to replied message"
await event.reply(helptext,
buttons=(
[
Button.url('📣 UPDATES', 'https://t.me/DeeCodeBots'),
Button.url('⭐SUPPORT', 'https://t.me/DeCodeSupport'),
],
[
Button.url('➕ ADD ME TO YOUR GROUP', 'https://t.me/MEMBER_TAGERBOT?startgroup=true'),
]
),
link_preview=False
)
#Wah bhaiya full ignorebazzi
#bsdk credit de dena verna maa chod dege
#tag
@client.on(events.NewMessage(pattern="^/tagall|/call|/tall|/all|#all|@all?(.*)"))
async def mentionall(event):
global moment_worker
if event.is_private:
return await event.respond("Use This In Channel or Group!")
admins = []
async for admin in client.iter_participants(event.chat_id, filter=ChannelParticipantsAdmins):
admins.append(admin.id)
if not event.sender_id in admins:
return await event.respond("Only Admin can use it.")
if event.pattern_match.group(1):
mode = "text_on_cmd"
msg = event.pattern_match.group(1)
elif event.reply_to_msg_id:
mode = "text_on_reply"
msg = event.reply_to_msg_id
if msg == None:
return await event.respond("I can't Mention Members for Old Post!")
elif event.pattern_match.group(1) and event.reply_to_msg_id:
return await event.respond("Give me can an Argument. Ex: `/tag Hey, Where are you`")
else:
return await event.respond("Reply to Message or Give Some Text To Mention!")
if mode == "text_on_cmd":
moment_worker.append(event.chat_id)
usrnum = 0
usrtxt = ""
async for usr in client.iter_participants(event.chat_id):
usrnum += 1
usrtxt += f"[{usr.first_name}](tg://user?id={usr.id}) "
if event.chat_id not in moment_worker:
await event.respond("Stopped!")
return
if usrnum == 5:
await client.send_message(event.chat_id, f"{usrtxt}\n\n{msg}")
await asyncio.sleep(2)
usrnum = 0
usrtxt = ""
if mode == "text_on_reply":
moment_worker.append(event.chat_id)
usrnum = 0
usrtxt = ""
async for usr in client.iter_participants(event.chat_id):
usrnum += 1
usrtxt += f"[{usr.first_name}](tg://user?id={usr.id}) "
if event.chat_id not in moment_worker:
await event.respond("Stopped")
return
if usrnum == 5:
await client.send_message(event.chat_id, usrtxt, reply_to=msg)
await asyncio.sleep(2)
usrnum = 0
usrtxt = ""
#telegraph
@client.on(events.NewMessage(pattern="^/t$"))
async def telegraph(client, message):
replied = message.reply_to_message
if not replied:
await message.reply("Reply to a supported media file")
return
if not (
(replied.photo and replied.photo.file_size <= 5242880)
or (replied.animation and replied.animation.file_size <= 5242880)
or (
replied.video
and replied.video.file_name.endswith(".mp4")
and replied.video.file_size <= 5242880
)
or (
replied.document
and replied.document.file_name.endswith(
(".jpg", ".jpeg", ".png", ".gif", ".mp4"),
)
and replied.document.file_size <= 5242880
)
):
await message.reply("Not supported!")
return
download_location = await client.download_media(
message=message.reply_to_message,
file_name="root/downloads/",
)
try:
response = upload_file(download_location)
except Exception as document:
await message.reply(message, text=document)
else:
await message.reply(
f"**Hey You...!\nLoook At This\n\n👉 https://telegra.ph{response[0]}**",
disable_web_page_preview=True,
)
finally:
os.remove(download_location)
print("Started Successfully Join Support")
print("¯\_(ツ)_/¯ Need Help Join @DeCodeSupport")
client.run_until_disconnected()