This repository has been archived by the owner on Jul 30, 2023. It is now read-only.
forked from teletips/CountdownTimer-TeLeTiPs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teletips_set.py
220 lines (206 loc) · 9.95 KB
/
teletips_set.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
#Copyright ©️ 2021 TeLe TiPs. All Rights Reserved
#You are free to use this code in any of your project, but you MUST include the following in your README.md (Copy & paste)
# ##Credits - [Countdown Timer Telegram bot by TeLe TiPs] (https://github.com/teletips/CountdownTimer-TeLeTiPs)
# Changing the code is not allowed! Read GNU AFFERO GENERAL PUBLIC LICENSE: https://github.com/teletips/CountdownTimer-TeLeTiPs/blob/main/LICENSE
from pyrogram import Client, filters
from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
import os
import asyncio
from plugins.teletips_t import *
from pyrogram.errors import FloodWait, MessageNotModified
from pyrogram.raw.functions.messages import UpdatePinnedMessage
bot=Client(
"Countdown-TeLeTiPs",
api_id = int(os.environ["API_ID"]),
api_hash = os.environ["API_HASH"],
bot_token = os.environ["BOT_TOKEN"]
)
stoptimer = False
TELETIPS_MAIN_MENU_BUTTONS = [
[
InlineKeyboardButton('🙋♀️ Commands Help 🙋♀️', callback_data="HELP_CALLBACK")
],
[
InlineKeyboardButton('🚀 Developers 🚀', callback_data="GROUP_CALLBACK"),
InlineKeyboardButton('👻 My Updates 👻', url='https://t.me/sl_bot_zone'),
],
[
InlineKeyboardButton('🏆 Adevertitments 🏆', callback_data="TUTORIAL_CALLBACK")
],
[
InlineKeyboardButton('💖 Rate Me 💖', url="https://t.me/slbotzone")
]
]
@bot.on_message(filters.command(['start','help']) & filters.private)
async def start(client, message):
text = START_TEXT
reply_markup = InlineKeyboardMarkup(TELETIPS_MAIN_MENU_BUTTONS)
await message.reply(
text=text,
reply_markup=reply_markup,
disable_web_page_preview=True
)
@bot.on_callback_query()
async def callback_query(client: Client, query: CallbackQuery):
if query.data=="HELP_CALLBACK":
TELETIPS_HELP_BUTTONS = [
[
InlineKeyboardButton("🙋♀️ Back Mein Menu ", callback_data="START_CALLBACK")
]
]
reply_markup = InlineKeyboardMarkup(TELETIPS_HELP_BUTTONS)
try:
await query.edit_message_text(
HELP_TEXT,
reply_markup=reply_markup
)
except MessageNotModified:
pass
elif query.data=="GROUP_CALLBACK":
TELETIPS_GROUP_BUTTONS = [
[
InlineKeyboardButton("🇱🇰 Main Support", url="https://t.me/sl_bot_zone")
],
[
InlineKeyboardButton("🌎 Advertitments 🏆", url="https://t.me/slbotzone")
],
[
InlineKeyboardButton("🙋♀️ Back", callback_data="START_CALLBACK"),
]
]
reply_markup = InlineKeyboardMarkup(TELETIPS_GROUP_BUTTONS)
try:
await query.edit_message_text(
GROUP_TEXT,
reply_markup=reply_markup
)
except MessageNotModified:
pass
elif query.data=="TUTORIAL_CALLBACK":
TELETIPS_TUTORIAL_BUTTONS = [
[
InlineKeyboardButton("SL Bot Zone", url="https://t.me/szteambots")
],
[
InlineKeyboardButton("WL Film World", url="https://t.me/FilmAndTVSeriasChat")
],
[
InlineKeyboardButton("Developer", url="https://t.me/omindas")
],
[
InlineKeyboardButton("🙋♀️ Back", callback_data="START_CALLBACK"),
]
]
reply_markup = InlineKeyboardMarkup(TELETIPS_TUTORIAL_BUTTONS)
try:
await query.edit_message_text(
TUTORIAL_TEXT,
reply_markup=reply_markup
)
except MessageNotModified:
pass
elif query.data=="START_CALLBACK":
TELETIPS_START_BUTTONS = [
[
InlineKeyboardButton('🙋♀️ Commands Help 🙋♀️', callback_data="HELP_CALLBACK")
],
[
InlineKeyboardButton('🚀 Developers 🚀', callback_data="GROUP_CALLBACK"),
InlineKeyboardButton(',👻 My Updates 👻', url='https://t.me/sl_bot_zone'),
],
[
InlineKeyboardButton('🏆 Adertitments 🏆', callback_data="TUTORIAL_CALLBACK")
],
[
InlineKeyboardButton('💖 Rate Me 💖', url="https://t.me/slbotzone")
]
]
reply_markup = InlineKeyboardMarkup(TELETIPS_START_BUTTONS)
try:
await query.edit_message_text(
START_TEXT,
reply_markup=reply_markup
)
except MessageNotModified:
pass
@bot.on_message(filters.command('set'))
async def set_timer(client, message):
global stoptimer
try:
if message.chat.id>0:
return await message.reply('⛔️ Try this command in a **group chat**.')
elif not (await client.get_chat_member(message.chat.id,message.from_user.id)).can_manage_chat:
return await message.reply('👮🏻♂️ Sorry, **only admins** can execute this command.')
elif len(message.command)<3:
return await message.reply('❌ **Incorrect format.**\n\n✅ Format should be like,\n<code> /set seconds "event"</code>\n\n**Example**:\n <code>/set 86400 "TIME LEFT UNTIL NEW YEAR"</code>')
else:
user_input_time = int(message.command[1])
user_input_event = str(message.command[2])
get_user_input_time = await bot.send_message(message.chat.id, user_input_time)
await get_user_input_time.pin()
if stoptimer: stoptimer = False
if 0<user_input_time<=10:
while user_input_time and not stoptimer:
s=user_input_time%60
Countdown_TeLe_TiPs='{}\n\n⏳ {:02d}**s**\n\n<i>"Your **Time** Is Limited, So Don\'t Waste It Living Someone Else\'s Life"</i>\n - Steve [Jobs](https://telegra.ph/file/290b04f8fb43495294ffc.mp4)'.format(user_input_event, s)
finish_countdown = await get_user_input_time.edit(Countdown_TeLe_TiPs)
await asyncio.sleep(1)
user_input_time -=1
await finish_countdown.edit("🚨 Beep! Beep!! **TIME'S UP!!!**")
elif 10<user_input_time<60:
while user_input_time>0 and not stoptimer:
s=user_input_time%60
Countdown_TeLe_TiPs='{}\n\n⏳ {:02d}**s**\n\n<i>"Your **Time** Is Limited, So Don\'t Waste It Living Someone Else\'s Life"</i>\n - Steve Jobs'.format(user_input_event, s)
finish_countdown = await get_user_input_time.edit(Countdown_TeLe_TiPs)
await asyncio.sleep(3)
user_input_time -=3
await finish_countdown.edit("🚨 Beep! Beep!! **TIME'S UP!!!**")
elif 60<=user_input_time<3600:
while user_input_time>0 and not stoptimer:
m=user_input_time%3600//60
s=user_input_time%60
Countdown_TeLe_TiPs='{}\n\n⏳ {:02d}**m** : {:02d}**s**\n\n<i>"Your **Time** Is Limited, So Don\'t Waste It Living Someone Else\'s Life"</i>\n - Steve Jobs'.format(user_input_event, m, s)
finish_countdown = await get_user_input_time.edit(Countdown_TeLe_TiPs)
await asyncio.sleep(3)
user_input_time -=3
await finish_countdown.edit("🚨 Beep! Beep!! **TIME'S UP!!!**")
elif 3600<=user_input_time<86400:
while user_input_time>0 and not stoptimer:
h=user_input_time%(3600*24)//3600
m=user_input_time%3600//60
s=user_input_time%60
Countdown_TeLe_TiPs='{}\n\n⏳ {:02d}**h** : {:02d}**m** : {:02d}**s**\n\n<i>"Your **Time** Is Limited, So Don\'t Waste It Living Someone Else\'s Life"</i>\n - Steve Jobs'.format(user_input_event, h, m, s)
finish_countdown = await get_user_input_time.edit(Countdown_TeLe_TiPs)
await asyncio.sleep(7)
user_input_time -=7
await finish_countdown.edit("🚨 Beep! Beep!! **TIME'S UP!!!**")
elif user_input_time>=86400:
while user_input_time>0 and not stoptimer:
d=user_input_time//(3600*24)
h=user_input_time%(3600*24)//3600
m=user_input_time%3600//60
s=user_input_time%60
Countdown_TeLe_TiPs='{}\n\n⏳ {:02d}**d** : {:02d}**h** : {:02d}**m** : {:02d}**s**\n\n<i>"Your **Time** Is Limited, So Don\'t Waste It Living Someone Else\'s Life"</i>\n - Steve Jobs'.format(user_input_event, d, h, m, s)
finish_countdown = await get_user_input_time.edit(Countdown_TeLe_TiPs)
await asyncio.sleep(9)
user_input_time -=9
await finish_countdown.edit("🚨 Beep! Beep!! **TIME'S UP!!!**")
else:
await get_user_input_time.edit(f"🤷🏻♂️ I can't countdown from {user_input_time}")
await get_user_input_time.unpin()
except FloodWait as e:
await asyncio.sleep(e.x)
@bot.on_message(filters.command('stopc'))
async def stop_timer(Client, message):
global stoptimer
try:
if (await bot.get_chat_member(message.chat.id,message.from_user.id)).can_manage_chat:
stoptimer = True
await message.reply('🛑 Countdown stopped.')
else:
await message.reply('👮🏻♂️ Sorry, **only admins** can execute this command.')
except FloodWait as e:
await asyncio.sleep(e.x)
print("Countdown Timer is alive!")
bot.run()
#Copyright ©️ 2021 TeLe TiPs. All Rights Reserved