TeamUltraUnion / rajniixrobot

An advanced modular telegram bot, running on python3 using the python-telegram-bot library and Telegram API.

Home Page:https://telegram.me/rajniixrobot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ʀᴀᴊɴɪ

An Advanced Modular Telegram Python Group Management bot running on python3.8.6. Build For Mainly Group Maintaining & Help Admins With Amazing Advanced Modules.

╔═━「 Status 」

  • Active
  • Maintained
  • Support Group Included
  • Free
  • OpenSourced
  • Working Instance Available
  • Clean Code
  • Heroku Deploy
  • Docker/Local Machine

╘═━「 Can be found on telegram as 𝔯𝔞𝔧𝔫𝔦𝔦 × 𝔯𝔬𝔟𝔬𝔱

╔═━「 Creator Info/Credits 」

The bot is based of on the original work done by PaulSonOfLars This repo was just reamped to suit an Anime-centric community. All original credits go to Paul and his dedication, Without his efforts, this fork would not have been possible!

╘═━「 Any other authorship/credits can be seen through the commits. 」

How to deploy code.

Deploy using Heroku Website

To deploy directly on Heroku.

Step 1 - Read sample_config.py in RajniiRobot folder.

Step 2 - Get all required values by given urls and hit Deploy to Heroku button, Heroku website will open.

Step 3 - Enter all required values and can fill other values as well if you have, in input feilds and hit Deploy button.

Step 4 - Wait for deployment to finish, after that click Manage App button just below the logs area.

Step 5 - Go to resources tab and turn off web dyno. turn on worker dyno, wait for sometime, bot will notify in support chat.

Deploy

Go to https://dashboard.heroku.com/apps/(app-name)/resources (Replace (app-name) with your app name.) Now send the bot /start, If it doesn't respond go to https://dashboard.heroku.com/apps/(app-name)/settings and remove webhook and port.

Deploy using Heroku CLI.

Install the requirement applications.

Install Heroku CLI

Install GIT

Install NodeJS

Initialising Accounts.

Create a Account on Heroku website (Click here to SignUp)

Open terminal

  • Download Repo by using git.
git clone https://github.com/TeamUltraUnion/rajniixrobot.git
  • Login in CLI by entering the following command.
heroku login

Hit Enter.

Click Login in webpage(browser will open login page automatically)

  • Navigate to Downloaded Reposiratory.
cd repository-path
  • Initialise Reposiratory as git reposiratory by following command.
git init
  • Make a Git Initial Commit in Repo by entering the following commands respectively.
git add .
git commit -m "Initial commit"
  • Create an app on heroku by this page or by following command (Should be Unique, can use hyphen/numbers).
heroku create rajniixrobot-v5

Set Git remote to your Heroku app (if you have created heroku app by heroku website, you need to initialise it like this).

heroku git:remote -a rajniixrobot-v5
  • Push changes to your heroku app by following command.
git push heroku master
Steps to deploy on local machine or virtual private server (vps).

Setting up the bot (Read this before trying to use!):

Please make sure to use python 3.6, as I cannot guarantee everything will work as expected on older Python versions! This is because markdown parsing is done by iterating through a dict, which is ordered by default in 3.6.

Configuration

There are two possible ways of configuring your bot: a config.py file, or ENV variables.

The preferred version is to use a config.py file, as it makes it easier to see all your settings grouped together. This file should be placed in your RajniiRobot folder, alongside the __main__.py file. This is where your bot token will be loaded from, as well as your database URI (if you're using a database), and most of your other settings.

It is recommended to import sample_config and extend the Config class, as this will ensure your config contains all defaults set in the sample_config, hence making it easier to upgrade.

An example config1.py file could be:

from RajniiRobot.sample_config import Config

class Development(Config):
    OWNER_ID = 254318997  # your telegram ID
    OWNER_USERNAME = "SonOfLars"  # your telegram username
    API_KEY = "your bot api key"  # your api key, as provided by the @botfather
    SQLALCHEMY_DATABASE_URI = 'postgresql://username:password@localhost:5432/database'  # sample db credentials
    JOIN_LOGGER = '-1234567890' # some group chat that your bot is a member of
    USE_JOIN_LOGGER = True
    DRAGONS = [18673980, 83489514]  # List of id's for users which have sudo access to the bot.
    LOAD = []
    NO_LOAD = ['translation']

If you can't have a config.py file (EG on Heroku), it is also possible to use environment variables. So just go and read the config sample file.

Python dependencies

Install the necessary Python dependencies by moving to the project directory and running:

pip3 install -r requirements.txt

This will install all the necessary python packages.

Database

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 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 need 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 you're using (eg Postgres, MySQL, SQLite, etc) repeat for your username, password, hostname (localhost?), port (5432?), and DB name.

Modules

Setting load order.

The module load order can be changed via the LOAD and NO_LOAD configuration settings. These should both represent lists.

If LOAD is an empty list, all modules in modules/ will be selected for loading by default.

If NO_LOAD is not present or is an empty list, all modules selected for loading will be loaded.

If a module is in both LOAD and NO_LOAD, the module will not be loaded - NO_LOAD takes priority.

Creating your own modules.

Creating a module has been simplified as much as possible - but do not hesitate to suggest further simplification.

All that is needed is that your .py file is in the modules folder.

To add commands, make sure to import the dispatcher via

from RajniiRobot import dispatcher

You can then add commands using the usual

dispatcher.add_handler()

Assigning the __help__ variable to a string describing this modules' available commands will allow the bot to load it and add the documentation for your module to the /help command. Setting the __mod_name__ variable will also allow you to use a nicer, user-friendly name for a module.

The __migrate__() function is used for migrating chats - when a chat is upgraded to a supergroup, the ID changes, so it is necessary to migrate it in the DB.

The __stats__() function is for retrieving module statistics, eg number of users, number of chats. This is accessed through the /stats command, which is only available to the bot owner.

Starting the bot.

Once you've set up your database and your configuration is complete, simply run the bat file(if on windows) or run (Linux):

python3 -m RajniiRobot

You can use nssm to install the bot as service on windows and set it to restart on /gitpull Make sure to edit the start and restart bats to your needs. Note: the restart bat requires that User account control be disabled.

For queries or any issues regarding the bot please open an issue ticket or visit us at Rajnii × Support.

Made with 💕 by @TeamUltraUnion.

About

An advanced modular telegram bot, running on python3 using the python-telegram-bot library and Telegram API.

https://telegram.me/rajniixrobot

License:BSD 2-Clause "Simplified" License


Languages

Language:Python 99.8%Language:Batchfile 0.2%Language:Dockerfile 0.0%Language:Shell 0.0%Language:Procfile 0.0%