-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.py
163 lines (133 loc) · 5.03 KB
/
main.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
# /usr/bin/nuhman/bughunter0
import os
from os import error
import logging
import pyrogram
import time
from decouple import config
from pyrogram import Client, filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from pyrogram.types import User, Message, Sticker, Document, ChatMember
from sticker import stickers
bughunter0 = Client(
"Member-Sticker-Bot",
bot_token = os.environ["BOT_TOKEN"],
api_id = int(os.environ["API_ID"]),
api_hash = os.environ["API_HASH"]
)
START_STRING_PRIVATE = """ Hi {}, I'm Member Sticker Bot.
I Can Send Relevant Thankyou Sticker in Groups and Channel
\n All Member count doesn't return a sticker, so I will send a Thank you message for the count which have no sticker,
This message will be deleted after 10 second. \n
Nothing to Do here !! 😕
**ADD ME TO A GROUP THEN TRIGGER ME**
"""
START_STRING_GROUP = """ **I need Admin rights to Send sticker in {}**
`Join My Updates Channel for Getting more familiar with me`
"""
ABOUT = """
● **BOT:** `Member Sticker BOT`
● **AUTHOR :** [bughunter0](https://t.me/bughunter0)
● **SERVER :** `Heroku`
● **LIBRARY :** `Pyrogram`
● **LANGUAGE :** `Python 3.9`
● **SOURCE :** [BugHunterBots](https://t.me/BugHunterBots/93)
"""
HELP = """
● Still Wonder How I Work ?
● Use /How get a Full Brief
● Use /Donate to Donate
"""
CHANNEL_BUTTON = InlineKeyboardMarkup(
[[
InlineKeyboardButton('↗ Join Here ↗', url='https://t.me/BughunterBots')
]]
)
ADDME_BUTTON = InlineKeyboardMarkup(
[[
InlineKeyboardButton('↗ ADD ME TO A GROUP ↗', url="t.me/member_sticker_bot?startgroup=true")
]]
)
START_BUTTON = InlineKeyboardMarkup(
[[
InlineKeyboardButton('ABOUT',callback_data='cbabout'),
InlineKeyboardButton('HELP',callback_data='cbhelp')
],
[
InlineKeyboardButton('↗ Join Here ↗', url='https://t.me/BughunterBots'),
],
[InlineKeyboardButton('↗ ADD ME TO A GROUP ↗', url="t.me/member_sticker_bot?startgroup=true")
]]
)
CLOSE_BUTTON = InlineKeyboardMarkup(
[[
InlineKeyboardButton('Back',callback_data='cbclose'),
]]
)
@bughunter0.on_callback_query() # callbackQuery()
async def cb_data(bot, update):
if update.data == "cbhelp":
await update.message.edit_text(
text=HELP,
reply_markup=CLOSE_BUTTON,
disable_web_page_preview=True
)
elif update.data == "cbabout":
await update.message.edit_text(
text=ABOUT,
reply_markup=CLOSE_BUTTON,
disable_web_page_preview=True
)
else:
await update.message.edit_text(
text=START_STRING_PRIVATE.format(update.from_user.mention),
disable_web_page_preview=True,
reply_markup=START_BUTTON
)
@bughunter0.on_message(filters.command(["start"]) & filters.private)
async def start_private(bot, update):
text = START_STRING_PRIVATE.format(update.from_user.mention)
reply_markup = START_BUTTON
await update.reply_text(
text=text,
disable_web_page_preview=True,
reply_markup=reply_markup,
quote=True
)
@bughunter0.on_message((filters.command(["start"]) & filters.group) | filters.regex("/start@member_sticker_bot"))
async def start_group(bot, update):
text = START_STRING_GROUP.format(update.chat.title)
reply_markup = CHANNEL_BUTTON
await update.reply_text(
text=text,
disable_web_page_preview=True,
reply_markup=reply_markup,
quote=True
)
@bughunter0.on_message(filters.command(["ping"]))
async def ping(bot, message):
start_t = time.time()
rm = await message.reply_text("Checking")
end_t = time.time()
time_taken_s = (end_t - start_t) * 1000
await rm.edit(f"Pong!\n{time_taken_s:.3f} ms")
@bughunter0.on_message(filters.new_chat_members & filters.group)
async def sticker_group(bot, message):
try:
chat_id = int(message.chat.id)
count = await bughunter0.get_chat_members_count(chat_id)
if count in stickers:
await bot.send_sticker(chat_id, stickers[count])
else :
txt = await message.reply_text(f"**We are Happy to Have you as Our** `{count} th Member`")
except Exception as error:
await message.reply("@admins , \nAs per Your Group Permission Members of This Group Can't send Stickers to this Chat (`I'm a Member, Not an Admin`) .\n**To Solve this Issue add me as Admin Or Give permission to send stickers in the Chat** \n\n\n ©@BugHunterBots")
@bughunter0.on_message(filters.channel & filters.command(["start"]))
async def sticker_channel(bot, message):
chat_id = int(message.chat.id)
await bot.send_message(text="We Are Working On It",chat_id=chat_id)
@bughunter0.on_message(filters.command(["help"]))
async def help(bot, message):
chat_id = str(message.chat.id)
await bot.send_sticker(chat_id,"CAACAgIAAxkBAAEEDq1g6Y5LLm2DtFwCV2pPNCddwwZQHgAC6AkAAowucAABsFGHedLEzeUgBA")
bughunter0.run()