botone

command module
v0.0.0-...-e7f1545 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2022 License: GPL-2.0 Imports: 19 Imported by: 0

README

Botone

Botone is a personal Telegram Bot API project, designed to keep a vague record of Telegram users so I don't forget them completely, since users tend to change their profiles a lot and have multiple alternative accounts.

The bot uses MongoDB to store the information as documents (NoSQL), and uses Telebot as a Telegram Bot API framework to design my bot.


Setup

The bot uses system environment variables for configuration.

The following variables needed are:

  • CONNECTION STRING: MongoDB's connection string to access databases and collections.
  • TOKEN: Telegram bot's token that's provided by The Bot Father when creating the bot.
  • OWNER: The Telegram ID of the owner of the bot. The owner has special privilages over the bot.
  • WEBHOOK: The webhook url.
  • PORT: The port to listen to, on webhook mode; Needed when setting up a webhook on Heroku.
  • LOGGING_TO_CHAT: A boolean value (true/false) to toggle the event-logging feature.
  • LOG_CHAT_ID: The ID of the channel for the bot to log to.

Alternatively, you can tell the program to read them from an .env file instead. To specify where to fetch that file, use the -config flag followed by the path to the file (file extention is not included), when executing the program.

Example:

.\botone.exe -config=C:\file

By default, the program runs on webhook mode, but you can set it to long-polling, using the -poll flag. When used, the program will keep running, until you enter any key into the console.

You can also use -poll-no-console, to use polling without the program terminating at recieving input from teminal, and will keep running until SIGTERM signal is emitted, just like in webhook mode.

And finally, you can set the program to run for a specific amount of time, using the -d flag followed by the number of seconds.


Debugging

You can use the flag -debug to allow more information to print into the terminal.


Usage

As the owner, you have the available commands:

  • /reg: register new users
  • /unreg: delete user entries
  • /recall: query users
  • /perm: view user permissions and modify them
  • /record: add notes to the user entries
  • /delrec: delete notes from user entries
  • /alias: add alias identifers to users
  • /set: set description to users
  • /changelog: view recent changes in the latest version
  • /help: see available commands, and view their documentaions
  • /credits: view credits

Use /help followed by the name of the command to learn how to use it.


The bot has a basic permission system, to decide who can use your bot, and to what extent.

Every command, button and inline query has a minimum permission level requirement that is compared to the user's, everytime he uses the bot. If the user's permission level uis lower than the action's, the bot simply ignores the request.

The four permission levels are:

  • [ 0 ] None
  • [ 1 ] Read-only
  • [ 2 ] Read/Write
  • [ 3 ] Operator
  • [ 4 ] Owner

'None' is basically no access to the bot whatsoever; it is the default level for newly registered users.

'Read-only' is pretty self explanatory - You can only perform read-only actions such as querying and reading permissions.

'Read/Write' allows the user to modify the database: add/remove users, modify their data, etc.. The only restriction a user with read/write permission has is that he can't change other people's permissions.

'Operator' is same as 'Read/Write' but the ability to modify permissions of other users, except for the owner. Operators cannot add more operators.

'Owner' permission is the highest permission level. Only one person can have this permission, and it can only be modified outside of the bot's runtime via the environment variable. Although it is recorded in the database, modifying the owner's permission level to lower levels won't change anything, since the owner ID is stored as environment variable.


Additional Notes

Although it's mentioned that the project uses Telebot as a dependency, it's actually this one which is just a clone, but with a tiny fix for the bot to function properly with webhooks without crashing at shutdown.


Changelog

  • /record now records recorder's ID rather than the chat's ID in which the record happenned.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL