File size: 637 Bytes
37aea19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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)