Update chatbot/plugins/chat.py
Browse files- chatbot/plugins/chat.py +47 -6
chatbot/plugins/chat.py
CHANGED
@@ -270,7 +270,7 @@ def split_message(text: str) -> List[str]:
|
|
270 |
async def check_steal_channel_id(client, event: ChatMemberUpdated):
|
271 |
old_status = event.old_chat_member.status if event.old_chat_member else None
|
272 |
new_status = event.new_chat_member.status if event.new_chat_member else None
|
273 |
-
user_id = event.new_chat_member.promoted_by.id if event.new_chat_member
|
274 |
if not user_id:
|
275 |
return
|
276 |
keyboard = []
|
@@ -320,7 +320,7 @@ async def menu_tools(client, callback):
|
|
320 |
keyboard = []
|
321 |
keyboard.append([
|
322 |
InlineKeyboardButton("π Post to Channel", callback_data=f"autopost_{user_id}"),
|
323 |
-
InlineKeyboardButton("
|
324 |
])
|
325 |
keyboard.append([
|
326 |
InlineKeyboardButton(f"πΎ", callback_data=f"memory_{user_id}")
|
@@ -349,7 +349,6 @@ async def auto_post_channel(client, callback):
|
|
349 |
who_post = data.get("channel_id", None)
|
350 |
if not who_post:
|
351 |
return await callback.answer("@GeminiAIDev_bot add to your channel as admin!", True)
|
352 |
-
# await callback.answer("Ok process", False)
|
353 |
if data.get("can_post_messages", False):
|
354 |
await callback.answer("Posted to Your Channel Check Now", True)
|
355 |
await client.send_photo(
|
@@ -357,7 +356,7 @@ async def auto_post_channel(client, callback):
|
|
357 |
photo=file_id,
|
358 |
caption=data.get("translate_text", "")
|
359 |
)
|
360 |
-
keyboard = create_keyboard(user_id=user_id)
|
361 |
await callback.edit_message_reply_markup(reply_markup=keyboard)
|
362 |
return
|
363 |
|
@@ -678,18 +677,60 @@ def anonymous_user(user_id: int = None):
|
|
678 |
)
|
679 |
return keyboard
|
680 |
|
681 |
-
|
|
|
|
|
682 |
keyboard = InlineKeyboardMarkup(
|
683 |
[
|
684 |
[
|
685 |
InlineKeyboardButton(f"π {likes}", callback_data="like"),
|
686 |
InlineKeyboardButton(f"π {unlikes}", callback_data="unlike"),
|
687 |
-
InlineKeyboardButton(f"βΎοΈ", callback_data=f"trmulti_{user_id}"),
|
688 |
InlineKeyboardButton(f"ποΈ", callback_data=f"menutools_{user_id}"),
|
|
|
689 |
InlineKeyboardButton(f"πΎ", callback_data=f"memory_{user_id}"),
|
690 |
]
|
691 |
]
|
692 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
693 |
return keyboard
|
694 |
|
695 |
@Client.on_callback_query()
|
|
|
270 |
async def check_steal_channel_id(client, event: ChatMemberUpdated):
|
271 |
old_status = event.old_chat_member.status if event.old_chat_member else None
|
272 |
new_status = event.new_chat_member.status if event.new_chat_member else None
|
273 |
+
user_id = event.new_chat_member.promoted_by.id if event.new_chat_member else None
|
274 |
if not user_id:
|
275 |
return
|
276 |
keyboard = []
|
|
|
320 |
keyboard = []
|
321 |
keyboard.append([
|
322 |
InlineKeyboardButton("π Post to Channel", callback_data=f"autopost_{user_id}"),
|
323 |
+
InlineKeyboardButton("π§± Back To Menu", callback_data=f"response_{user_id}")
|
324 |
])
|
325 |
keyboard.append([
|
326 |
InlineKeyboardButton(f"πΎ", callback_data=f"memory_{user_id}")
|
|
|
349 |
who_post = data.get("channel_id", None)
|
350 |
if not who_post:
|
351 |
return await callback.answer("@GeminiAIDev_bot add to your channel as admin!", True)
|
|
|
352 |
if data.get("can_post_messages", False):
|
353 |
await callback.answer("Posted to Your Channel Check Now", True)
|
354 |
await client.send_photo(
|
|
|
356 |
photo=file_id,
|
357 |
caption=data.get("translate_text", "")
|
358 |
)
|
359 |
+
keyboard = create_keyboard(user_id=user_id, is_menu=True)
|
360 |
await callback.edit_message_reply_markup(reply_markup=keyboard)
|
361 |
return
|
362 |
|
|
|
677 |
)
|
678 |
return keyboard
|
679 |
|
680 |
+
@Client.on_callback_query(filters.regex("^response_(\d+)$"))
|
681 |
+
async def response_call(client, callback):
|
682 |
+
user_id = int(callback.matches[0].group(1))
|
683 |
keyboard = InlineKeyboardMarkup(
|
684 |
[
|
685 |
[
|
686 |
InlineKeyboardButton(f"π {likes}", callback_data="like"),
|
687 |
InlineKeyboardButton(f"π {unlikes}", callback_data="unlike"),
|
|
|
688 |
InlineKeyboardButton(f"ποΈ", callback_data=f"menutools_{user_id}"),
|
689 |
+
InlineKeyboardButton(f"βΎοΈ", callback_data=f"trmulti_{user_id}"),
|
690 |
InlineKeyboardButton(f"πΎ", callback_data=f"memory_{user_id}"),
|
691 |
]
|
692 |
]
|
693 |
)
|
694 |
+
await callback.edit_message_reply_markup(
|
695 |
+
reply_markup=keyboard
|
696 |
+
)
|
697 |
+
return keyboard
|
698 |
+
|
699 |
+
|
700 |
+
def create_keyboard(
|
701 |
+
likes: int = 0,
|
702 |
+
unlikes: int = 0,
|
703 |
+
user_id: int = None,
|
704 |
+
chat: str = None,
|
705 |
+
is_menu: bool = False
|
706 |
+
):
|
707 |
+
if is_menu:
|
708 |
+
keyboard = InlineKeyboardMarkup(
|
709 |
+
[
|
710 |
+
[
|
711 |
+
InlineKeyboardButton(f"ποΈ", callback_data=f"menutools_{user_id}"),
|
712 |
+
InlineKeyboardButton(f"π", url=f"https://t.me/{chat}"),
|
713 |
+
InlineKeyboardButton(f"βΎοΈ", callback_data=f"trmulti_{user_id}"),
|
714 |
+
InlineKeyboardButton(f"πΎ", callback_data=f"memory_{user_id}"),
|
715 |
+
],
|
716 |
+
[
|
717 |
+
InlineKeyboardButton(f"π {likes}", callback_data="like"),
|
718 |
+
InlineKeyboardButton(f"π {unlikes}", callback_data="unlike"),
|
719 |
+
]
|
720 |
+
]
|
721 |
+
)
|
722 |
+
else:
|
723 |
+
keyboard = InlineKeyboardMarkup(
|
724 |
+
[
|
725 |
+
[
|
726 |
+
InlineKeyboardButton(f"π {likes}", callback_data="like"),
|
727 |
+
InlineKeyboardButton(f"π {unlikes}", callback_data="unlike"),
|
728 |
+
InlineKeyboardButton(f"βΎοΈ", callback_data=f"trmulti_{user_id}"),
|
729 |
+
InlineKeyboardButton(f"π", callback_data=f"refreshch"),
|
730 |
+
InlineKeyboardButton(f"πΎ", callback_data=f"memory_{user_id}"),
|
731 |
+
]
|
732 |
+
]
|
733 |
+
)
|
734 |
return keyboard
|
735 |
|
736 |
@Client.on_callback_query()
|