Пишу бота служба поддержки
main.py
from telegram.ext import Updater
from handlers import setup_dispatcher
from settings import TELEGRAM_TOKEN, HEROKU_APP_NAME, PORT
# Setup bot handlers
updater = Updater(TELEGRAM_TOKEN)
dp = updater.dispatcher
dp = setup_dispatcher(dp)
# Run bot
if HEROKU_APP_NAME is None: # pooling mode
print("Can't detect 'HEROKU_APP_NAME' env. Running bot in pooling mode.")
print("Note: this is not a great way to deploy the bot in Heroku.")
updater.start_polling()
updater.idle()
else: # webhook mode
print(f"Running bot in webhook mode. Make sure that this url is correct: https://{HEROKU_APP_NAME}.herokuapp.com/")
updater.start_webhook(
listen="0.0.0.0",
port=PORT,
url_path=TELEGRAM_TOKEN,
webhook_url=f"https://{HEROKU_APP_NAME}.herokuapp.com/{TELEGRAM_TOKEN}"
)
updater.idle()
settings.py
import os
from dotenv import load_dotenv, find_dotenv
# Loading .env variables
load_dotenv(find_dotenv())
TELEGRAM_TOKEN = os.getenv("TELEGRAM_TOKEN")
if TELEGRAM_TOKEN is None:
raise Exception("Please setup the .env variable TELEGRAM_TOKEN.")
PORT = int(os.environ.get('PORT', '8443'))
HEROKU_APP_NAME = os.getenv("HEROKU_APP_NAME")
TELEGRAM_SUPPORT_CHAT_ID = os.getenv("TELEGRAM_SUPPORT_CHAT_ID")
if TELEGRAM_SUPPORT_CHAT_ID is None or not str(TELEGRAM_SUPPORT_CHAT_ID).lstrip("-").isdigit():
raise Exception("You need to specify 'TELEGRAM_SUPPORT_CHAT_ID' env variable: The bot will forward all messages to this chat_id. Add this bot https://t.me/ShowJsonBot to your private chat to find its chat_id.")
TELEGRAM_SUPPORT_CHAT_ID = int(TELEGRAM_SUPPORT_CHAT_ID)
WELCOME_MESSAGE = os.getenv("WELCOME_MESSAGE", "")
REPLY_TO_THIS_MESSAGE = os.getenv("REPLY_TO_THIS_MESSAGE", "REPLY_TO_THIS")
WRONG_REPLY = os.getenv("WRONG_REPLY", "WRONG_REPLY")
.env
TELEGRAM_TOKEN= "5542048102:AAHuGG87CmiLsxiwPBk0g-QyytXBs1EPKo0"
TELEGRAM_SUPPORT_CHAT_ID= "https://t.me/chatsupports_bot"
# optional params
HEROKU_APP_NAME= # name of your Heroku app for webhook setup
WELCOME_MESSAGE= # text of a message that bot will write on /start command
# If user don't allow forward his messages Bot adds his comment with thue user_id to reply
# Support team must reply to "bot reply", not to original user forwarded message
# Customize message for support team here:
REPLY_TO_THIS_MESSAGE=User above don't allow forward his messages. Reply to this message.
# If support reply to forwarded messages with hidded sender, bor warns with next error:
WRONG_REPLY=User above don't allow forward his messages. You must reply to bot reply under
Ошибка в следующем
в settings.py
читал переводил не смог решить