All Projects → dihanofficial → SophiaBot

dihanofficial / SophiaBot

Licence: GPL-3.0 license
Hi There ✋ I'M Sophia 3.0 ❤️ NEW VERSION OF SOPHIA.. Source Code of @SophiaSLBot.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to SophiaBot

PyroGramBot
pluggable Telegram Bot based on Pyrogram
Stars: ✭ 168 (+281.82%)
Mutual labels:  group, powerful, pyrogram
Fire-X
Powerful Telegram Maintained UserBot in Telethon
Stars: ✭ 22 (-50%)
Mutual labels:  telethon, pyrogram
MissElizabethRobot
MashaRoBot : 📑Editor's choice
Stars: ✭ 43 (-2.27%)
Mutual labels:  telethon, pyrogram
Sophie
New repo - https://gitlab.com/SophieBot/sophie
Stars: ✭ 28 (-36.36%)
Mutual labels:  telegram-bots, telethon
MashaRoBot
MashaRoBot : 📑Editor's choice
Stars: ✭ 39 (-11.36%)
Mutual labels:  telethon, pyrogram
SpamBot
First Spam Bot repo ever made for telegram bots. Powerful spambot for telegram made with python and telethon.
Stars: ✭ 67 (+52.27%)
Mutual labels:  telethon, pyrogram
Telegram-mailer
Web-application for sending messages to list of users. Use several accounts to avoid ban.
Stars: ✭ 28 (-36.36%)
Mutual labels:  telegram-bots, telethon
QuickNotes
一款简单、轻量、高效的Android记事、记账应用
Stars: ✭ 19 (-56.82%)
Mutual labels:  simple, powerful
DevelopersUserbot
Telegram Userbot Made for Developers by Developers
Stars: ✭ 25 (-43.18%)
Mutual labels:  telethon, pyrogram
StringSessionBot
Pyrogram and Telethon String Session Generator
Stars: ✭ 63 (+43.18%)
Mutual labels:  telethon, pyrogram
tgcalls
Voice chats, private incoming and outgoing calls in Telegram for Developers
Stars: ✭ 408 (+827.27%)
Mutual labels:  telethon, pyrogram
Txt2SpeechBot
The only Text to Speech Telegram Inline Bot
Stars: ✭ 26 (-40.91%)
Mutual labels:  telegram-bots
simple-style
My simple style hugo theme, based on <https://yanlinlin82.github.io/webpage-templates/simple-style/index.html>
Stars: ✭ 25 (-43.18%)
Mutual labels:  simple
EsseX
A telegram bot to fetch anime, character and manga info.
Stars: ✭ 40 (-9.09%)
Mutual labels:  pyrogram
lwpkt
Lightweight packet protocol structure for multi-device communication focused on RS-485
Stars: ✭ 71 (+61.36%)
Mutual labels:  simple
telresender
A Telegram bot, which resend your message to another account
Stars: ✭ 22 (-50%)
Mutual labels:  telegram-bots
Userge-Assistant
assistant-bot for manage userge OT group
Stars: ✭ 34 (-22.73%)
Mutual labels:  pyrogram
Recon
HA LDAP based key/value solution for projects configuration storing with multi master replication support
Stars: ✭ 12 (-72.73%)
Mutual labels:  simple
SophiApp
⚡ The most powerful open source tweaker on GitHub for fine-tuning Windows 10 & Windows 11
Stars: ✭ 1,859 (+4125%)
Mutual labels:  sophia
AbilityBots
The AbilityBots abstraction and API for building expressive Java Telegram Bots
Stars: ✭ 12 (-72.73%)
Mutual labels:  telegram-bots

Sophia v3

A Powerful, Smart And Simple Group Manager
... Written with Pyrogram and Telethon...

Stars

Codacy

⭐️ Thanks to everyone who starred Sophia, That is the greatest pleasure we have !

Avaiilable on Telegram as @SophiaSLBot

Video Tutorial:

Complete guide on deploying @SophiaSLBot's clone on Heroku.

🙋‍♂️ Video by Dihan RandilaYouTube

Deploy To Heroku

Deploy

Join my Updates Channel & Support Chats

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 SophiaBot 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 config.py file could be:

from SophiaBot.sample_config import Config

class Development(Config):
    OWNER_ID = 12345  # your telegram ID
    OWNER_USERNAME = "dihanrandila"  # 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
    MESSAGE_DUMP = '-1234567890' # some group chat that your bot is a member of
    USE_MESSAGE_DUMP = True
    SUDO_USERS = [12345678]  # 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. 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

  • LOAD: Space-separated list of modules you would like to load

  • NO_LOAD: Space-separated list of modules you would like NOT to load

  • 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.

  • CERT_PATH: Path to your webhook certificate

  • PORT: Port to use for your webhooks

  • DEL_CMDS: Whether to delete commands from users which don't have rights to use that command

  • STRICT_GBAN: Enforce gbans across new groups as well as old groups. When a gbanned user talks, he will be banned.

  • 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.

  • BAN_STICKER: Which sticker to use when banning people.

  • ALLOW_EXCL: Whether to allow using exclamation marks ! for commands as well as /.

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 SophiaBot 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 SophiaBot

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 Support

How to setup on Heroku

For starters click on this button

Contributors

Special Credits

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].