DATA BASE
: Sqlalchemy DatabaseDATA LIMIT
: 10000
My New Updates In This Channel
Our Beta Filter Bot.
Alternatively, find me on telegram! (Keep all support questions in the support chat, where more people can help you.)
from bot.sample_config import Config
class Development(Config):
OWNER_ID = 1118936839 # my telegram ID
OWNER_USERNAME = "Sur_vivor" # my telegram username
API_KEY = "your bot api key" # my api key, as provided by the botfather
SQLALCHEMY_DATABASE_URI = 'postgresql://username:password@localhost:5432/database' # sample db credentials
USE_MESSAGE_DUMP = True
SUDO_USERS = [] # List of id's for users which have sudo access to the bot.
If you can't have a config.py file (EG on heroku), it is also possible to use environment variables. The following env variables are supported:
-
ENV
: Setting this to ANYTHING will enable env variables -
TOKEN
: Your bot token, as a string. -
OWNER_ID
: An integer of consisting of your owner ID -
OWNER_USERNAME
: Your username -
DATABASE_URL
: Your database URL -
MESSAGE_DUMP
: optional: a chat where your replied saved messages are stored, to stop people deleting their old -
WEBHOOK
: Setting this to ANYTHING will enable webhooks when in env mode messages -
URL
: The URL your webhook should connect to (only needed for webhook mode) -
SUDO_USERS
: A space separated list of user_ids which should be considered sudo users -
SUPPORT_USERS
: A space separated list of user_ids which should be considered support users (can gban/ungban, nothing else) -
WHITELIST_USERS
: A space separated list of user_ids which should be considered whitelisted - they can't be banned. -
DONATION_LINK
: Optional: link where you would like to receive donations. -
PORT
: Port to use for your webhooks -
DEL_CMDS
: Whether to delete commands from users which don't have rights to use that command -
WORKERS
: Number of threads to use. 8 is the recommended (and default) amount, but your experience may vary. Note that going crazy with more threads wont necessarily speed up your bot, given the large amount of sql data accesses, and the way python asynchronous calls work. -
ALLOW_EXCL
: Whether to allow using exclamation marks ! for commands as well as /.
Install the necessary python dependencies by moving to the project directory and running:
pip3 install -r requirements.txt
.
This will install all necessary python packages.
If you wish to use a database-dependent module (eg: locks, notes, userinfo, users, filters, welcomes), you'll need to have a database installed on your system. I use postgres, so I recommend using it for optimal compatibility.
In the case of postgres, this is how you would set up a the database on a debian/ubuntu system. Other distributions may vary.
- install postgresql:
sudo apt-get update && sudo apt-get install postgresql
- change to the postgres user:
sudo su - postgres
- create a new database user (change YOUR_USER appropriately):
createuser -P -s -e YOUR_USER
This will be followed by you needing to input your password.
- create a new database table:
createdb -O YOUR_USER YOUR_DB_NAME
Change YOUR_USER and YOUR_DB_NAME appropriately.
- finally:
psql YOUR_DB_NAME -h YOUR_HOST YOUR_USER
This will allow you to connect to your database via your terminal. By default, YOUR_HOST should be 0.0.0.0:5432.
You should now be able to build your database URI. This will be:
sqldbtype://username:pw@hostname:port/db_name
Replace sqldbtype with whichever db youre using (eg postgres, mysql, sqllite, etc) repeat for your username, password, hostname (localhost?), port (5432?), and db name.