Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import telebot
- from telebot import types
- import urllib.request
- import json
- token = "765360465:AAFfxN_u4nxQjsHdHSgUF_lh8sm7dUf3X0A"
- proxy_user = "usangeorg@y_4244"
- proxy_pass = "DF5PivaA5iff6cX9"
- proxy_addr = "vpnde01.fornex.org"
- proxy_port = 1080
- telebot.apihelper.proxy = {
- "https": f"socks5://{proxy_user}:{proxy_pass}@{proxy_addr}:{proxy_port}"
- }
- # connect to the telegram
- bot = telebot.TeleBot(token)
- stickers = []
- @bot.message_handler(commands=["start"])
- def repeat_all_messages(message):
- # создаем клавиатуру
- keyboard = types.InlineKeyboardMarkup()
- # add buttons
- button1 = types.InlineKeyboardButton(text="Help", callback_data="button1")
- button2 = types.InlineKeyboardButton(text="FAQ", callback_data="button2")
- button3 = types.InlineKeyboardButton(text="Search", callback_data="button3")
- keyboard.add(button1)
- keyboard.add(button2)
- keyboard.add(button3)
- # send message to the user
- bot.send_message(message.chat.id, "Hello!", reply_markup=keyboard)
- # this shit will be activated if the user pressed the button
- @bot.callback_query_handler(func=lambda call: True)
- def callback_inline(call):
- tops = {"Action & Adventure": 10769, "Animation" : 16, "Comedy" : 35, "Crime" : 80, "Documentory" : 99, "Drama" : 18,
- "Family" : 10751, "Kids" : 10762, "Mystery" : 9658, "News" : 10763, "Reality" : 110764, "SciFi_Fantasy" : 10765, "Soap" :10766, "Talk" : 10767,
- "Western" : 37}
- if call.message:
- if call.data == "button1":
- bot.send_message(call.message.chat.id, "Hello, here you can read the information.")
- if call.data == "button2":
- 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\"")
- if call.data == "button3":
- keyboard2 = types.InlineKeyboardMarkup()
- button1 = types.InlineKeyboardButton(text="TOP", callback_data="TOP")
- keyboard2.add(button1)
- bot.send_message(call.message.chat.id, "TOP list:", reply_markup=keyboard2)
- if call.data == "TOP":
- keyboard = types.InlineKeyboardMarkup()
- for genre in tops:
- genre_button = types.InlineKeyboardButton(text=genre, callback_data=genre)
- keyboard.add(genre_button)
- bot.send_message(call.message.chat.id, "TOPS:", reply_markup=keyboard)
- if call.data in tops:
- contents = urllib.request.urlopen("https://api.themoviedb.org/3/discover/movie?with_genres={0}&api_key=cdd772a7762e4faaddab11871a7cda8b".format(tops[call.data]))
- data = json.load(contents)
- a = ""
- print (data)
- for i in range(20):
- a += data["results"][i]["title"] + "\n"
- bot.send_message(call.message.chat.id, a)
- bot.polling(none_stop=True)
- рабочие жанры:drama, wester, documentory, animation,comedy,crime,family
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement