mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Add guidance comments on obtaining bot tokens from environment variables
This commit is contained in:
parent
62f62de50a
commit
879b333a11
7 changed files with 26 additions and 4 deletions
|
|
@ -10,6 +10,8 @@ from aiogram.utils.markdown import hbold
|
|||
|
||||
# Bot token can be obtained via https://t.me/BotFather
|
||||
TOKEN = "42:TOKEN"
|
||||
# However, is recommended to get the token from environment variable:
|
||||
# TOKEN = getenv("BOT_TOKEN")
|
||||
|
||||
# All handlers should be attached to the Router (or Dispatcher)
|
||||
router = Router()
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_applicati
|
|||
|
||||
# Bot token can be obtained via https://t.me/BotFather
|
||||
TOKEN = "42:TOKEN"
|
||||
# However, is recommended to get the token from environment variable:
|
||||
# TOKEN = getenv("BOT_TOKEN")
|
||||
|
||||
|
||||
# Webserver settings
|
||||
# bind localhost only to prevent any external access
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_applicati
|
|||
|
||||
# Bot token can be obtained via https://t.me/BotFather
|
||||
TOKEN = "42:TOKEN"
|
||||
# However, is recommended to get the token from environment variable:
|
||||
# TOKEN = getenv("BOT_TOKEN")
|
||||
|
||||
|
||||
# Webserver settings
|
||||
# bind localhost only to prevent any external access
|
||||
|
|
|
|||
|
|
@ -16,6 +16,11 @@ from aiogram.types import (
|
|||
ReplyKeyboardRemove,
|
||||
)
|
||||
|
||||
TOKEN = "42:TOKEN"
|
||||
# However, is recommended to get the token from environment variable:
|
||||
# TOKEN = getenv("BOT_TOKEN")
|
||||
|
||||
|
||||
form_router = Router()
|
||||
|
||||
|
||||
|
|
@ -122,7 +127,7 @@ async def show_summary(message: Message, data: Dict[str, Any], positive: bool =
|
|||
|
||||
|
||||
async def main():
|
||||
bot = Bot(token=getenv("TELEGRAM_TOKEN"), parse_mode=ParseMode.HTML)
|
||||
bot = Bot(token=TOKEN, parse_mode=ParseMode.HTML)
|
||||
dp = Dispatcher()
|
||||
dp.include_router(form_router)
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,10 @@ from aiogram.webhook.aiohttp_server import (
|
|||
main_router = Router()
|
||||
|
||||
BASE_URL = getenv("BASE_URL", "https://example.com")
|
||||
MAIN_BOT_TOKEN = getenv("TELEGRAM_TOKEN")
|
||||
MAIN_BOT_TOKEN = "42:TOKEN"
|
||||
# However, is recommended to get the token from environment variable:
|
||||
# MAIN_BOT_TOKEN = getenv("BOT_TOKEN")
|
||||
|
||||
|
||||
WEB_SERVER_HOST = "127.0.0.1"
|
||||
WEB_SERVER_PORT = 8080
|
||||
|
|
|
|||
|
|
@ -15,6 +15,9 @@ from aiogram.types import (
|
|||
from aiogram.utils.markdown import hbold, hcode
|
||||
|
||||
TOKEN = "42:TOKEN"
|
||||
# However, is recommended to get the token from environment variable:
|
||||
# TOKEN = getenv("BOT_TOKEN")
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,10 @@ from aiogram import Bot, Dispatcher
|
|||
from aiogram.types import MenuButtonWebApp, WebAppInfo
|
||||
from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_application
|
||||
|
||||
TELEGRAM_TOKEN = getenv("TELEGRAM_TOKEN")
|
||||
TOKEN = "42:TOKEN"
|
||||
# However, is recommended to get the token from environment variable:
|
||||
# TOKEN = getenv("BOT_TOKEN")
|
||||
|
||||
APP_BASE_URL = getenv("APP_BASE_URL")
|
||||
|
||||
|
||||
|
|
@ -23,7 +26,7 @@ async def on_startup(bot: Bot, base_url: str):
|
|||
|
||||
|
||||
def main():
|
||||
bot = Bot(token=TELEGRAM_TOKEN, parse_mode="HTML")
|
||||
bot = Bot(token=TOKEN, parse_mode="HTML")
|
||||
dispatcher = Dispatcher()
|
||||
dispatcher["base_url"] = APP_BASE_URL
|
||||
dispatcher.startup.register(on_startup)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue