Skip to content
This repository has been archived by the owner on Mar 6, 2021. It is now read-only.

Commit

Permalink
Adding Handlers
Browse files Browse the repository at this point in the history
Command Handlers added.
  • Loading branch information
xditya authored Sep 6, 2020
2 parents f0b0c7f + df5df84 commit 21659d7
Show file tree
Hide file tree
Showing 175 changed files with 1,262 additions and 2,994 deletions.
29 changes: 17 additions & 12 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
"value": "",
"required": false
},
"CMD_HNDR": {
"description": "Used to invoke commands, leave blank for default, (dot)",
"value": "",
"required": false
},
"GIT_REPO_NAME": {
"description": "Your repo name Example: xditya/TeleBot, but GITHUB_ACCESS_TOKEN must be setup first.",
"value": "",
Expand All @@ -68,16 +73,16 @@
"value": "",
"required": true
},
"CHROME_BIN": {
"description": "Leave as such, Google Chrome (or) Chromium binary location for selenium based modules.",
"value": "/usr/bin/google-chrome",
"required": false
},
"CHROME_DRIVER": {
"description": "Leave as such, ChromeDriver location for selenium based modules",
"value": "/usr/bin/chromedriver",
"required": false
},
"CHROME_BIN": {
"description": "Leave as such, Google Chrome (or) Chromium binary location for selenium based modules.",
"value": "/usr/bin/google-chrome",
"required": false
},
"CHROME_DRIVER": {
"description": "Leave as such, ChromeDriver location for selenium based modules",
"value": "/usr/bin/chromedriver",
"required": false
},
"SUDO_USERS": {
"description": "Don't change the value here. (Makes your acc and bot stable)",
"value": "919057070",
Expand Down Expand Up @@ -133,12 +138,12 @@
"value": "",
"required": false
},
"OWNER_ID": {
"OWNER_ID": {
"description": "Your telegram userid, get it by sending /info to any bot, like Rose",
"value": "",
"required": false
},
"ALIVE_PIC": {
"ALIVE_PIC": {
"description": "telegra.ph link to theimage you want as alive pic, leave blank for sticker",
"value": "",
"required": false
Expand Down
1 change: 1 addition & 0 deletions heroku_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class Var(object):
G_DRIVE_CLIENT_SECRET = os.environ.get("G_DRIVE_CLIENT_SECRET", None)
GDRIVE_FOLDER_ID = os.environ.get("GDRIVE_FOLDER_ID", "root")
AUTH_TOKEN_DATA = os.environ.get("AUTH_TOKEN_DATA", None)
CMD_HNDLR = os.environ.get("CMD_HNDLR", ".")
if AUTH_TOKEN_DATA != None:
os.makedirs(TEMP_DOWNLOAD_DIRECTORY)
t_file = open(TEMP_DOWNLOAD_DIRECTORY+"auth_token.txt","w")
Expand Down
2 changes: 1 addition & 1 deletion userbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@

# Default .alive name
ALIVE_NAME = os.environ.get("ALIVE_NAME", None)

CMD_HNDLR = os.environ.get("CMD_HNDLR", ".")
LESS_SPAMMY = os.environ.get("LESS_SPAMMY", True)

# Time & Date - Country and Time Zone
Expand Down
5 changes: 3 additions & 2 deletions userbot/plugins/_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

from userbot import CMD_LIST
from userbot import ALIVE_NAME
from userbot.utils import admin_cmd

DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "No name set yet, check pinned in @TeleBotHelp"
DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "TeleBot User"

@command(pattern="^.help ?(.*)")
@telebot.on(admin_cmd(pattern="help ?(.*)"))
async def cmd_list(event):
if not event.text[0].isalpha() and event.text[0] not in ("/", "#", "@", "!"):
tgbotusername = Var.TG_BOT_USER_NAME_BF_HER
Expand Down
2 changes: 1 addition & 1 deletion userbot/plugins/about.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from userbot.utils import admin_cmd

@borg.on(admin_cmd("info"))
@telebot.on(admin_cmd(pattern="info"))
async def _(event):
if event.fwd_from:
return
Expand Down
6 changes: 3 additions & 3 deletions userbot/plugins/account_edits.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
UploadProfilePhotoRequest)
from telethon.tl.types import InputPhoto, MessageMediaPhoto, User, Chat, Channel

@borg.on(admin_cmd("pbio (.*)")) # pylint:disable=E0602
@borg.on(admin_cmd(pattern="pbio (.*)")) # pylint:disable=E0602
async def _(event):
if event.fwd_from:
return
Expand All @@ -32,7 +32,7 @@ async def _(event):
await event.edit(str(e))


@borg.on(admin_cmd("pname ((.|\n)*)")) # pylint:disable=E0602,W0703
@borg.on(admin_cmd(pattern="pname ((.|\n)*)")) # pylint:disable=E0602,W0703
async def _(event):
if event.fwd_from:
return
Expand All @@ -51,7 +51,7 @@ async def _(event):
await event.edit(str(e))


@borg.on(admin_cmd("ppic")) # pylint:disable=E0602
@borg.on(admin_cmd(pattern="ppic")) # pylint:disable=E0602
async def _(event):
if event.fwd_from:
return
Expand Down
4 changes: 0 additions & 4 deletions userbot/plugins/actressdp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
#Usage .actressdp Im Not Responsible For Any Ban caused By This

import requests , re , random

import urllib , os

from telethon.tl import functions

from userbot.utils import admin_cmd

import asyncio

COLLECTION_STRING = [
Expand Down
18 changes: 9 additions & 9 deletions userbot/plugins/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
# ================================================


@register(outgoing=True, pattern="^.setgpic$")
@telebot.on(admin_cmd(outgoing=True, pattern="setgpic"))
@errors_handler
async def set_group_photo(gpic):
""" For .setgpic command, changes the picture of a group """
Expand Down Expand Up @@ -106,7 +106,7 @@ async def set_group_photo(gpic):
await gpic.edit(PP_ERROR)


@register(outgoing=True, pattern="^.promote(?: |$)(.*)")
@telebot.on(admin_cmd(outgoing=True, pattern="promote(?: |$)(.*)"))
@errors_handler
async def promote(promt):
""" For .promote command, promotes the replied/tagged person """
Expand Down Expand Up @@ -157,7 +157,7 @@ async def promote(promt):
f"CHAT: {promt.chat.title}(`{promt.chat_id}`)")


@register(outgoing=True, pattern="^.demote(?: |$)(.*)")
@telebot.on(admin_cmd(outgoing=True, pattern="demote(?: |$)(.*)"))
@errors_handler
async def demote(dmod):
""" For .demote command, demotes the replied/tagged person """
Expand Down Expand Up @@ -378,7 +378,7 @@ async def promote(promt):
f"CHAT: {promt.chat.title}(`{promt.chat_id}`)")


@register(outgoing=True, pattern="^.gmute(?: |$)(.*)")
@telebot.on(admin_cmd(outgoing=True, pattern="gmute(?: |$)(.*)"))
@errors_handler
async def gspider(gspdr):
""" For .gmute command, globally mutes the replied/tagged person """
Expand Down Expand Up @@ -423,7 +423,7 @@ async def gspider(gspdr):
f"CHAT: {gspdr.chat.title}(`{gspdr.chat_id}`)")


