botpy / app.py
KotVasily's picture
Rename main.py to app.py
104fcfa verified
raw
history blame contribute delete
637 Bytes
import logging
import random
import os
from aiogram import Bot, Dispatcher, executor, types
TOKEN = "7588478727:AAF6E0Z6OYLn2pQ4XrfI91t0UeiM3SvADEA"
bot = Bot(token=TOKEN)
dp = Dispatcher(bot)
logging.basicConfig(level=logging.INFO)
@dp.message_handler(commands="random")
async def cmd_test1(message: types.Message):
meme_files = [f for f in os.listdir('image/') if f.endswith('.jpg')]
random_meme = random.choice(meme_files)
with open(os.path.join('image/', random_meme), 'rb') as photo:
await message.answer_photo(photo=photo)
if __name__ == "__main__":
executor.start_polling(dp, skip_updates=True)