参考链接:
- 调用api文档示例 https://docs.python-telegram-bot.org/en/stable/examples.arbitrarycallbackdatabot.html
- bot开发相关 https://medium.com/@ton_xfans/tg-mini-app-dev-3aff329bf05a brickspert/blog#65
目前先试试不做webApp吧,直接去botFather创建一个bot。重命名.env.example为.env 然后填再.env文件就可以自己开发了
- Make sure poetry is installed on your system.
将依赖安装在目录下,这样vscode就能检测到了 poetry config virtualenvs.in-project true
poetry install
- Run:
poetry run python -m src.main --dev
or execute themain
function directly in your debugger which will default todev
mode. (make sure the environment is activated by runningpoetry shell
first)
Production mode runs alembic migrations against your database before starting the bot, make sure the following environment variables are set:
BOT_TOKEN
you can get one from BotfatherDB_PATH
the path to your database, relative from where the bot is executing. (I recommend choosing/data/yourdb.sqlite3
, as a/data
directory is automatically created in the Docker container and can be mounted to a persistent volume)FIRST_ADMIN
yourtelegram_id
, this can be set to give you automatically theADMIN
role when you register in your own bot
The following are optional:
LOGGING_CHANNEL
a telegramchat_id
that theErrorForwarder
can use to send JSON logs to. Very useful, usually set to a shared channel or your own id.
Finally:
- Execute
./entrypoint.sh