-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathmain.py
More file actions
43 lines (28 loc) · 1.21 KB
/
main.py
File metadata and controls
43 lines (28 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from bot.bot import start, list_files, upload_file, search_button, cython, pi_button, FIRST, SECOND
from dotenv import load_dotenv
from telegram.ext import ApplicationBuilder, CommandHandler, MessageHandler, filters, CallbackQueryHandler, ConversationHandler
import os
def main():
import cProfile
import pstats
load_dotenv()
application = ApplicationBuilder().token(os.getenv('TOKEN')).build()
application.add_handler(CommandHandler('start', start))
with cProfile.Profile() as pr:
application.add_handler(CommandHandler('files', list_files))
stats = pstats.Stats(pr)
stats.sort_stats(pstats.SortKey.TIME)
stats.dump_stats(filename='profiling.prof')
conv_handler = ConversationHandler(
entry_points=[CommandHandler("cython", cython)],
states={
FIRST: [CallbackQueryHandler(search_button)],
SECOND: [CallbackQueryHandler(pi_button)],
},
fallbacks=[CommandHandler("cython", cython)],
)
application.add_handler(conv_handler)
application.add_handler(MessageHandler(filters.Document.ALL, upload_file))
application.run_polling()
if __name__ == '__main__':
main()