@register(outgoing=True, pattern="^.delusers(?: |$)(.*)")
@telebot.on(admin_cmd(outgoing=True, pattern="delusers(?: |$)(.*)"))
@errors_handler
async def rm_deletedacc(show):
""" For .delusers command, list all the ghost/deleted accounts in a chat. """
Expand Down Expand Up @@ -495,7 +495,7 @@ async def rm_deletedacc(show):
\nCHAT: {show.chat.title}(`{show.chat_id}`)")


@register(outgoing=True, pattern="^.admins$")
@telebot.on(admin_cmd(outgoing=True, pattern="admins$"))
@errors_handler
async def get_admin(show):
""" For .admins command, list all of the admins of the chat. """
Expand All @@ -516,7 +516,7 @@ async def get_admin(show):
await show.edit(mentions, parse_mode="html")


@register(outgoing=True, pattern="^.pin(?: |$)(.*)")
@telebot.on(admin_cmd(outgoing=True, pattern="pin(?: |$)(.*)"))
@errors_handler
async def pin(msg):
""" For .pin command, pins the replied/tagged message on the top the chat. """
Expand Down Expand Up @@ -562,7 +562,7 @@ async def pin(msg):
f"LOUD: {not is_silent}")


@register(outgoing=True, pattern="^.kick(?: |$)(.*)")
@telebot.on(admin_cmd(outgoing=True, pattern="kick(?: |$)(.*)"))
@errors_handler
async def kick(usr):
""" For .kick command, kicks the replied/tagged person from the group. """
Expand Down Expand Up @@ -605,7 +605,7 @@ async def kick(usr):
f"CHAT: {usr.chat.title}(`{usr.chat_id}`)\n")


@register(outgoing=True, pattern="^.users ?(.*)")
@telebot.on(admin_cmd(outgoing=True, pattern="users ?(.*)"))
@errors_handler
async def get_users(show):
""" For .users command, list all of the users in a chat. """
Expand Down
4 changes: 2 additions & 2 deletions userbot/plugins/afk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from telethon import events
from telethon.tl import functions, types
from userbot import CUSTOM_AFK

from userbot.utils import admin_cmd

global USER_AFK # pylint:disable=E0602
global afk_time # pylint:disable=E0602
Expand All @@ -22,7 +22,7 @@
AFK_MSG = str(CUSTOM_AFK) if CUSTOM_AFK else "**Sorry**!! I'm AFK now."
AFKSTR = f"{AFK_MSG}"

@borg.on(events.NewMessage(pattern=r"\.afk ?(.*)", outgoing=True)) # pylint:disable=E0602
@borg.on(admin_cmd(pattern=r"afk ?(.*)", outgoing=True)) # pylint:disable=E0602
async def _(event):
if event.fwd_from:
return
Expand Down
2 changes: 1 addition & 1 deletion userbot/plugins/alive.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def get_readable_time(seconds: int) -> str:

DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "No name set yet, check pinned in @TeleBotHelp"

@command(outgoing=True, pattern="^.alive$")
@telebot.on(admin_cmd(outgoing=True, pattern="alive"))
async def amireallyalive(alive):
start = datetime.now()
""" For .alive command, check if the bot is running. """
Expand Down
11 changes: 6 additions & 5 deletions userbot/plugins/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

from userbot import CMD_HELP
from userbot.utils import register
from userbot.utils import admin_cmd

GITHUB = 'https://github.com'
DEVICES_DATA = 'https://raw.githubusercontent.com/androidtrackers/' \
'certified-android-devices/master/devices.json'


