Update chatbot/plugins/chat.py
Browse files- chatbot/plugins/chat.py +1 -217
chatbot/plugins/chat.py
CHANGED
@@ -315,44 +315,6 @@ def split_message(text: str) -> List[str]:
|
|
315 |
text = ""
|
316 |
return parts
|
317 |
|
318 |
-
@Client.on_chat_member_updated(
|
319 |
-
filters.channel
|
320 |
-
)
|
321 |
-
async def check_steal_channel_id(client, event: ChatMemberUpdated):
|
322 |
-
old_status = event.old_chat_member.status if event.old_chat_member else None
|
323 |
-
new_status = event.new_chat_member.status if event.new_chat_member else None
|
324 |
-
user_id = event.new_chat_member.promoted_by.id if event.new_chat_member else None
|
325 |
-
if not user_id or event.chat.username is None:
|
326 |
-
return
|
327 |
-
user_bl = await db.user_blacklists.find_one({"user_id": user_id})
|
328 |
-
if user_bl and user_bl.get("is_frozen", False):
|
329 |
-
return
|
330 |
-
|
331 |
-
keyboard = []
|
332 |
-
keyboard.append([
|
333 |
-
InlineKeyboardButton("๐ View Channel", url=f"https://t.me/{event.chat.username}"),
|
334 |
-
InlineKeyboardButton("โ Close", callback_data="closedd")
|
335 |
-
])
|
336 |
-
try:
|
337 |
-
await db.backup_chatbot.update_one(
|
338 |
-
{"user_id": user_id},
|
339 |
-
{"$set": {
|
340 |
-
"channel_username": event.chat.username,
|
341 |
-
"channel_id": event.chat.id,
|
342 |
-
"is_channel_photo": True,
|
343 |
-
"can_post_messages": event.new_chat_member.privileges.can_post_messages
|
344 |
-
}},
|
345 |
-
upsert=True
|
346 |
-
)
|
347 |
-
await client.send_message(
|
348 |
-
user_id,
|
349 |
-
f"Successfully connected to your [`{event.chat.id}`] channel",
|
350 |
-
reply_markup=InlineKeyboardMarkup(keyboard)
|
351 |
-
)
|
352 |
-
# LOGS.info(f"Update Channel: {event.new_chat_member}")
|
353 |
-
except Exception as e:
|
354 |
-
LOGS.error(f"Error check_steal_channel_id: {str(e)}")
|
355 |
-
|
356 |
@Client.on_callback_query(filters.regex("^cancels"))
|
357 |
async def cancel_(client, callback_query):
|
358 |
chat_id = callback_query.message.chat.id
|
@@ -376,121 +338,6 @@ async def deletemydata(client, callback):
|
|
376 |
else:
|
377 |
await callback.answer(delm, True)
|
378 |
|
379 |
-
@Client.on_callback_query(filters.regex("^photo_(\d+)$"))
|
380 |
-
async def modephoto(client, callback):
|
381 |
-
user_id = int(callback.matches[0].group(1))
|
382 |
-
user_bl = await db.user_blacklists.find_one({"user_id": user_id})
|
383 |
-
if user_bl and user_bl.get("is_frozen", False):
|
384 |
-
await callback.answer("Sorry your account is disabled", True)
|
385 |
-
return
|
386 |
-
|
387 |
-
data = await db.backup_chatbot.find_one({"user_id": user_id})
|
388 |
-
if not data:
|
389 |
-
return await callback.answer("Can't found user", True)
|
390 |
-
keyboard = []
|
391 |
-
keyboard.append([
|
392 |
-
InlineKeyboardButton("โ
Mode Enabled", callback_data=f"photomode_{user_id}_true"),
|
393 |
-
InlineKeyboardButton("โ Mode Disabled", callback_data=f"photomode_{user_id}_false")
|
394 |
-
])
|
395 |
-
|
396 |
-
keyboard.append([
|
397 |
-
InlineKeyboardButton("๐งฑ Back To Menu", callback_data=f"response_{user_id}_{data.get('channel_username', 'RendyProjects')}")
|
398 |
-
])
|
399 |
-
|
400 |
-
keyboard.append([
|
401 |
-
InlineKeyboardButton(f"๐พ", callback_data=f"memory_{user_id}")
|
402 |
-
])
|
403 |
-
try:
|
404 |
-
await callback.edit_message_reply_markup(
|
405 |
-
reply_markup=InlineKeyboardMarkup(keyboard)
|
406 |
-
)
|
407 |
-
await callback.answer("Menu Tools", False)
|
408 |
-
except Exception as e:
|
409 |
-
LOGS.error(f"Exception menu_tools: {str(e)}")
|
410 |
-
await callback.answer("Server busy try again later", True)
|
411 |
-
|
412 |
-
@Client.on_callback_query(filters.regex("^menutools_(\d+)$"))
|
413 |
-
async def menu_tools(client, callback):
|
414 |
-
user_id = int(callback.matches[0].group(1))
|
415 |
-
user_bl = await db.user_blacklists.find_one({"user_id": user_id})
|
416 |
-
if user_bl and user_bl.get("is_frozen", False):
|
417 |
-
await callback.answer("Sorry your account is disabled", True)
|
418 |
-
return
|
419 |
-
|
420 |
-
data = await db.backup_chatbot.find_one({"user_id": user_id})
|
421 |
-
if not data:
|
422 |
-
return await callback.answer("Can't found user", True)
|
423 |
-
keyboard = []
|
424 |
-
keyboard.append([
|
425 |
-
InlineKeyboardButton("๐ Post to Channel", callback_data=f"autopost_{user_id}"),
|
426 |
-
InlineKeyboardButton("๐ฟ Channel Mode", callback_data=f"photo_{user_id}")
|
427 |
-
])
|
428 |
-
keyboard.append([
|
429 |
-
InlineKeyboardButton("๐งฑ Back To Menu", callback_data=f"response_{user_id}_{data.get('channel_username', 'RendyProjects')}")
|
430 |
-
])
|
431 |
-
keyboard.append([
|
432 |
-
InlineKeyboardButton(f"๐พ", callback_data=f"memory_{user_id}")
|
433 |
-
])
|
434 |
-
try:
|
435 |
-
await callback.edit_message_reply_markup(
|
436 |
-
reply_markup=InlineKeyboardMarkup(keyboard)
|
437 |
-
)
|
438 |
-
await callback.answer("Menu Tools", False)
|
439 |
-
except Exception as e:
|
440 |
-
LOGS.error(f"Exception menu_tools: {str(e)}")
|
441 |
-
await callback.answer("Server busy try again later", True)
|
442 |
-
|
443 |
-
@Client.on_callback_query(filters.regex("^autopost_(\d+)$"))
|
444 |
-
async def auto_post_channel(client, callback):
|
445 |
-
user_id = int(callback.matches[0].group(1))
|
446 |
-
user_bl = await db.user_blacklists.find_one({"user_id": user_id})
|
447 |
-
if user_bl and user_bl.get("is_frozen", False):
|
448 |
-
await callback.answer("Sorry your account is disabled", True)
|
449 |
-
return
|
450 |
-
|
451 |
-
try:
|
452 |
-
backup_chat = await db._get_chatbot_chat_from_db(user_id)
|
453 |
-
data = await db.backup_chatbot.find_one({"user_id": user_id})
|
454 |
-
if not data:
|
455 |
-
await callback.answer("Can't found user", True)
|
456 |
-
return
|
457 |
-
file_id = data.get("file_id", None)
|
458 |
-
if data.get("is_channel_photo", False):
|
459 |
-
if not file_id:
|
460 |
-
await callback.answer("Can't found file_id or expired", True)
|
461 |
-
return
|
462 |
-
who_post = data.get("channel_id", None)
|
463 |
-
if not who_post:
|
464 |
-
await callback.answer("@GeminiAIDev_bot add to your channel as admin!", True)
|
465 |
-
return
|
466 |
-
if data.get("can_post_messages", False):
|
467 |
-
await callback.answer("Posted to Your Channel Check Now", True)
|
468 |
-
await client.send_photo(
|
469 |
-
who_post,
|
470 |
-
photo=file_id,
|
471 |
-
caption=data.get("translate_text", "")
|
472 |
-
)
|
473 |
-
keyboard = create_keyboard(
|
474 |
-
user_id=user_id,
|
475 |
-
chat=data.get("channel_username", "RendyProjects"),
|
476 |
-
is_menu=data.get("is_channel_photo", False)
|
477 |
-
)
|
478 |
-
await db.backup_chatbot.update_one(
|
479 |
-
{"user_id": user_id},
|
480 |
-
{"$unset": {"file_id": None}}
|
481 |
-
)
|
482 |
-
await callback.edit_message_reply_markup(reply_markup=keyboard)
|
483 |
-
return
|
484 |
-
|
485 |
-
await callback.answer("Permissions: can_post_messages", True)
|
486 |
-
return
|
487 |
-
|
488 |
-
await callback.answer("You add bot me to your channel as admin! or channel Mode True/False", True)
|
489 |
-
return
|
490 |
-
except Exception as e:
|
491 |
-
LOGS.error(f"auto_post failed: {str(e)}")
|
492 |
-
await callback.answer("Server busy try again later", True)
|
493 |
-
|
494 |
@Client.on_callback_query(filters.regex("^genprompt_(\d+)$"))
|
495 |
async def geminigen_prompt(client, callback):
|
496 |
user_id = int(callback.matches[0].group(1))
|
@@ -533,8 +380,6 @@ async def geminigen_prompt(client, callback):
|
|
533 |
|
534 |
keyboard = create_keyboard(
|
535 |
user_id=user_id,
|
536 |
-
chat=data.get("channel_username", "RendyProjects"),
|
537 |
-
is_menu=data.get("is_channel_photo", False),
|
538 |
uuid_str=uuid_code
|
539 |
)
|
540 |
view_button_user = anonymous_user(user_id=user_id)
|
@@ -812,9 +657,7 @@ async def terjemahkan(client, callback):
|
|
812 |
)
|
813 |
keyboard = create_keyboard(
|
814 |
user_id=user_id,
|
815 |
-
uuid_str=uuidstr
|
816 |
-
chat=data_tr.get("channel_username", "RendyProjects"),
|
817 |
-
is_menu=data_tr.get("is_channel_photo", False)
|
818 |
)
|
819 |
await callback.edit_message_text(
|
820 |
translation.text,
|
@@ -825,33 +668,6 @@ async def terjemahkan(client, callback):
|
|
825 |
LOGS.error(f"Exception translate: {str(e)}")
|
826 |
await callback.answer("Server busy try again later", True)
|
827 |
|
828 |
-
@Client.on_callback_query(filters.regex("^photomode_(\d+)_(\w+)$"))
|
829 |
-
async def photo_mode(client, callback):
|
830 |
-
user_id, mode = callback.matches[0].groups()
|
831 |
-
user_bl = await db.user_blacklists.find_one({"user_id": int(user_id)})
|
832 |
-
if user_bl and user_bl.get("is_frozen", False):
|
833 |
-
await callback.answer("Sorry your account is disabled", True)
|
834 |
-
return
|
835 |
-
|
836 |
-
data = await db.backup_chatbot.find_one({"user_id": int(user_id)})
|
837 |
-
if not data:
|
838 |
-
return await callback.answer("Can't found user", True)
|
839 |
-
mode_mapping = {"true": True, "false": False}
|
840 |
-
is_channel_photo = mode_mapping.get(mode.lower(), False)
|
841 |
-
await db.backup_chatbot.update_one(
|
842 |
-
{"user_id": int(user_id)},
|
843 |
-
{"$set": {"is_channel_photo": is_channel_photo}},
|
844 |
-
upsert=True
|
845 |
-
)
|
846 |
-
await callback.answer(f"Set Channels To {is_channel_photo}")
|
847 |
-
keyboard = create_keyboard(
|
848 |
-
user_id=user_id,
|
849 |
-
chat=data.get("channel_username", "RendyProjects"),
|
850 |
-
is_menu=data.get("is_channel_photo", False)
|
851 |
-
)
|
852 |
-
await callback.edit_message_reply_markup(
|
853 |
-
reply_markup=keyboard
|
854 |
-
)
|
855 |
|
856 |
@Client.on_callback_query(filters.regex("^trmulti_(\d+)_([a-f0-9]{8})$"))
|
857 |
async def multiple_langagues(client, callback):
|
@@ -908,42 +724,17 @@ def anonymous_user(user_id: int = None):
|
|
908 |
)
|
909 |
return keyboard
|
910 |
|
911 |
-
@Client.on_callback_query(filters.regex("^response_(\d+)_(\w+)$"))
|
912 |
-
async def response_call(client, callback):
|
913 |
-
user_id, chat = callback.matches[0].groups()
|
914 |
-
user_bl = await db.user_blacklists.find_one({"user_id": int(user_id)})
|
915 |
-
if user_bl and user_bl.get("is_frozen", False):
|
916 |
-
await callback.answer("Sorry your account is disabled", True)
|
917 |
-
return
|
918 |
-
|
919 |
-
keyboard = InlineKeyboardMarkup(
|
920 |
-
[
|
921 |
-
[
|
922 |
-
InlineKeyboardButton(f"๐๏ธ", callback_data=f"menutools_{int(user_id)}"),
|
923 |
-
InlineKeyboardButton(f"๐", url=f"https://t.me/{chat}"),
|
924 |
-
],
|
925 |
-
[
|
926 |
-
InlineKeyboardButton(f"๐ 0", callback_data="like"),
|
927 |
-
InlineKeyboardButton(f"๐ 0", callback_data="unlike")
|
928 |
-
]
|
929 |
-
]
|
930 |
-
)
|
931 |
-
await callback.edit_message_reply_markup(reply_markup=keyboard)
|
932 |
-
|
933 |
def create_keyboard(
|
934 |
likes: int = 0,
|
935 |
unlikes: int = 0,
|
936 |
user_id: int = None,
|
937 |
uuid_str: str = None,
|
938 |
-
chat: str = None,
|
939 |
is_menu: bool = False
|
940 |
):
|
941 |
if is_menu:
|
942 |
keyboard = InlineKeyboardMarkup(
|
943 |
[
|
944 |
[
|
945 |
-
InlineKeyboardButton(f"๐๏ธ", callback_data=f"menutools_{user_id}"),
|
946 |
-
InlineKeyboardButton(f"๐", url=f"https://t.me/{chat}"),
|
947 |
InlineKeyboardButton(f"โพ๏ธ", callback_data=f"trmulti_{user_id}_{uuid_str}"),
|
948 |
InlineKeyboardButton(f"๐พ", callback_data=f"memory_{user_id}_{uuid_str}"),
|
949 |
],
|
@@ -957,7 +748,6 @@ def create_keyboard(
|
|
957 |
keyboard = InlineKeyboardMarkup(
|
958 |
[
|
959 |
[
|
960 |
-
InlineKeyboardButton(f"๐๏ธ", callback_data=f"menutools_{user_id}"),
|
961 |
InlineKeyboardButton(f"โพ๏ธ", callback_data=f"trmulti_{user_id}_{uuid_str}"),
|
962 |
InlineKeyboardButton(f"๐", callback_data=f"refreshch"),
|
963 |
InlineKeyboardButton(f"๐พ", callback_data=f"memory_{user_id}_{uuid_str}")
|
@@ -1024,12 +814,6 @@ async def startbot(client: Client, message: Message):
|
|
1024 |
users_all = await db.backup_chatbot.find_one({"bot_id": client.me.id})
|
1025 |
users_count = len(users_all["broadcast"])
|
1026 |
buttons = [
|
1027 |
-
[
|
1028 |
-
InlineKeyboardButton(
|
1029 |
-
text="Try this Gemini OLD",
|
1030 |
-
url=f"https://t.me/ryuzaki_asstbot"
|
1031 |
-
),
|
1032 |
-
],
|
1033 |
[
|
1034 |
InlineKeyboardButton(
|
1035 |
text="Developer",
|
|
|
315 |
text = ""
|
316 |
return parts
|
317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
@Client.on_callback_query(filters.regex("^cancels"))
|
319 |
async def cancel_(client, callback_query):
|
320 |
chat_id = callback_query.message.chat.id
|
|
|
338 |
else:
|
339 |
await callback.answer(delm, True)
|
340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
@Client.on_callback_query(filters.regex("^genprompt_(\d+)$"))
|
342 |
async def geminigen_prompt(client, callback):
|
343 |
user_id = int(callback.matches[0].group(1))
|
|
|
380 |
|
381 |
keyboard = create_keyboard(
|
382 |
user_id=user_id,
|
|
|
|
|
383 |
uuid_str=uuid_code
|
384 |
)
|
385 |
view_button_user = anonymous_user(user_id=user_id)
|
|
|
657 |
)
|
658 |
keyboard = create_keyboard(
|
659 |
user_id=user_id,
|
660 |
+
uuid_str=uuidstr
|
|
|
|
|
661 |
)
|
662 |
await callback.edit_message_text(
|
663 |
translation.text,
|
|
|
668 |
LOGS.error(f"Exception translate: {str(e)}")
|
669 |
await callback.answer("Server busy try again later", True)
|
670 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
671 |
|
672 |
@Client.on_callback_query(filters.regex("^trmulti_(\d+)_([a-f0-9]{8})$"))
|
673 |
async def multiple_langagues(client, callback):
|
|
|
724 |
)
|
725 |
return keyboard
|
726 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
727 |
def create_keyboard(
|
728 |
likes: int = 0,
|
729 |
unlikes: int = 0,
|
730 |
user_id: int = None,
|
731 |
uuid_str: str = None,
|
|
|
732 |
is_menu: bool = False
|
733 |
):
|
734 |
if is_menu:
|
735 |
keyboard = InlineKeyboardMarkup(
|
736 |
[
|
737 |
[
|
|
|
|
|
738 |
InlineKeyboardButton(f"โพ๏ธ", callback_data=f"trmulti_{user_id}_{uuid_str}"),
|
739 |
InlineKeyboardButton(f"๐พ", callback_data=f"memory_{user_id}_{uuid_str}"),
|
740 |
],
|
|
|
748 |
keyboard = InlineKeyboardMarkup(
|
749 |
[
|
750 |
[
|
|
|
751 |
InlineKeyboardButton(f"โพ๏ธ", callback_data=f"trmulti_{user_id}_{uuid_str}"),
|
752 |
InlineKeyboardButton(f"๐", callback_data=f"refreshch"),
|
753 |
InlineKeyboardButton(f"๐พ", callback_data=f"memory_{user_id}_{uuid_str}")
|
|
|
814 |
users_all = await db.backup_chatbot.find_one({"bot_id": client.me.id})
|
815 |
users_count = len(users_all["broadcast"])
|
816 |
buttons = [
|
|
|
|
|
|
|
|
|
|
|
|
|
817 |
[
|
818 |
InlineKeyboardButton(
|
819 |
text="Developer",
|