Advertisement
Guest User

ForAlyona

a guest
Jan 4th, 2019
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. import telebot
  2. from telebot import types
  3. import urllib.request
  4. import json
  5.  
  6. token = "765360465:AAFfxN_u4nxQjsHdHSgUF_lh8sm7dUf3X0A"
  7.  
  8. proxy_user = "usangeorg@y_4244"
  9. proxy_pass = "DF5PivaA5iff6cX9"
  10. proxy_addr = "vpnde01.fornex.org"
  11. proxy_port = 1080
  12.  
  13. telebot.apihelper.proxy = {
  14. "https": f"socks5://{proxy_user}:{proxy_pass}@{proxy_addr}:{proxy_port}"
  15. }
  16.  
  17. # connect to the telegram
  18. bot = telebot.TeleBot(token)
  19. stickers = []
  20.  
  21. @bot.message_handler(commands=["start"])
  22. def repeat_all_messages(message):
  23. # создаем клавиатуру
  24. keyboard = types.InlineKeyboardMarkup()
  25. # add buttons
  26. button1 = types.InlineKeyboardButton(text="Help", callback_data="button1")
  27. button2 = types.InlineKeyboardButton(text="FAQ", callback_data="button2")
  28. button3 = types.InlineKeyboardButton(text="Search", callback_data="button3")
  29. keyboard.add(button1)
  30. keyboard.add(button2)
  31. keyboard.add(button3)
  32. # send message to the user
  33. bot.send_message(message.chat.id, "Hello!", reply_markup=keyboard)
  34. # this shit will be activated if the user pressed the button
  35.  
  36. @bot.callback_query_handler(func=lambda call: True)
  37. def callback_inline(call):
  38. tops = {"Action & Adventure": 10769, "Animation" : 16, "Comedy" : 35, "Crime" : 80, "Documentory" : 99, "Drama" : 18,
  39. "Family" : 10751, "Kids" : 10762, "Mystery" : 9658, "News" : 10763, "Reality" : 110764, "SciFi_Fantasy" : 10765, "Soap" :10766, "Talk" : 10767,
  40. "Western" : 37}
  41. if call.message:
  42. if call.data == "button1":
  43. bot.send_message(call.message.chat.id, "Hello, here you can read the information.")
  44. if call.data == "button2":
  45. bot.send_message(call.message.chat.id, "Hello! This is FilmBot, here you can seatch for films and tops. For more information go to the \"Help\"")
  46. if call.data == "button3":
  47. keyboard2 = types.InlineKeyboardMarkup()
  48. button1 = types.InlineKeyboardButton(text="TOP", callback_data="TOP")
  49. keyboard2.add(button1)
  50. bot.send_message(call.message.chat.id, "TOP list:", reply_markup=keyboard2)
  51. if call.data == "TOP":
  52. keyboard = types.InlineKeyboardMarkup()
  53. for genre in tops:
  54. genre_button = types.InlineKeyboardButton(text=genre, callback_data=genre)
  55. keyboard.add(genre_button)
  56. bot.send_message(call.message.chat.id, "TOPS:", reply_markup=keyboard)
  57. if call.data in tops:
  58. contents = urllib.request.urlopen("https://api.themoviedb.org/3/discover/movie?with_genres={0}&api_key=cdd772a7762e4faaddab11871a7cda8b".format(tops[call.data]))
  59. data = json.load(contents)
  60. a = ""
  61. print (data)
  62. for i in range(20):
  63. a += data["results"][i]["title"] + "\n"
  64.  
  65. bot.send_message(call.message.chat.id, a)
  66.  
  67.  
  68.  
  69. bot.polling(none_stop=True)
  70.  
  71. рабочие жанры:drama, wester, documentory, animation,comedy,crime,family
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement