-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
39 lines (24 loc) · 956 Bytes
/
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
import constants as keys
from telegram.ext import *
import Responses as R
print("Bot started...")
def start_command(update, context):
update.message.reply_text('Type something random to ger started!')
def help_command(update, context):
update.message.reply_text('If you need help! You should ask for it on Google!')
def handle_message(update, context):
text = str(update.message.text).lower()
response = R.sample_responses(text)
update.message.reply_text(response)
def error(update, context):
print(f"Update {update} caused error {context.error}")
def main():
updater = Updater(keys.API_KEY, use_context=True)
dp = updater.dispatcher
dp.add_handler(CommandHandler("start", start_command))
dp.add_handler(CommandHandler("help", help_command))
dp.add_handler(MessageHandler(Filters.text, handle_message))
dp.add_error_handler(error)
updater.start_polling()
updater.idle()
main()