Skip to content

Commit

Permalink
Updated Readme :D & Improve Adminlist!
Browse files Browse the repository at this point in the history
Signed-off-by: Yasir-siddiqui <[email protected]>
  • Loading branch information
Yasir-siddiqui authored and MD Raza committed Jul 17, 2020
1 parent 35fb2f3 commit d056644
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 15 deletions.
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ A modular telegram Python bot running on python3 with an sqlalchemy database.
Originally a simple group management bot with multiple admin features, it has evolved, becoming extremely modular and
simple to use.

Can be found on telegram as [Marie](https://t.me/BanhammerMarie_bot).
Can be found on telegram as [Joker](https://t.me/Joker_dabot).

Marie and I are moderating a [support group](https://t.me/MarieSupport), where you can ask for help setting up your
bot, discover/request new features, report bugs, and stay in the loop whenever a new update is available. Of course
I'll also help when a database schema changes, and some table column needs to be modified/added. Note to maintainers that all schema changes will be found in the commit messages, and its their responsibility to read any new commits.

Join the [news channel](https://t.me/MarieNews) if you just want to stay in the loop about new features or
Join the [news channel](https://t.me/JokerHarleynews) if you just want to stay in the loop about new features or
announcements.

Alternatively, [find me on telegram](https://t.me/SonOfLars)! (Keep all support questions in the support chat, where more people can help you.)
Alternatively, [find me on telegram](https://t.me/YasirSiddiqui)!.

## Starting the bot.

Once you've setup your database and your configuration (see below) is complete, simply run:

`python3 -m tg_bot`
`python3 -m tg_bot` or `python -m tg_bot`


## Setting up the bot (Read this before trying to use!):
Expand All @@ -44,15 +41,17 @@ from tg_bot.sample_config import Config
class Development(Config):
OWNER_ID = 254318997 # my telegram ID
OWNER_USERNAME = "SonOfLars" # my telegram username
OWNER_ID = 427770754 # my telegram ID
OWNER_USERNAME = "Yasirsiddiqui" # 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
MESSAGE_DUMP = '-1234567890' # some group chat that your bot is a member of
USE_MESSAGE_DUMP = True
SUDO_USERS = [18673980, 83489514] # List of id's for users which have sudo access to the bot.
STRICT_GMUTE = True
STRICT_GBAN = True
SUDO_USERS = [427770754, 12345678] # List of id's for users which have sudo access to the bot.
LOAD = []
NO_LOAD = ['translation']
NO_LOAD = ['translation, memes]
```

If you can't have a config.py file (EG on heroku), it is also possible to use environment variables.
Expand Down Expand Up @@ -80,6 +79,7 @@ The following env variables are supported:
- `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.
- `STRICT_GMUTE`: Enforce gmute across new groups as well as old groups. When a gmuted user talks, he will be muted.
- `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.
Expand Down
19 changes: 15 additions & 4 deletions tg_bot/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,25 @@ def adminlist(bot: Bot, update: Update):
text = "Admins in *{}*:".format(update.effective_chat.title or "this chat")
for admin in administrators:
user = admin.user
name = "[{}](tg://user?id={})".format(user.first_name + (user.last_name or ""), user.id)
status = admin.status
name = "[{}](tg://user?id={})".format(user.first_name + " " + (user.last_name or ""), user.id)
if user.username:
name = "[{}](tg://user?id={})".format(user.first_name + (user.last_name or ""), user.id)
text += "\n - {}".format(name)
if status == "creator":
text += "\n 🔱 Creator:"
text += "\n` • `{} \n\n 🔰 Admin:".format(name)
for admin in administrators:
user = admin.user
status = admin.status
name = "[{}](tg://user?id={})".format(user.first_name + " " + (user.last_name or ""), user.id)
if user.username:
name = "[{}](tg://user?id={})".format(user.first_name + (user.last_name or ""), user.id)
if status == "administrator":
text += "\n` • `{}".format(name)

update.effective_message.reply_text(text, parse_mode=ParseMode.MARKDOWN)


def __chat_settings__(chat_id, user_id):
return "You are *admin*: `{}`".format(
dispatcher.bot.get_chat_member(chat_id, user_id).status in ("administrator", "creator"))
Expand Down

0 comments on commit d056644

Please sign in to comment.