-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
84 lines (68 loc) · 3.2 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#FUNCTIONAL MODULES
from start import start
from pparticulars.signup import signup_conv
from pparticulars.nok import nok_conv
from pparticulars.contact import contact_conv
from pparticulars.medical import medical_conv
from menu.menu import (
main_menu, cmd_menu, credits, pdpa, pdpa_disposable, delete_recent, more_menu, faq,
)
from menu.profile import my_profile
from activities import activities
from events import events, details, register, unregister
from schedule import schedule
#KEY MODULES
from database import db
from telegram import InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import (
Updater,
CommandHandler,
MessageHandler,
Filters,
ConversationHandler,
CallbackContext,
CallbackQueryHandler,
RegexHandler,
)
import logging
from dotenv import load_dotenv
import os
#Logging Module
logging.basicConfig(format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO)
logger = logging.getLogger(__name__)
#Token
load_dotenv('.env')
updater = Updater(token=os.getenv('SMUX_BOT_TOKEN'), use_context=True)
dispatcher = updater.dispatcher
#==============================================================================================#
start_handler = CommandHandler('start', start)
dispatcher.add_handler(start_handler)
dispatcher.add_handler(signup_conv)
dispatcher.add_handler(contact_conv)
dispatcher.add_handler(medical_conv)
dispatcher.add_handler(nok_conv)
#events callbacks
# updater.dispatcher.add_handler(RegexHandler('^(/info_[\d]+)$', info))
updater.dispatcher.add_handler(MessageHandler(Filters.regex('^(/details_[\d]+)$'), details))
updater.dispatcher.add_handler(MessageHandler(Filters.regex('^(/register_[\d]+)$'), register))
updater.dispatcher.add_handler(MessageHandler(Filters.regex('^(/unregister_[\d]+)$'), unregister))
# dispatcher.add_handler(CommandHandler("details", detailed_event, pass_args=True))
#Main Menu Callbacks
updater.dispatcher.add_handler(CommandHandler('menu', cmd_menu))
# updater.dispatcher.add_handler(CommandHandler('done', cmd_my_profile))
updater.dispatcher.add_handler(CallbackQueryHandler(main_menu, pattern='callback_main_menu'))
updater.dispatcher.add_handler(CallbackQueryHandler(my_profile, pattern='callback_my_profile'))
updater.dispatcher.add_handler(CallbackQueryHandler(more_menu, pattern='callback_more_menu'))
updater.dispatcher.add_handler(CallbackQueryHandler(activities, pattern='callback_activities'))
updater.dispatcher.add_handler(CallbackQueryHandler(events, pattern='callback_events'))
updater.dispatcher.add_handler(CallbackQueryHandler(schedule, pattern='callback_schedule'))
#More Menu Callbacks
updater.dispatcher.add_handler(CallbackQueryHandler(faq, pattern='callback_faq'))
updater.dispatcher.add_handler(CallbackQueryHandler(credits, pattern='callback_credits'))
updater.dispatcher.add_handler(CallbackQueryHandler(pdpa, pattern='callback_pdpa'))
updater.dispatcher.add_handler(CallbackQueryHandler(pdpa_disposable, pattern='callback_disposable'))
updater.dispatcher.add_handler(CallbackQueryHandler(delete_recent, pattern='callback_delete'))
#Polling
updater.start_polling()
#Activites conversation handler
#==============================================================================================#