-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault_segments.py
698 lines (579 loc) · 26.6 KB
/
default_segments.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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
import memes
from pyrogram import Client
from pyrogram.types import Message, InputMediaVideo
from pyrogram.enums import ParseMode
from datetime import datetime, timezone, timedelta
from sambot import Sambot, BotPipelineSegmentBase, MessageAdapter
from pyrogram.handlers import MessageHandler
from wordcloud import WordCloud
import asyncio
import re
from io import BytesIO
import random
from PyL360 import L360Client
import os
from database import get_session, Reminder
import time
import logging
from utils import setup_logger
class PingIndicator(BotPipelineSegmentBase):
'''
Segment to indicate if the bot is alive. It will send a message with uptime duration
Activate by sending '.ping'
'''
def CanHandle(self, message: Message):
if not message.text:
return False
return message.text == '.ping' and message.from_user.is_self
async def ProcessMessage(self, bot: Client, message: Message):
if (not self.CanHandle(message)):
return
uptime = (datetime.now(timezone.utc) -
self.sambot._startTimeUtc).total_seconds()
await bot.edit_message_text(message.chat.id, message.id, f"Online. I've been up for {int(uptime)} seconds now. Uptime was at {self.sambot._startTimeUtc}")
await asyncio.sleep(3)
await bot.delete_messages(chat_id=message.chat.id, message_ids=[message.id])
def RegisterSegment(self, sambot: Sambot, bot: Client):
self.sambot = sambot
handler = MessageHandler(self.ProcessMessage)
bot.add_handler(handler, group=1001)
# return await super().RegisterSegment(sambot, bot)
class TikTokDownloader(BotPipelineSegmentBase):
'''
Segment to download TikTok and Youtube videos
Activate it by replying the command '.dl' to a message that contains a URL to a video
'''
def __init__(self):
self.logger = logging.getLogger('TikTokDownloader')
setup_logger(self.logger)
url_pattern = re.compile(
r'http[s]?://(?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*\\(\\),]|'
r'(?:%[0-9a-fA-F][0-9a-fA-F]))+'
)
issue_messages = [
"One second"
"Something went wrong. Let me try again...",
"Third times the charm! (Updating YT-DLP)",
"Uhhh... just one second"
]
invalid_operation_messages = [
"You need to reply with a link!",
"Where's the link?",
"What do you want me to download? Reply to a message with a link!",
"Im gonna need a link"
]
def can_download(self, message: Message):
if not message.text:
return False
return message.text == '.dl'
def can_ban(self, message: Message):
if not message.reply_to_message:
return False
if not message.from_user.is_self:
return False
return message.text == '.ban_dl'
def can_unban(self, message: Message):
if not message.reply_to_message:
return False
if not message.from_user.is_self:
return False
return message.text == '.unban_dl'
async def ban_user(self, message: Message):
if message.reply_to_message.from_user.id in self.sambot.configuration["TikTokDl"]["BannedUsers"]:
await message.edit_text("This guy is already banned")
return
self.sambot.configuration["TikTokDl"]["BannedUsers"].append(
message.reply_to_message.from_user.id)
self.sambot.SaveConfiguration()
await message.edit_text("This fool has been banned!")
async def unban_user(self, message: Message):
if not message.reply_to_message.from_user.id in self.sambot.configuration["TikTokDl"]["BannedUsers"]:
await message.edit_text("This guy was not banned")
return
self.sambot.configuration["TikTokDl"]["BannedUsers"].remove(
message.reply_to_message.from_user.id)
self.sambot.SaveConfiguration()
await message.edit_text("This fool has been unbanned!")
def update_and_reimport_yt_dlp(self):
import subprocess
import importlib
import sys
try:
# Install or update yt-dlp using pip
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "--upgrade", "yt-dlp"])
# Import or reload yt-dlp to get the latest version
import yt_dlp
importlib.reload(yt_dlp)
self.logger.info("yt-dlp has been updated and re-imported successfully.")
return yt_dlp # Return the module if needed
except Exception as e:
self.logger.fatal(f"An error occurred: {e}")
async def process_message(self, bot: Client, message: Message):
message = MessageAdapter(message)
if not message.text:
return False # Check if its a text message
if self.can_ban(message): # Check if its a message to ban users
await self.ban_user(message)
return
if self.can_unban(message): # Check if its a message to unban users
await self.unban_user(message)
return
if not self.can_download(message):
return # If its not a module related message, ignore it
# If the fool is banned, react to the origin
# message with the bird
if message.from_user.id in self.sambot.configuration["TikTokDl"]["BannedUsers"]:
await message.react("🖕")
return
if not message.IsRealReply():
await self.reply_with_issue(bot, message, random.choice(self.invalid_operation_messages))
return
url_match = re.search(self.url_pattern, message.reply_to_message.text)
if not url_match:
await self.reply_with_issue(bot, message, "You need to reply to a message with a url, and no url was detected in this message!")
return
status_msg: Message = await self.reply_with_issue(bot, message, 'One sec. Downloading the file...')
try_count = 0
while (True):
try:
file = self.download_tiktok_video(
url_match.string, reloadlib=try_count > 2)
await bot.send_media_group(
media=[InputMediaVideo(file, caption="Here you go!")],
chat_id=message.chat.id,
reply_to_message_id=message.reply_to_message_id)
if status_msg:
await bot.delete_messages(status_msg.chat.id, message_ids=[status_msg.id])
return
except Exception as e:
if (try_count == 2):
self.update_and_reimport_yt_dlp()
if (try_count <= 2):
await status_msg.edit_text(self.issue_messages[try_count])
await asyncio.sleep(3)
else:
await status_msg.edit_text("Yeah no, I give up, this can't be downloaded. I have failed. I failed and let down my entire clan")
self.logger.fatal("Download failed for {}: {}".format(url_match.string, e))
break
try_count += 1
async def reply_with_issue(self, bot: Client, message: MessageAdapter, issue: str):
if (message.from_user.is_self):
return await bot.edit_message_text(message.chat.id, message.id, issue)
else:
return await bot.send_message(
chat_id=message.chat.id,
text=issue,
reply_to_message_id=message.reply_to_top_message_id)
def download_tiktok_video(self, url, output_path='ext-mount/cache/', reloadlib: bool = False) -> str:
import yt_dlp
import hashlib
import os
import importlib
if reloadlib:
importlib.reload(yt_dlp)
md5_hash = hashlib.md5()
md5_hash.update(url.encode('utf-8'))
filename = md5_hash.hexdigest()
if os.path.exists(f'{output_path}/{filename}.mp4'):
return f'{output_path}/{filename}.mp4'
ydl_opts = {
'outtmpl': f'{output_path}/{filename}.%(ext)s',
'format': 'best',
'postprocessors': [{
'key': 'FFmpegVideoConvertor',
'preferedformat': 'mp4', # Convert to mp4 if needed
}]
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
return f'{output_path}/{filename}.mp4'
def RegisterSegment(self, sambot: Sambot, bot: Client):
self.sambot = sambot
handler = MessageHandler(self.process_message)
bot.add_handler(handler, group=1002)
# return super().RegisterSegment(sambot, bot)
class MentionEveryone(BotPipelineSegmentBase):
'''
Mention everyone in the chat when @everyone is mentioned
'''
async def can_handle(self, message: MessageAdapter):
if not message.text:
return False
if not message.chat.id in self.sambot.configuration["mentioneveryone"]["AllowedChats"]:
return False
return '@everyone' in (await message.GetMentionedUsers())
def can_handle_config(self, message: Message):
if (not message.from_user.is_self):
return False
return ' '.join(message.text.split()[:2]) == ".config mentioneveryone"
async def handle_config_instruction(self, bot: Client, message: Message):
parts = message.text.split()
if (len(parts) == 2):
parts.append('')
if (parts[2] == 'add'):
self.sambot.configuration['MentionEveryone']['AllowedChats'].append(
message.chat.id)
elif (parts[2] == 'remove'):
self.sambot.configuration['MentionEveryone']['AllowedChats'].append(
message.chat.id)
else:
await bot.send_message(
chat_id=message.chat.id,
text="Uknown command. Please use .config everyone_mention add|remove",
reply_to_message_id=message.id
)
return
await bot.send_message(
chat_id=message.chat.id,
text=f"Changes made",
reply_to_message_id=message.id
)
self.sambot.SaveConfiguration()
return
async def process_message(self, bot: Client, message: MessageAdapter):
message = MessageAdapter(message)
if not message.text:
return
if (not await self.can_handle(message)):
if self.can_handle_config(message):
await self.handle_config_instruction(bot, message)
return
else:
return
mentioned_users = []
async for user in bot.get_chat_members(message.chat.id):
mentioned_users.append(
f"[{user.user.first_name}](tg://user?id={user.user.id})")
await bot.send_message(
chat_id=message.chat.id,
text=' '.join(mentioned_users),
reply_to_message_id=message.id
)
def RegisterSegment(self, sambot: Sambot, bot: Client):
self.sambot = sambot
handler = MessageHandler(self.process_message)
bot.add_handler(handler, 1003)
return super().RegisterSegment(sambot, bot)
class TerminateSegment(BotPipelineSegmentBase):
async def can_handle(self, message: MessageAdapter):
if not message.text:
return
if not message.from_user.is_self:
return
return message.text == ".terminate"
async def process_message(self, bot: Client, message: MessageAdapter):
if (not await self.can_handle(message)):
return
await bot.send_message(
chat_id=message.chat.id,
text=f"`Terminating self... Good bye...`",
reply_to_message_id=message.id,
parse_mode=ParseMode.MARKDOWN
)
await asyncio.create_task(bot.stop(False))
open('terminate-lockfile', 'a').close()
exit()
def RegisterSegment(self, sambot: Sambot, bot: Client):
self.sambot = sambot
handler = MessageHandler(self.process_message)
bot.add_handler(handler, 1004)
class ReactionCounter(BotPipelineSegmentBase):
def can_handle(self, message: MessageAdapter):
if not message.text:
return
return message.text == ".leaderboard" and message.from_user.is_self
async def process_message(self, bot: Client, message: MessageAdapter):
if (not self.can_handle(message)):
return
start_date = datetime.today() - timedelta(days=1)
reactions_dict = dict()
messages_count_dict = dict()
# Fetch messages from the chat
async for msg in bot.get_chat_history(message.chat.id):
# Check if message date is within the last n days
if msg.date >= start_date:
if not msg.from_user:
continue
key = msg.from_user.first_name
if (msg.text):
# if its a text message, increment the dictionary.key with the number
# of words (split string with white space)
messages_count_dict[key] = messages_count_dict.get(
key, 0) + len(msg.text.split(' '))
else:
# otherwise just increment by one
messages_count_dict[key] = messages_count_dict.get(
key, 0) + 1
if (msg.reactions is None):
continue
count = sum(r.count for r in msg.reactions.reactions)
reactions_dict[key] = reactions_dict.get(key, 0) + count
else:
break # Stop if messages are older than start_date
reactions_dict = {k: v for k, v in sorted(
reactions_dict.items(), key=lambda item: item[1], reverse=True)}
messages_count_dict = {k: v for k, v in sorted(
messages_count_dict.items(), key=lambda item: item[1], reverse=True)}
reply_message = "**Reactions Leaderboard ✨**\n"
reply_message += '\n'.join(['- {} : {}'.format(x,
reactions_dict[x]) for x in reactions_dict])
reply_message += "\n\n**Yappin Leaderboard 🗣️**\n"
reply_message += '\n'.join(['- {} : {}'.format(x, messages_count_dict[x])
for x in messages_count_dict])
await message.reply_text(reply_message)
def RegisterSegment(self, sambot: Sambot, bot: Client):
self.sambot = sambot
handler = MessageHandler(self.process_message)
bot.add_handler(handler, 1005)
class WordCloudGenerator(BotPipelineSegmentBase):
def can_handle(self, message: MessageAdapter):
if not message.text:
return
return message.text == ".wordcloud" and message.from_user.is_self
async def process_message(self, bot: Client, message: MessageAdapter):
if (not self.can_handle(message)):
return
start_date = datetime.today() - timedelta(days=1)
messages_list = []
# Fetch messages from the chat
async for msg in bot.get_chat_history(message.chat.id):
# Check if message date is within the last n days
if msg.date >= start_date:
if (not msg.text):
continue
messages_list.append(msg.text)
else:
break # Stop if messages are older than start_date
joined = ' '.join(messages_list)
wordcloud = WordCloud(
width=2000, height=2000).generate(joined).to_image()
binary_io = BytesIO()
# Save the image to the BytesIO object
wordcloud.save(binary_io, format="PNG")
binary_io.seek(0)
await bot.send_photo(
chat_id=message.chat.id,
reply_to_message_id=message.reply_to_message_id or message.reply_to_top_message_id,
photo=binary_io
)
def RegisterSegment(self, sambot: Sambot, bot: Client):
self.sambot = sambot
handler = MessageHandler(self.process_message)
bot.add_handler(handler, 1006)
class WhoIsNoora(BotPipelineSegmentBase):
pass
class Life360Integration(BotPipelineSegmentBase):
def __init__(self):
self.l360_client = L360Client(
username=os.getenv("Life360_Username"),
password=os.getenv("Life360_Password"),
)
self.l360_client.Authenticate()
async def process_message(self, bot: Client, message: MessageAdapter):
message = MessageAdapter(message)
if not message.text:
return
if message.text.split()[0] == '.whereis':
await self.HandleQuery(bot, message)
if not message.from_user.is_self:
return
if ' '.join(message.text.split()[:2]) == ".config whereis":
await self.HandleConfiguration(bot, message)
async def HandleQuery(self, bot: Client, message: MessageAdapter):
if message.chat.id not in self.sambot.configuration["L360"]["AllowedChats"]:
return
mentioned_users = await message.GetMentionedUsersIds()
if len(mentioned_users) != 1:
await message.reply_text("You need to mention one user like `.whereis @sammy`", parse_mode=ParseMode.MARKDOWN)
return
user_id = str(mentioned_users[0])
assignments = self.sambot.configuration["L360"]["Assignments"]
if not user_id in assignments:
await message.reply_text("`No L360 profile is assigned to this user`", parse_mode=ParseMode.MARKDOWN)
return
l360_entry = assignments[user_id].split('/')
l360_user = l360_entry[1]
l360_circle = l360_entry[0]
reply_msg = await message.reply_text("`Asking Life360...`", parse_mode=ParseMode.MARKDOWN)
available_circles = self.l360_client.GetCircles()
circle = next(
(x for x in available_circles.circles if x.name == l360_circle), None)
if not circle:
await message.reply_text("The circle `{}` was not found on my Life360 account".format(l360_circle), parse_mode=ParseMode.MARKDOWN)
return
circle_members_list = circle.GetDetails().members
circle_member = next(
(x for x in circle_members_list if x.firstName == l360_user), None)
if not circle_member:
await message.reply_text("The user `{}` was not found in `{}`".format(l360_user, l360_circle), parse_mode=ParseMode.MARKDOWN)
return
await asyncio.sleep(1)
await reply_msg.delete()
summary_data = "{} is at {}".format(
circle_member.firstName,
circle_member.location.name or circle_member.location.shortAddress
)
summary_msg = await message.reply_text(summary_data)
await summary_msg.reply_location(
latitude=float(circle_member.location.latitude),
longitude=float(circle_member.location.longitude),
)
async def HandleConfiguration(self, bot: Client, message: MessageAdapter):
message_parts = message.text.split()
if len(message_parts) < 3:
await message.edit_text("`Invalid command\nsetuser - Link a user to a L360 user`", parse_mode=ParseMode.MARKDOWN)
return
match message_parts[2]:
case "setuser":
if not message.IsRealReply():
await message.edit_text("`You need to reply to a user for this command`", parse_mode=ParseMode.MARKDOWN)
return
l360User = ' '.join(message_parts[3:])
self.sambot.configuration["L360"]["Assignments"][str(
message.reply_to_message.from_user.id)] = l360User
self.sambot.SaveConfiguration()
await message.react("👍")
case "unsetuser":
if not message.IsRealReply():
await message.reply_text("`You need to reply to a user for this command`", parse_mode=ParseMode.MARKDOWN)
return
if not str(message.reply_to_message.from_user.id) in self.sambot.configuration["L360"]["Assignments"]:
await message.reply_text("`This user is not configured`", parse_mode=ParseMode.MARKDOWN)
return
del self.sambot.configuration["L360"]["Assignments"][str(
message.reply_to_message.from_user.id)]
self.sambot.SaveConfiguration()
await message.react("👍")
case "allow":
self.sambot.configuration["L360"]["AllowedChats"].append(
message.chat.id)
self.sambot.SaveConfiguration()
await message.react("👍")
pass
case "disallow":
self.sambot.configuration["L360"]["AllowedChats"].remove(
message.chat.id)
self.sambot.SaveConfiguration()
await message.react("👍")
pass
case default:
await message.edit_text("`Invalid command`", parse_mode=ParseMode.MARKDOWN)
def RegisterSegment(self, sambot: Sambot, bot: Client):
self.sambot = sambot
handler = MessageHandler(self.process_message)
bot.add_handler(handler, 1007)
class RemindMeLater(BotPipelineSegmentBase):
def __init__(self):
self.logger = logging.getLogger('RemindMeLater')
setup_logger(self.logger)
def get_total_seconds_from_string(self, time_string: str) -> int:
import re
pattern = r'(?:(\d+)d)?(?:(\d+)h)?(?:(\d+)m)?(?:(\d+)s)?'
match = re.match(pattern, time_string)
if not match:
raise ValueError("Invalid time format")
days, hours, minutes, seconds = match.groups(default='0')
total_seconds = int(days) * 86400 + int(hours) * 3600 + int(minutes) * 60 + int(seconds)
return total_seconds
async def add_reminder(self, bot: Client, message: MessageAdapter):
message_text = message.text.split()
if len(message_text) < 3:
await message.reply_text("`Invalid command. Please use .remindme time message`")
return
try:
total_seconds = self.get_total_seconds_from_string(message_text[1])
except ValueError:
await message.reply_text("`Invalid time format. Please use (number)d|h|m|s`")
return
if total_seconds <= 0:
await message.reply_text("`Time must be greater than 0`")
return
reminder_val = ' '.join(message_text[2:])
reminder_object = Reminder(
chat_id=message.chat.id,
user_id=message.from_user.id,
reminder_text=reminder_val,
remind_at=datetime.now(timezone.utc) + timedelta(seconds=total_seconds),
messageid=message.id
)
time_left = (reminder_object.remind_at - datetime.now(timezone.utc)).total_seconds()
if (time_left < 30):
asyncio.create_task(self.wait_and_send_reminder(reminder_object))
else:
self.add_reminder_to_db(reminder_object)
await message.reply_text("⏰ Reminder added!")
def start_check_reminder_job(self):
loop = asyncio.get_event_loop()
loop.call_soon(lambda: asyncio.create_task(self.check_reminders()))
async def check_reminders(self):
self.logger.info("Starting reminder background job...")
while True:
session = get_session()
reminders = session.query(Reminder).filter(
Reminder.remind_at <= datetime.now(timezone.utc) + timedelta(seconds=30)).all()
for reminder in reminders:
asyncio.create_task(self.wait_and_send_reminder(reminder, cleanup=True))
await asyncio.sleep(30)
async def wait_and_send_reminder(self, reminder:Reminder, cleanup: bool = False):
if reminder.remind_at.tzinfo is None:
reminder.remind_at = reminder.remind_at.replace(tzinfo=timezone.utc)
time_left = (reminder.remind_at - datetime.now(timezone.utc)).total_seconds()
self.logger.info("Reminder found: {} with {}s left : arming".format(reminder.reminder_text, time_left))
await asyncio.sleep(time_left)
original_user = (await self.sambot.bot.get_users(reminder.user_id))
await self.sambot.bot.send_message(
chat_id=reminder.chat_id,
text="Hey [{}](tg://user?id={})! This is a reminder for: **{}** ⏰".format(original_user.first_name, reminder.user_id, reminder.reminder_text),
reply_to_message_id=reminder.messageid,
parse_mode=ParseMode.MARKDOWN
)
if (cleanup):
session = get_session()
session.delete(reminder)
session.commit()
pass
def add_reminder_to_db(self, reminder: Reminder):
from database import get_session
session = get_session()
session.add(reminder)
session.commit()
async def check_if_reminders_allowed(self, message: MessageAdapter) -> bool:
if not message.chat.id in self.sambot.configuration["RemindMe"]["AllowedChats"]:
return False
return True
async def handle_config_instruction(self, bot: Client, message: MessageAdapter):
message_parts = message.text.split()
if len(message_parts) < 3:
await message.edit_text("`Invalid command\n.config remindme allow | disallow`", parse_mode=ParseMode.MARKDOWN)
return
match message_parts[2]:
case "allow":
self.sambot.configuration["RemindMe"]["AllowedChats"].append(
message.chat.id)
self.sambot.SaveConfiguration()
await message.react("👍")
pass
case "disallow":
self.sambot.configuration["RemindMe"]["AllowedChat"].remove(
message.chat.id)
self.sambot.SaveConfiguration()
await message.react("👍")
pass
case default:
await message.edit_text("`Invalid command`", parse_mode=ParseMode.MARKDOWN)
async def process_message(self, bot: Client, message: MessageAdapter):
message = MessageAdapter(message)
if not message.text:
return
if await self.check_if_reminders_allowed(message):
if message.text.split()[0] == '.remindme':
await self.add_reminder(bot, message)
if message.from_user.is_self:
if ' '.join(message.text.split()[:2]) == '.config remindme':
await self.handle_config_instruction(bot, message)
def RegisterSegment(self, sambot: Sambot, bot: Client):
self.sambot = sambot
handler = MessageHandler(self.process_message)
bot.add_handler(handler, 1008)
self.start_check_reminder_job()