Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08f7a1f

Browse files
Add files via upload
1 parent ec16e7d commit 08f7a1f

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

GroupManagement.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
from rubpy import Client, types, utils
2+
from rubpy.types import Updates
3+
4+
class Bot(Client):
5+
def init(self, name):
6+
super().init(name)
7+
self.silent_users = []
8+
9+
async def handle_updates(self, update: Updates):
10+
if update.object_guid == 'g0DQVcs06895f970201487d0ea1fdd97' and update.message.author_object_guid == 'u0EzVvG0d22c29de91f6699181af2d38':
11+
if not update.message.reply_to_message_id:
12+
return
13+
14+
full_message = await self.get_messages_by_id(update.object_guid, [update.message.reply_to_message_id])
15+
user_guid = full_message.messages[0].author_object_guid
16+
17+
if update.message.text == 'سکوت':
18+
if user_guid not in self.silent_users:
19+
self.silent_users.append(user_guid)
20+
await update.reply(f'کاربر {utils.Mention("کاربر", user_guid)} در لیست سکوت قرار گرفت')
21+
print(f'User {user_guid} added to silent_users list. Current list: {self.silent_users}')
22+
23+
elif update.message.text == 'حذف از لیست سکوت':
24+
if user_guid in self.silent_users:
25+
self.silent_users.remove(user_guid)
26+
await update.reply(f'کاربر {utils.Mention("کاربر", user_guid)} از لیست سکوت حذف شد')
27+
print(f'User {user_guid} removed from silent_users list. Current list: {self.silent_users}')
28+
29+
elif update.message.text == 'بن':
30+
await self.ban_group_member(update.object_guid, user_guid)
31+
await update.reply(f'کاربر {utils.Mention("کاربر", user_guid)} از گروه حذف شد')
32+
33+
elif update.message.text == 'لیست سکوت':
34+
for x in self.silent_users:
35+
await update.reply(utils.Mention("کاربر", x))
36+
37+
async def check_silent_users(self, update: Updates):
38+
if update.message.author_object_guid in self.silent_users:
39+
await self.delete_messages(update.object_guid, update.message.message_id)
40+
41+
bot = Bot('sokot')
42+
bot.on_message_updates()(bot.handle_updates)
43+
bot.on_message_updates()(bot.check_silent_users)
44+
bot.run()

0 commit comments

Comments
 (0)