-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
62 lines (43 loc) · 1.93 KB
/
main.py
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env python
# pylint: disable=unused-argument, wrong-import-position
import logging
import asyncio
import os
from telegram import Update
from telegram.ext import filters, ApplicationBuilder, ContextTypes, CommandHandler, MessageHandler
from database import *
from activity import *
from puzzles import *
from users import *
from tops import *
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
level=logging.INFO
)
async def ping(update: Update, context: ContextTypes.DEFAULT_TYPE):
await context.bot.send_message(chat_id=update.effective_chat.id, text="pong")
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
await context.bot.send_message(chat_id=update.effective_chat.id, text="Hey there")
async def unknown(update: Update, context: ContextTypes.DEFAULT_TYPE):
await context.bot.send_message(chat_id=update.effective_chat.id, text="Sorry, I didn't understand that command.")
TOKEN = os.environ.get('TOKEN', 'changeme')
if __name__ == '__main__':
database_initialize()
application = ApplicationBuilder().token(TOKEN).build()
start_handler = CommandHandler('start', start)
application.add_handler(start_handler)
ping_handler = CommandHandler('ping', ping)
application.add_handler(ping_handler)
register_handler = CommandHandler('register', register)
application.add_handler(register_handler)
stats_handler = CommandHandler('stats', stats)
application.add_handler(stats_handler)
top_chat_handler = CommandHandler('top_chat', top_chat)
application.add_handler(top_chat_handler)
puzzles_handler = CommandHandler('puzzle', puzzles)
application.add_handler(puzzles_handler)
activity_handler = CommandHandler('activity', activity)
application.add_handler(activity_handler)
unknown_handler = MessageHandler(filters.COMMAND, unknown)
application.add_handler(unknown_handler)
application.run_polling()