-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
59 lines (47 loc) · 2 KB
/
main.py
File metadata and controls
59 lines (47 loc) · 2 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from telegram.ext import CommandHandler, Updater
from telegram import Bot, Update
from credentials import bot_token
TOKEN = bot_token
bot = Bot(TOKEN)
# This is the initial message upon the User clicking on 'Start'
def start(update: Update, context):
greeting = 'Hi, I am NUSCopilot! How can I help?'
bot.send_message(chat_id=update.message.chat_id, text=greeting)
# This is the tentative list of commands for the Bot
def help(update: Update, context):
avail_commands = [
'/help --> Your help a tap away ~',
'/makan --> Grab a snack from SuperSnacks?',
'/spaces --> Book your facilities?',
'/feedback --> Want to provide suggestions for improvements?'
]
help_text = '\n'.join(avail_commands)
bot.send_message(chat_id=update.message.chat_id, text=f'Available commands:\n\n{help_text}')
def makan(update: Update, context):
bot.send_message(chat_id=update.message.chat_id, text='Implementation in progress')
def spaces(update: Update, context):
bot.send_message(chat_id=update.message.chat_id, text='Implementation in progress')
def feedback(update: Update, context):
bot.send_message(chat_id=update.message.chat_id, text='Implementation in progress')
def main():
updater = Updater(TOKEN)
# What actions to be triggered when the dispatcher receives update from the updater
dispatcher = updater.dispatcher
dispatcher.add_handler(CommandHandler("start", start))
dispatcher.add_handler(CommandHandler("help", help))
dispatcher.add_handler(CommandHandler("makan", makan))
dispatcher.add_handler(CommandHandler("spaces", spaces))
dispatcher.add_handler(CommandHandler("feedback", feedback))
updater.start_polling()
if __name__ == '__main__':
import logging
logging.basicConfig(
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
datefmt='%I:%M:%S %p',
level=logging.INFO,
)
logger = logging.getLogger(__name__)
try:
main()
except Exception as e:
logger.error(e)