-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbot.py
85 lines (72 loc) · 3.45 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
import os, logging, asyncio
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)
anlik_calisan = []
@client.on(events.NewMessage(pattern='^(?i)/cancel'))
async def cancel(event):
global anlik_calisan
anlik_calisan.remove(event.chat_id)
@client.on(events.NewMessage(pattern="^/start$"))
async def start(event):
await event.reply("**Ben Tagger Bot**, Grup veya kanaldaki neredeyse tüm üyelerden bahsedebilirim ★\nDaha fazla bilgi için **/help**'i tıklayın.",
buttons=(
[Button.url('🌟 Beni Bir Gruba Ekle', 'https://t.me/turkctagbot?startgroup=a'),
Button.url('📣 Geliştirici', 'https://t.me/turkcbot')]
),
link_preview=False
)
@client.on(events.NewMessage(pattern="^/help$"))
async def help(event):
helptext = "**Tagger Bot'un Yardım Menüsü**\n\nKomut: /all \n Bu komutu, başkalarına bahsetmek istediğiniz metinle birlikte kullanabilirsiniz. \n\n`Örnek: /all Günaydın!` \n\nBu komutu yanıt olarak kullanabilirsiniz. Herhangi bir mesaj yanıtlandığında, yanıtlanan mesaj ile kullanıcıları etiketleyecebilir\n@turkcbot"
await event.reply(helptext,
buttons=(
[Button.url('🌟 Beni Bir Gruba Ekle', 'https://t.me/turkctagbot?startgroup=a'),
Button.url('📣 Geliştirici', 'https://t.me/turkcbot')]
),
link_preview=False
)
@client.on(events.NewMessage(pattern="^/all ?(.*)"))
async def mentionall(event):
global anlik_calisan
if event.is_private:
return await event.respond("__Bu komut gruplarda ve kanallarda kullanılabilir.!__")
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(f"[{get_display_name(u)}](tg://user?id={u.id})**__Yalnızca yöneticiler hepsinden bahsedebilir warn text bold__**")
if event.pattern_match.group(1):
mode = "text_on_cmd"
msg = event.pattern_match.group(1)
elif event.pattern_match.group(1) and event.reply_to_msg_id:
return await event.respond("**__Bana bir mesaj ver!__**")
else:
return await event.respond("**__Bir mesajı yanıtlayın veya başkalarından bahsetmem için bana bir metin verin!__**")
if mode == "text_on_cmd":
anlik_calisan.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 anlik_calisan:
await event.respond("İşlem Başarılı Bir Şekilde Durduruldu ❌")
return
if usrnum == 5:
await client.send_message(event.chat_id, f"{msg} \n\n {usrtxt}")
await asyncio.sleep(1.5)
usrnum = 0
usrtxt = ""
print(">> Bot çalıyor merak etme 🚀 @drmehmetaktass bilgi alabilirsin <<")
client.run_until_disconnected()