Advertisement
dybun4uk

Untitled

Dec 15th, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.74 KB | None | 0 0
  1. #do not touch anything!
  2. import aiogram
  3. from aiogram import types
  4. import logging as log
  5. from fb import FEEDBACK_USER_ID
  6. from connection import bot, database_query
  7. from text import ANSWER_TO_USER as text_to_user
  8. from text import notallowed,block,ban,eror,like,unlike
  9. import sqlite3
  10.  
  11.  
  12.  
  13. async def feedback_message(message: types.Message):
  14. #this is for debug mode, if you need all info about user to be printed, uncomment it
  15. log.info(f'Message ({message.content_type}) from {message.from_user.first_name} ({message.from_user.id}) with text: {message.text}')
  16.  
  17. try:
  18. if message.chat.id == FEEDBACK_USER_ID:
  19. if message.reply_to_message is None:
  20. await message.answer(eror)
  21. else:
  22. try:
  23. units = database_query(f"SELECT user_id FROM messages WHERE message_id = {message.reply_to_message.message_id}")
  24. unit = units[0][0]
  25. if message.content_type == "text":
  26. await bot.send_message(unit,like, message.text)
  27. elif message.content_type == "photo":
  28. capt = message.caption
  29. await bot.send_photo(unit, message.photo[-1].file_id,caption=capt)
  30. elif message.content_type == "video":
  31. capt = message.caption
  32. await bot.send_video(unit, message.video.file_id,caption=capt)
  33. elif message.content_type == "sticker":
  34. await bot.send_sticker(unit, message.sticker.file_id)
  35. elif message.content_type == "audio":
  36. capt = message.caption
  37. await bot.send_audio(unit, message.audio.file_id,caption=capt)
  38. elif message.content_type == "voice":
  39. capt = message.caption
  40. await bot.send_voice(unit, message.voice.file_id,caption=capt)
  41. elif message.content_type == "document":
  42. capt = message.caption
  43. await bot.send_document(unit, message.document.file_id,caption=capt)
  44. elif message.content_type == "location":
  45. await bot.send_location(unit, message.location)
  46. elif message.content_type == "animation":
  47. capt = message.caption
  48. await bot.send_animation(unit, message.animation.file_id,caption=capt)
  49. elif message.content_type == "contact":
  50. await bot.send_contact(unit, message.contact.file_id)
  51. except aiogram.utils.exceptions.BotBlocked:
  52. await bot.send_message(message.chat.id,block)
  53. else:
  54. if message.forward_from == None:
  55. units = database_query(f"SELECT user_id FROM blocked WHERE user_id = {message.from_user.id}")
  56. unit = units
  57. print(unit)
  58. if not unit:
  59. forward_message_result = await bot.forward_message(FEEDBACK_USER_ID, message.chat.id, message.message_id)
  60. database_query(f"INSERT OR IGNORE INTO messages(user_id,username,full_name,message_id,message) "
  61. f"VALUES('{message.from_user.id}','{message.from_user.username}','{message.from_user.full_name}','{forward_message_result.message_id}','{message.text}')")
  62. await bot.send_message(message.chat.id, text_to_user)
  63. elif unit:
  64. await bot.send_message(message.chat.id, ban)
  65. else:
  66. await message.answer(notallowed)
  67. except Exception as e:
  68. await message.answer(message.chat.id,f"{str(e)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement