Skip to content

Configuration

Googleplex edited this page Apr 22, 2021 · 8 revisions

To configure options, you have the following ways:

  1. Directly set envrionment variables
  2. Use .env.example as a template, modify the values and rename it to .env

ENV

Optional

The default option (production) uses Webhook mode, you can set to development to use polling mode.

TOKEN

Required

API token of your bot, can be obtained from @BotFather.

WEBHOOK_URL

Required if using webhook mode

Webhook URL to be set for Telegram server, must end with /. e.g.: https://xxx.herokuapp.com/

PORT

Required if using webhook mode

Webhook port, automatically set if on Heroku.

STORAGE_DIR

Optional

Storage directory, can be local or remote, will be created if not exists.

Default: Pictures

GALLERY_ID

Notice: You need to add your bot to channel administrators

Required

Telegram channel ID used for storing messages, messages sent to bot and containing URL entities will be forwarded here for reviewing.

ADMIN_ID

Required

Telegram user ID(not username) of the admin, some bot functions are restricted to admin user.

eg:

export ADMIN_ID=111111

IS_PUBLIC

Optional

Whether to make this bot public, can be true or false.

Default: false

Added in v2

ALLOW_ID

Optional

Telegram user ID of the allowed users other than admin, separated by a comma, ignored if IS_PUBLIC=true.

e.g.:

export ALLOW_ID=12345
export ALLOW_USERNAME=12345,23456,34567

Changed in v2

Tips:

You can get your User ID & Channel ID via @GetIDs Bot

ALLOW_USERNAME

Optional

Telegram username of the allowed users other than admin, without @ prefix, separated by a comma, ignored if IS_PUBLIC=true.

e.g.:

export ALLOW_USERNAME=user1
export ALLOW_USERNAME=user1,user2,user3

Changed in v2

ALLOW_GROUP

Optional

Telegram group ID, separated by a comma. Users in this group will be able to use the bot in group chat.

e.g.:

export ALLOW_GROUP=-12345,-23456

Changed in v2

About access control:

  1. Allow all if IS_PUBLIC=true
  2. User in ALLOW_ID or ALLOW_USERNAME or ADMIN_ID can access the bot via private chat
  3. User in ALLOW_GROUP can access via specified group chat

For more information, see nazurin/middleware.py.

CAPTION_IGNORE

Optional

Caption items to ignore when generating image captions, separated by a comma.

e.g.:

export CAPTION_IGNORE=bookmarked

Default is none.

Added in v2

RETRIES

Retry attempts after a failed requests.

e.g.:

export RETRIES=5

Default is 5.

Added in v2

DATABASE

**Notice: Don't use local database on Heroku, or the data cannot be persisted"

Optional

Type of database.

Supported databases:

Driver Usage Config Note
TinyDB https://github.com/y-young/nazurin/wiki/TinyDB Local Default
Firestore https://github.com/y-young/nazurin/wiki/Firestore Firebase
MongoDB https://github.com/y-young/nazurin/wiki/MongoDB Mongo MongoDB Atlas supported
Cloudant https://github.com/y-young/nazurin/wiki/Cloudant Cloudant

You can also implement your own database driver by creating a file under database folder, and set this option to the name of driver class.

STORAGE

**Notice: Don't use local storage on Heroku, or the data cannot be persisted"

Optional

A string list of storage names, separated by commas.

e.g.:

export STORAGE=Local,Telegram,Mega

Default: Local

Supported storage:

Name Usage Config Note
Local Append Local to STORAGE Local Default
Telegram https://github.com/y-young/nazurin/wiki/Telegram Telegram Added in v2
MEGA https://github.com/y-young/nazurin/wiki/MEGA Mega
Google Drive https://github.com/y-young/nazurin/wiki/Google-Drive GoogleDrive
OneDrive https://github.com/y-young/nazurin/wiki/OneDrive OneDrive

Implement other storage by creating a file under storage with a store function.

Changed in v2