randydev commited on
Commit
dde99d7
Β·
verified Β·
1 Parent(s): 0f61e58

Update chatbot/plugins/chat.py

Browse files
Files changed (1) hide show
  1. chatbot/plugins/chat.py +37 -6
chatbot/plugins/chat.py CHANGED
@@ -282,8 +282,28 @@ async def deletemydata(client, callback):
282
  else:
283
  await callback.answer(delm, True)
284
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
  @Client.on_callback_query(filters.regex("^autopost_(\d+)$"))
286
- async def auto_post(client, callback):
287
  user_id = int(callback.matches[0].group(1))
288
  try:
289
  backup_chat = await db._get_chatbot_chat_from_db(user_id)
@@ -294,13 +314,20 @@ async def auto_post(client, callback):
294
  if data.get("is_channel_photo", False):
295
  if not file_id:
296
  return await callback.answer("Can't found file_id", True)
 
 
 
 
297
  await client.send_photo(
298
- data.get("channel_id"),
299
  photo=file_id,
300
- caption=caption
301
  )
 
 
302
  except Exception as e:
303
  LOGS.error(f"auto_post failed: {str(e)}")
 
304
 
305
  @Client.on_callback_query(filters.regex("^genprompt_(\d+)$"))
306
  async def geminigen_prompt(client, callback):
@@ -421,10 +448,14 @@ async def flux_prompt(client, callback):
421
  ),
422
  reply_markup=keyboard
423
  )
424
- # photo = await client.send_photo("@xpushz", file_path)
425
  await db.backup_chatbot.update_one(
426
  {"user_id": user_id},
427
- {"$set": {"translate_text": response.text}},
 
 
 
 
428
  upsert=True
429
  )
430
  backup_chat.append({"role": "model", "parts": [{"text": response.text}]})
@@ -596,7 +627,7 @@ def create_keyboard(likes: int = 0, unlikes: int = 0, user_id: int = None):
596
  InlineKeyboardButton(f"πŸ‘ {likes}", callback_data="like"),
597
  InlineKeyboardButton(f"πŸ‘Ž {unlikes}", callback_data="unlike"),
598
  InlineKeyboardButton(f"♾️", callback_data=f"trmulti_{user_id}"),
599
- InlineKeyboardButton(f"πŸ”", callback_data="refreshch"),
600
  InlineKeyboardButton(f"πŸ’Ύ", callback_data=f"memory_{user_id}"),
601
  ]
602
  ]
 
282
  else:
283
  await callback.answer(delm, True)
284
 
285
+ @Client.on_callback_query(filters.regex("^menutools_(\d+)$"))
286
+ async def menu_tools(client, callback):
287
+ user_id = int(callback.matches[0].group(1))
288
+ keyboard = []
289
+ keyboard.append([
290
+ InlineKeyboardButton("πŸ†• Post to Channel", callback_data=f"autopost_{user_id}"),
291
+ InlineKeyboardButton("πŸ” Refresh", callback_data="refreshch")
292
+ ])
293
+ keyboard.append([
294
+ InlineKeyboardButton(f"πŸ’Ύ", callback_data=f"memory_{user_id}")
295
+ ])
296
+ try:
297
+ await callback.edit_message_reply_markup(
298
+ reply_markup=InlineKeyboardMarkup(keyboard)
299
+ )
300
+ await callback.answer("Menu Tools", False)
301
+ except Exception as e:
302
+ LOGS.error(f"Exception menu_tools: {str(e)}")
303
+ await callback.answer("Server busy try again later", True)
304
+
305
  @Client.on_callback_query(filters.regex("^autopost_(\d+)$"))
306
+ async def auto_post_channel(client, callback):
307
  user_id = int(callback.matches[0].group(1))
308
  try:
309
  backup_chat = await db._get_chatbot_chat_from_db(user_id)
 
314
  if data.get("is_channel_photo", False):
315
  if not file_id:
316
  return await callback.answer("Can't found file_id", True)
317
+ who_post = data.get("channel_id", None)
318
+ if not who_post:
319
+ return await callback.answer("Can't found channel id", True)
320
+ await callback.answer("Ok process", False)
321
  await client.send_photo(
322
+ who_post,
323
  photo=file_id,
324
+ caption=data.get("translate_text", "")
325
  )
326
+ await callback.answer("Posted to Your Channel Check Now", True)
327
+ return await callback.answer("Need Channel as admin", True)
328
  except Exception as e:
329
  LOGS.error(f"auto_post failed: {str(e)}")
330
+ await callback.answer("Server busy try again later", True)
331
 
332
  @Client.on_callback_query(filters.regex("^genprompt_(\d+)$"))
333
  async def geminigen_prompt(client, callback):
 
448
  ),
449
  reply_markup=keyboard
450
  )
451
+ photo = await client.send_photo("LicenseAknBotDB", file_path)
452
  await db.backup_chatbot.update_one(
453
  {"user_id": user_id},
454
+ {"$set": {
455
+ "translate_text": response.text,
456
+ "file_id": photo.file_id,
457
+ "is_channel_photo": True
458
+ }},
459
  upsert=True
460
  )
461
  backup_chat.append({"role": "model", "parts": [{"text": response.text}]})
 
627
  InlineKeyboardButton(f"πŸ‘ {likes}", callback_data="like"),
628
  InlineKeyboardButton(f"πŸ‘Ž {unlikes}", callback_data="unlike"),
629
  InlineKeyboardButton(f"♾️", callback_data=f"trmulti_{user_id}"),
630
+ InlineKeyboardButton(f"πŸ—ƒοΈ", callback_data=f"autopost_{user_id}"),
631
  InlineKeyboardButton(f"πŸ’Ύ", callback_data=f"memory_{user_id}"),
632
  ]
633
  ]