From 3ca0f2c82f33e6f31c570a5e3210e6d9db846b91 Mon Sep 17 00:00:00 2001 From: Ian Andwati Date: Sun, 8 May 2022 00:33:13 +0300 Subject: [PATCH] added message handler for start command --- src/__init__.py | 0 src/bot.py | 22 ++++++++++++++++++++++ src/server.py | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) delete mode 100644 src/__init__.py diff --git a/src/__init__.py b/src/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/bot.py b/src/bot.py index e69de29..39ac982 100644 --- a/src/bot.py +++ b/src/bot.py @@ -0,0 +1,22 @@ +from os import environ + +import requests +import telebot + +bot = telebot.TeleBot(environ["TELEGRAM_TOKEN"]) + + +@bot.message_handler(commands=["start"]) +def send_welcome(message): + """ + handle triggered by the /start command + """ + bot.reply_to(message, "hi there") + + +# configure the webhook for the bot +bot.set_webhook( + "https://{}.herokuapp.com/{}".format( + environ["PROJECT_NAME"], environ["TELEGRAM_TOKEN"] + ) +) diff --git a/src/server.py b/src/server.py index 845ca47..1f95043 100644 --- a/src/server.py +++ b/src/server.py @@ -1,7 +1,7 @@ import flask import telebot -from bot import bot +from .bot import bot app = flask.Flask(__name__)