@register(outgoing=True, pattern="^.magisk$")
@telebot.on(admin_cmd(outgoing=True, pattern="magisk"))
async def magisk(request):
""" magisk latest releases """
magisk_dict = {
Expand All @@ -38,7 +39,7 @@ async def magisk(request):
f'[Uninstaller]({data["uninstaller"]["link"]})\n'
await request.edit(releases)

@register(outgoing=True, pattern=r"^.device(?: |$)(\S*)")
@telebot.on(admin_cmd(outgoing=True, pattern=r"device(?: |$)(\S*)"))
async def device_info(request):
""" get android device basic info from its codename """
textx = await request.get_reply_message()
Expand Down Expand Up @@ -69,7 +70,7 @@ async def device_info(request):
await request.edit(reply)


@register(outgoing=True, pattern=r"^.codename(?: |)([\S]*)(?: |)([\s\S]*)")
@telebot.on(admin_cmd(outgoing=True, pattern=r"codename(?: |)([\S]*)(?: |)([\s\S]*)"))
async def codename_info(request):
""" search for android codename """
textx = await request.get_reply_message()
Expand Down Expand Up @@ -104,7 +105,7 @@ async def codename_info(request):
await request.edit(reply)


@register(outgoing=True, pattern=r"^.specs(?: |)([\S]*)(?: |)([\s\S]*)")
@telebot.on(admin_cmd(outgoing=True, pattern=r"specs(?: |)([\S]*)(?: |)([\s\S]*)"))
async def devices_specifications(request):
""" Mobile devices specifications """
textx = await request.get_reply_message()
Expand Down Expand Up @@ -157,7 +158,7 @@ async def devices_specifications(request):
await request.edit(reply)


@register(outgoing=True, pattern=r"^.twrp(?: |$)(\S*)")
@telebot.on(admin_cmd(outgoing=True, pattern=r"twrp(?: |$)(\S*)"))
async def twrp(request):
""" get android device twrp """
textx = await request.get_reply_message()
Expand Down
8 changes: 1 addition & 7 deletions userbot/plugins/animedp.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
#Made By @TeleBotHelp Keep Credits If You Are Goanna Kang This Lol

#And Thanks To The Creator Of Autopic This Script Was Made from Snippets From That Script

#Usage .actressdp Im Not Responsible For Any Ban caused By This
#Usage .actressdp I'm Not Responsible For Any Ban caused By This

import requests , re , random

import urllib , os

from telethon.tl import functions

from userbot.utils import admin_cmd

import asyncio

COLLECTION_STRING = [
Expand Down
4 changes: 2 additions & 2 deletions userbot/plugins/animesticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from userbot import CMD_HELP
from userbot.events import register

from userbot.utils import admin_cmd


EMOJI_PATTERN = re.compile(
Expand All @@ -30,7 +30,7 @@ def deEmojify(inputString: str) -> str:
return re.sub(EMOJI_PATTERN, '', inputString)


@register(outgoing=True, pattern="^.waifu(?: |$)(.*)")
@telebot.on(admin_cmd(outgoing=True, pattern="waifu(?: |$)(.*)"))

async def waifu(animu):
#"""Creates random anime sticker!"""
Expand Down
2 changes: 1 addition & 1 deletion userbot/plugins/antivirus2.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from telethon.errors.rpcerrorlist import YouBlockedUserError
from userbot.utils import admin_cmd

@borg.on(admin_cmd("scan ?(.*)"))
@borg.on(admin_cmd(pattern="scan ?(.*)"))
async def _(event):
if event.fwd_from:
return
Expand Down
12 changes: 3 additions & 9 deletions userbot/plugins/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,12 @@
# Ported by @its_xditya for TeleBot

import requests

import bs4



from telethon import *

from userbot.events import register
from userbot.utils import admin_cmd



@register(pattern="^.app (.*)")
@telebot.on(admin_cmd(pattern="app (.*)"))

async def apk(e):

Expand Down Expand Up @@ -76,7 +70,7 @@ async def apk(e):



@register(pattern="^.appr (.*)")
@telebot.on(admin_cmd(pattern="appr (.*)"))

async def apkr(e):

Expand Down
2 changes: 1 addition & 1 deletion userbot/plugins/ascii.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from userbot.utils import admin_cmd
from userbot import CMD_HELP

@borg.on(admin_cmd("ascii ?(.*)"))
@borg.on(admin_cmd(pattern="ascii ?(.*)"))
async def _(event):
if event.fwd_from:
return
Expand Down
2 changes: 1 addition & 1 deletion userbot/plugins/autobio.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
DEL_TIME_OUT = 60


@borg.on(admin_cmd(pattern="bio")) # pylint:disable=E0602
@borg.on(admin_cmd(pattern="autobio")) # pylint:disable=E0602
async def _(event):
if event.fwd_from:
return
Expand Down
Loading

0 comments on commit 21659d7

Please sign in to comment.