KotVasily commited on
Commit
37aea19
·
verified ·
1 Parent(s): dcdf875

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +23 -0
main.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import random
3
+ import os
4
+
5
+ from aiogram import Bot, Dispatcher, executor, types
6
+
7
+ TOKEN = "7588478727:AAF6E0Z6OYLn2pQ4XrfI91t0UeiM3SvADEA"
8
+ bot = Bot(token=TOKEN)
9
+ dp = Dispatcher(bot)
10
+ logging.basicConfig(level=logging.INFO)
11
+
12
+ @dp.message_handler(commands="random")
13
+ async def cmd_test1(message: types.Message):
14
+ meme_files = [f for f in os.listdir('image/') if f.endswith('.jpg')]
15
+ random_meme = random.choice(meme_files)
16
+
17
+ with open(os.path.join('image/', random_meme), 'rb') as photo:
18
+ await message.answer_photo(photo=photo)
19
+
20
+
21
+ if __name__ == "__main__":
22
+ executor.start_polling(dp, skip_updates=True)
23
+