Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- from dotenv import load_dotenv
- from telethon import TelegramClient, events, Button
- load_dotenv()
- TOKEN = os.getenv('TOKEN')
- API_ID = int(os.getenv('API_ID'))
- API_HASH = os.getenv('API_HASH')
- print(TOKEN, API_ID, API_HASH)
- bot = TelegramClient('bot', API_ID, API_HASH).start(bot_token=TOKEN)
- @bot.on(events.InlineQuery())
- async def inline_query(event):
- builder = event.builder
- empty_image="https://upload.wikimedia.org/wikipedia/commons/5/59/Empty.png"
- results = [
- builder.photo(
- empty_image,
- text="Immagine senza immagine",
- buttons=Button.inline("Immagine", b"1"),
- include_media=False
- )
- ]
- await event.answer(results)
- @bot.on(events.CallbackQuery())
- async def button(event):
- if event.data == b"1":
- img="https://upload.wikimedia.org/wikipedia/commons/e/e9/Felis_silvestris_silvestris_small_gradual_decrease_of_quality.png"
- await event.edit_message(media=img)
- with bot:
- bot.run_until_disconnected()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement