Style fix to README and docs

This commit is contained in:
nocturn9x 2020-06-05 19:26:37 +00:00
parent 0acc9c51f8
commit 3addea5ecc
3 changed files with 52 additions and 52 deletions

View File

@ -24,22 +24,22 @@ is locked` error when accessing the database.
All queries are performed within a `with` block and therefore rollbacked
automatically if an error occurs or committed if the transaction was successful.
- `get_user()` -> Given a Telegram ID as input, returns a tuple containing
the unique id of the user in the database, its telegram id, username,
the date and time the user was inserted in the database as a string
(formatted as d/m/Y H:M:S) and an integer (0 for `False` and 1 for `True`)
that represents the user's status (whether it is banned or not)
- `get_user()` -> Given a Telegram ID as input, returns a tuple containing
the unique id of the user in the database, its telegram id, username,
the date and time the user was inserted in the database as a string
(formatted as d/m/Y H:M:S) and an integer (0 for `False` and 1 for `True`)
that represents the user's status (whether it is banned or not)
- `get_users()` -> This acts similarly to the above `get_user`, but takes
no parameters and returns a list of all the users in the database. The
list contains tuples of the same structure of the ones returned by `get_user`
- `get_users()` -> This acts similarly to the above `get_user`, but takes
no parameters and returns a list of all the users in the database. The
list contains tuples of the same structure of the ones returned by `get_user`
- `set_user()` -> Saves an ID/username pair (in this order)
to the database. The username parameter can be `None`
- `set_user()` -> Saves an ID/username pair (in this order)
to the database. The username parameter can be `None`
- `ban_user()` -> Bans the user with the given user ID (Coming soon)
- `ban_user()` -> Bans the user with the given user ID (Coming soon)
- `unban_user()` -> Unbans a user with the given ID (Coming soon)
- `unban_user()` -> Unbans a user with the given ID (Coming soon)
# I need MySQL/other DBMS!

View File

@ -21,11 +21,11 @@ the corresponding pyrogram method returns.
List of the available functions in `BotBase.methods.safe_send`
- `send_message`
- `send_photo`
- `send_audio`
- `send_animation`
- `send_sticker`
- `send_message`
- `send_photo`
- `send_audio`
- `send_animation`
- `send_sticker`
These are the exact names that pyrogram uses, to see their docs refer to
[pyrogram docs](https://docs.pyrogram.org/api/methods/)
@ -34,14 +34,14 @@ These are the exact names that pyrogram uses, to see their docs refer to
List of the available functions in `BotBase.methods.safe_edit`
- `edit_message_text`
- `edit_message_media`
- `edit_message_caption`
- `edit_message_text`
- `edit_message_media`
- `edit_message_caption`
## Methods - Various
List of the available functions in `BotBase.methods.various`
- `answer` (for `CallbackQuery` objects)
- `delete_messages`
- `answer` (for `CallbackQuery` objects)
- `delete_messages`

View File

@ -12,10 +12,10 @@ Also, you need to know how to host a bot yourself. I mean, I coded all of this f
To setup a project using BotBase, follow this step-by-step guide (assuming `pip` and `git` are already installed and up to date):
- Open a terminal and type `git clone https://github.com/nocturn9x/BotBase`
- `cd` into the newly created directory and run `python3 -m pip install -r requirements.txt`
- Once that is done, open the `BotBase/config.py` module with a text editor and start changing the default settings
- The first thing you might want to do is change the `API_ID`, `API_HASH` and `BOT_TOKEN` global variables. Check [this page](https://my.telegram.org/apps) and login with your telegram account to create an API_ID/API_HASH pair. For the bot token, just create one with [BotFather](https://telegram.me/BotFather)
- Open a terminal and type `git clone https://github.com/nocturn9x/BotBase`
- `cd` into the newly created directory and run `python3 -m pip install -r requirements.txt`
- Once that is done, open the `BotBase/config.py` module with a text editor and start changing the default settings
- The first thing you might want to do is change the `API_ID`, `API_HASH` and `BOT_TOKEN` global variables. Check [this page](https://my.telegram.org/apps) and login with your telegram account to create an API_ID/API_HASH pair. For the bot token, just create one with [BotFather](https://telegram.me/BotFather)
**Note**: The configuration file is still a python file, so when it will be imported any python code that you typed inside it will be executed, so be careful! If you need to perform pre-startup operations it is advised to do them in the `if __name__ == "main":` block inside `bot.py`, before `bot.start()`
@ -25,10 +25,10 @@ BotBase comes with lots of default plugins and tools to manage database interact
As of now, the following plugins are active:
- An advanced live chat accessible trough buttons
- A start module that simply replies to /start and adds the user to the database if not already present
- An highly customizable antiflood module that protects your both from callback and message flood
- An administration module with lots of pre-built features such as /global and /whisper
- An advanced live chat accessible trough buttons
- A start module that simply replies to /start and adds the user to the database if not already present
- An highly customizable antiflood module that protects your both from callback and message flood
- An administration module with lots of pre-built features such as /global and /whisper
### Plugins - Live Chat
@ -38,14 +38,14 @@ work properly. To customize this plugin, go the the appropriate section in `conf
This plugin works the following way:
- When a user presses the button to trigger the live chat, all admins get notified that user xyz is asking for support
- The notification will contain the user information such as ID and username, if available
- At the same time, the user will see a waiting queue. Available admins will be shown with a green sphere next to their name, while admins that are already chatting will be shown as busy
- The user can press the update button to update the admin's statuses
- When an administrator joins, all notifications from all admins are automatically deleted and the admin is marked as busy
- When an admin joins a chat, other admins won't be able to join
- Admins that are busy will not receive other support notifications
- An admin cannot join a chat if it's already busy
- When a user presses the button to trigger the live chat, all admins get notified that user xyz is asking for support
- The notification will contain the user information such as ID and username, if available
- At the same time, the user will see a waiting queue. Available admins will be shown with a green sphere next to their name, while admins that are already chatting will be shown as busy
- The user can press the update button to update the admin's statuses
- When an administrator joins, all notifications from all admins are automatically deleted and the admin is marked as busy
- When an admin joins a chat, other admins won't be able to join
- Admins that are busy will not receive other support notifications
- An admin cannot join a chat if it's already busy
Most of the working of the module is pre-defined, but you can customize the texts that the bot will use in the appropriate section of `config.py`
@ -56,20 +56,20 @@ This is the administrative module for the bot, and it also has its own section i
To configure this plugin, go to the appropriate section in `config.py` and change the default values in the `ADMINS` dictionary. Do **NOT** change the value of `ADMINS`, just update the dictionary as follows:
- Use the admin's ID as a key
- As a value you can set the name that will be displayed to users in the admin's queue
- Use the admin's ID as a key
- As a value you can set the name that will be displayed to users in the admin's queue
The available commands are:
- `/getuser ID`: Fetches user information by its Telegram ID
- `/getranduser`: Fetches a random user from the database
- `/ban ID`: Bans a user from using the bot, permanently (Coming soon)
- `/unban ID`: Unbans a user from using the bot (Coming soon)
- `/count`: Shows the current number of registered users
- `/global msg`: Broadcast whatever comes after `/global` to all users, supports HTML and markdown formatting
- `/whisper ID msg`: Send `msg` to a specific user given its ID. HTML and markdown formatting supported (Coming soon)
- `/update ID`: Updates the user's info in the database, if they've changed (Coming soon)
- `/getuser ID`: Fetches user information by its Telegram ID
- `/getranduser`: Fetches a random user from the database
- `/ban ID`: Bans a user from using the bot, permanently (Coming soon)
- `/unban ID`: Unbans a user from using the bot (Coming soon)
- `/count`: Shows the current number of registered users
- `/global msg`: Broadcast whatever comes after `/global` to all users, supports HTML and markdown formatting
- `/whisper ID msg`: Send `msg` to a specific user given its ID. HTML and markdown formatting supported (Coming soon)
- `/update ID`: Updates the user's info in the database, if they've changed (Coming soon)
### Plugins - Antiflood
@ -92,7 +92,7 @@ If you don't know what a smart plugin is, check [this link](https://docs.pyrogra
There are some things to keep in mind, though:
- If you want to protect your plugin from flood, import the `BotBase.modules.antiflood.BANNED_USERS` filter (basically a `Filters.user()` object) and use it like this: `~BANNED_USERS`. This will restrict banned users from reaching your handler at all
- To avoid repetition with try/except blocks, BotBase also implements some wrappers around `pyrogram.Client` and `pyrogram.CallbackQuery` (and many more soon) that perform automatic exception handling and log to the console automatically, check the `METHODS.md` file in this repo to know more
- Nothing restricts you from changing how the default plugins work, but this is not advised. The default plugins have been design to cooperate together and breaking this might lead to obscure tracebacks and errors that are hard to debug
- BotBase also has many default methods to handle database interaction, check the `DATABASE.md` file in this repo to know more
- If you want to protect your plugin from flood, import the `BotBase.modules.antiflood.BANNED_USERS` filter (basically a `Filters.user()` object) and use it like this: `~BANNED_USERS`. This will restrict banned users from reaching your handler at all
- To avoid repetition with try/except blocks, BotBase also implements some wrappers around `pyrogram.Client` and `pyrogram.CallbackQuery` (and many more soon) that perform automatic exception handling and log to the console automatically, check the `METHODS.md` file in this repo to know more
- Nothing restricts you from changing how the default plugins work, but this is not advised. The default plugins have been design to cooperate together and breaking this might lead to obscure tracebacks and errors that are hard to debug
- BotBase also has many default methods to handle database interaction, check the `DATABASE.md` file in this repo to know more