-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.py
67 lines (50 loc) · 2.11 KB
/
utils.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
# Creation Date: 2022.06.27
# Copyright Ratiu Sebastian, All rights reserved 2022
import telegram.ext
from telegram.ext import CallbackQueryHandler
from telegram.ext.filters import Filters
import food
import menu
import trivia_funcs
from keep_alive import keep_alive
##################### whitelist #######################
whitelist = ["@SPAWN_LKD", "@Starstroke", "@sandorsinofobu", "@SergiuWat"]
#######################################################
def read_token(token_file):
with open(token_file, 'r') as f:
return f.read()
def start_bot():
TOKEN = read_token("token.txt")
updater = telegram.ext.Updater(TOKEN, use_context=True)
disp = updater.dispatcher
disp.add_handler(
telegram.ext.CommandHandler("start", start,
Filters.user(username=whitelist)))
disp.add_handler(CallbackQueryHandler(button))
disp.add_handler(
telegram.ext.CommandHandler("help", help,
Filters.user(username=whitelist)))
keep_alive()
updater.start_polling()
updater.idle()
def start(update, context):
update.message.reply_text(
"""Aloha! Welcome to The Crib! Here we can do all sorts of things, but for now, let me just say..Hi, I'm Jeff 🤖 and I'll be the one that helps you from now on. Just type /help and we'll get things going. Cheerio!"""
)
def button(update, context) -> None:
"""Parses the CallbackQuery and updates the message text."""
query = update.callback_query
query.answer()
if query.data == 'word':
trivia_funcs.word_of_the_day(update, context)
elif query.data == 'fact':
trivia_funcs.fun_fact(update, context)
elif query.data == 'dishes':
food.daily_dishes(update, context)
def help(update, context):
update.message.reply_text("""
Hello there, the following commands are available:
/start -> starting welcome message, brought by me, Your friendly Telegram-hood Jeff
/help -> this wonderful helping message
""")
menu.menu(update, context)