Update chatbot/plugins/chat.py
Browse files- chatbot/plugins/chat.py +51 -3
chatbot/plugins/chat.py
CHANGED
@@ -284,6 +284,7 @@ async def check_steal_channel_id(client, event: ChatMemberUpdated):
|
|
284 |
{"$set": {
|
285 |
"channel_username": event.chat.username,
|
286 |
"channel_id": event.chat.id,
|
|
|
287 |
"can_post_messages": event.new_chat_member.privileges.can_post_messages
|
288 |
}},
|
289 |
upsert=True
|
@@ -315,6 +316,30 @@ async def deletemydata(client, callback):
|
|
315 |
else:
|
316 |
await callback.answer(delm, True)
|
317 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
@Client.on_callback_query(filters.regex("^menutools_(\d+)$"))
|
319 |
async def menu_tools(client, callback):
|
320 |
user_id = int(callback.matches[0].group(1))
|
@@ -324,6 +349,7 @@ async def menu_tools(client, callback):
|
|
324 |
keyboard = []
|
325 |
keyboard.append([
|
326 |
InlineKeyboardButton("π Post to Channel", callback_data=f"autopost_{user_id}"),
|
|
|
327 |
InlineKeyboardButton("π§± Back To Menu", callback_data=f"response_{user_id}_{data.get('channel_username', 'RendyProjects')}")
|
328 |
])
|
329 |
keyboard.append([
|
@@ -363,7 +389,7 @@ async def auto_post_channel(client, callback):
|
|
363 |
keyboard = create_keyboard(
|
364 |
user_id=user_id,
|
365 |
chat=data.get("channel_username", "RendyProjects"),
|
366 |
-
is_menu=
|
367 |
)
|
368 |
await callback.edit_message_reply_markup(reply_markup=keyboard)
|
369 |
return
|
@@ -512,8 +538,7 @@ async def flux_prompt(client, callback):
|
|
512 |
{"user_id": user_id},
|
513 |
{"$set": {
|
514 |
"translate_text": response.text,
|
515 |
-
"file_id": photo.photo.file_id
|
516 |
-
"is_channel_photo": True
|
517 |
}},
|
518 |
upsert=True
|
519 |
)
|
@@ -643,6 +668,29 @@ async def terjemahkan(client, callback):
|
|
643 |
LOGS.error(f"Exception translate: {str(e)}")
|
644 |
await callback.answer("Server busy try again later", True)
|
645 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
646 |
@Client.on_callback_query(filters.regex("^trmulti_(\d+)$"))
|
647 |
async def multiple_langagues(client, callback):
|
648 |
user_id = int(callback.matches[0].group(1))
|
|
|
284 |
{"$set": {
|
285 |
"channel_username": event.chat.username,
|
286 |
"channel_id": event.chat.id,
|
287 |
+
"is_channel_photo": True,
|
288 |
"can_post_messages": event.new_chat_member.privileges.can_post_messages
|
289 |
}},
|
290 |
upsert=True
|
|
|
316 |
else:
|
317 |
await callback.answer(delm, True)
|
318 |
|
319 |
+
@Client.on_callback_query(filters.regex("^photo_(\d+)$"))
|
320 |
+
async def modephoto(client, callback):
|
321 |
+
user_id = int(callback.matches[0].group(1))
|
322 |
+
data = await db.backup_chatbot.find_one({"user_id": user_id})
|
323 |
+
if not data:
|
324 |
+
return await callback.answer("Can't found user", True)
|
325 |
+
keyboard = []
|
326 |
+
keyboard.append([
|
327 |
+
InlineKeyboardButton("β
Mode Enabled", callback_data=f"photomode_{user_id}_true"),
|
328 |
+
InlineKeyboardButton("β Mode Disabled", callback_data=f"photomode_{user_id}_false"),
|
329 |
+
InlineKeyboardButton("π§± Back To Menu", callback_data=f"response_{user_id}_{data.get('channel_username', 'RendyProjects')}")
|
330 |
+
])
|
331 |
+
keyboard.append([
|
332 |
+
InlineKeyboardButton(f"πΎ", callback_data=f"memory_{user_id}")
|
333 |
+
])
|
334 |
+
try:
|
335 |
+
await callback.edit_message_reply_markup(
|
336 |
+
reply_markup=InlineKeyboardMarkup(keyboard)
|
337 |
+
)
|
338 |
+
await callback.answer("Menu Tools", False)
|
339 |
+
except Exception as e:
|
340 |
+
LOGS.error(f"Exception menu_tools: {str(e)}")
|
341 |
+
await callback.answer("Server busy try again later", True)
|
342 |
+
|
343 |
@Client.on_callback_query(filters.regex("^menutools_(\d+)$"))
|
344 |
async def menu_tools(client, callback):
|
345 |
user_id = int(callback.matches[0].group(1))
|
|
|
349 |
keyboard = []
|
350 |
keyboard.append([
|
351 |
InlineKeyboardButton("π Post to Channel", callback_data=f"autopost_{user_id}"),
|
352 |
+
InlineKeyboardButton("πΏ Channel Mode", callback_data=f"photo_{user_id}"),
|
353 |
InlineKeyboardButton("π§± Back To Menu", callback_data=f"response_{user_id}_{data.get('channel_username', 'RendyProjects')}")
|
354 |
])
|
355 |
keyboard.append([
|
|
|
389 |
keyboard = create_keyboard(
|
390 |
user_id=user_id,
|
391 |
chat=data.get("channel_username", "RendyProjects"),
|
392 |
+
is_menu=data.get("is_channel_photo", False)
|
393 |
)
|
394 |
await callback.edit_message_reply_markup(reply_markup=keyboard)
|
395 |
return
|
|
|
538 |
{"user_id": user_id},
|
539 |
{"$set": {
|
540 |
"translate_text": response.text,
|
541 |
+
"file_id": photo.photo.file_id
|
|
|
542 |
}},
|
543 |
upsert=True
|
544 |
)
|
|
|
668 |
LOGS.error(f"Exception translate: {str(e)}")
|
669 |
await callback.answer("Server busy try again later", True)
|
670 |
|
671 |
+
@Client.on_callback_query(filters.regex("^photomode_(\d+)_(\w+)$"))
|
672 |
+
async def photo_mode(client, callback):
|
673 |
+
user_id, mode = callback.matches[0].groups()
|
674 |
+
data = await db.backup_chatbot.find_one({"user_id": int(user_id)})
|
675 |
+
if not data:
|
676 |
+
return await callback.answer("Can't found user", True)
|
677 |
+
mode_mapping = {"true": True, "false": False}
|
678 |
+
is_channel_photo = mode_mapping.get(mode.lower(), False)
|
679 |
+
await db.backup_chatbot.update_one(
|
680 |
+
{"user_id": int(user_id)},
|
681 |
+
{"$set": {"is_channel_photo": is_channel_photo}},
|
682 |
+
upsert=True
|
683 |
+
)
|
684 |
+
await callback.answer(f"Set Channels To {is_channel_photo}")
|
685 |
+
keyboard = create_keyboard(
|
686 |
+
user_id=user_id,
|
687 |
+
chat=data.get("channel_username", "RendyProjects"),
|
688 |
+
is_menu=data.get("is_channel_photo", False)
|
689 |
+
)
|
690 |
+
await callback.edit_message_reply_markup(
|
691 |
+
reply_markup=keyboard
|
692 |
+
)
|
693 |
+
|
694 |
@Client.on_callback_query(filters.regex("^trmulti_(\d+)$"))
|
695 |
async def multiple_langagues(client, callback):
|
696 |
user_id = int(callback.matches[0].group(1))
|