\
43 | \n**USAGE :** Get an information about covid-19 data in the given country."
44 | }
45 | )
46 |
--------------------------------------------------------------------------------
/userbot/plugins/shout.py:
--------------------------------------------------------------------------------
1 | """Shouts a message in MEME way
2 | usage: .shout message
3 | originaly from : @corsicanu_bot
4 | """
5 |
6 | import asyncio
7 |
8 | from userbot.utils import admin_cmd
9 |
10 |
11 | @borg.on(admin_cmd(pattern=f"shout", outgoing=True))
12 | async def shout(args):
13 | if args.fwd_from:
14 | return
15 | msg = "```"
16 | messagestr = args.text
17 | messagestr = messagestr[7:]
18 | text = " ".join(messagestr)
19 | result = []
20 | result.append(" ".join([s for s in text]))
21 | for pos, symbol in enumerate(text[1:]):
22 | result.append(symbol + " " + " " * pos + symbol)
23 | result = list("\n".join(result))
24 | result[0] = text[0]
25 | result = "".join(result)
26 | msg = "\n" + result
27 | await args.edit("`" + msg + "`")
28 |
29 |
30 | @borg.on(admin_cmd(pattern=f"sadmin", outgoing=True))
31 | async def _(event):
32 | if event.fwd_from:
33 | return
34 | animation_ttl = range(0, 13)
35 | await event.edit("sadmin")
36 | animation_chars = [
37 | "@aaaaaaaaaaaaadddddddddddddmmmmmmmmmmmmmiiiiiiiiiiiiinnnnnnnnnnnnn",
38 | "@aaaaaaaaaaaaddddddddddddmmmmmmmmmmmmiiiiiiiiiiiinnnnnnnnnnnn",
39 | "@aaaaaaaaaaadddddddddddmmmmmmmmmmmiiiiiiiiiiinnnnnnnnnnn",
40 | "@aaaaaaaaaaddddddddddmmmmmmmmmmiiiiiiiiiinnnnnnnnnn",
41 | "@aaaaaaaaadddddddddmmmmmmmmmiiiiiiiiinnnnnnnnn",
42 | "@aaaaaaaaddddddddmmmmmmmmiiiiiiiinnnnnnnn",
43 | "@aaaaaaadddddddmmmmmmmiiiiiiinnnnnnn",
44 | "@aaaaaaddddddmmmmmmiiiiiinnnnnn",
45 | "@aaaaadddddmmmmmiiiiinnnnn",
46 | "@aaaaddddmmmmiiiinnnn",
47 | "@aaadddmmmiiinnn",
48 | "@aaddmmiinn",
49 | "@admin",
50 | ]
51 | for i in animation_ttl:
52 | await asyncio.sleep(1)
53 | await event.edit(animation_chars[i % 13])
54 |
--------------------------------------------------------------------------------
/userbot/plugins/figlet.py:
--------------------------------------------------------------------------------
1 | import pyfiglet
2 |
3 | from .. import CMD_HELP
4 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
5 |
6 |
7 | @borg.on(admin_cmd(pattern="figlet ?(.*)", outgoing=True))
8 | @borg.on(sudo_cmd(pattern="figlet ?(.*)", allow_sudo=True))
9 | async def figlet(event):
10 | if event.fwd_from:
11 | return
12 | CMD_FIG = {
13 | "slant": "slant",
14 | "3D": "3-d",
15 | "5line": "5lineoblique",
16 | "alpha": "alphabet",
17 | "banner": "banner3-D",
18 | "doh": "doh",
19 | "iso": "isometric1",
20 | "letter": "letters",
21 | "allig": "alligator",
22 | "dotm": "dotmatrix",
23 | "bubble": "bubble",
24 | "bulb": "bulbhead",
25 | "digi": "digital",
26 | }
27 | input_str = event.pattern_match.group(1)
28 | if ":" in input_str:
29 | text, cmd = input_str.split(":", maxsplit=1)
30 | elif input_str is not None:
31 | cmd = None
32 | text = input_str
33 | else:
34 | await edit_or_reply(event, "Please add some text to figlet")
35 | return
36 | if cmd is not None:
37 | try:
38 | font = CMD_FIG[cmd]
39 | except KeyError:
40 | await edit_or_reply(event, "Invalid selected font.")
41 | return
42 | result = pyfiglet.figlet_format(text, font=font)
43 | else:
44 | result = pyfiglet.figlet_format(text)
45 | await edit_or_reply(event, "`{}`".format(result))
46 |
47 |
48 | CMD_HELP.update(
49 | {
50 | "figlet": ".figlet text or **.figlet text : type\
51 | \n USAGE:the types are slant, 3D , 5line , alpha , banner , doh , iso , letter , allig , dotm , bubble , bulb , digi\
52 | \n NOTE: Nospace must be given after : and type\
53 | \nEXAMPLE : `.figlet hello :digi`"
54 | }
55 | )
56 |
--------------------------------------------------------------------------------
/userbot/plugins/translate.py:
--------------------------------------------------------------------------------
1 | """ Google Translate
2 | Available Commands:
3 | .tr LanguageCode as reply to a message
4 | .tr LangaugeCode | text to translate"""
5 |
6 | from googletrans import Translator
7 |
8 | from .. import CMD_HELP
9 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
10 | from . import deEmojify
11 |
12 |
13 | @borg.on(admin_cmd(pattern="tl ?(.*)"))
14 | @borg.on(sudo_cmd(pattern="tl ?(.*)", allow_sudo=True))
15 | async def _(event):
16 | if event.fwd_from:
17 | return
18 | if "trim" in event.raw_text:
19 | # https://t.me/c/1220993104/192075
20 | return
21 | input_str = event.pattern_match.group(1)
22 | if event.reply_to_msg_id:
23 | previous_message = await event.get_reply_message()
24 | text = previous_message.message
25 | lan = input_str or "ml"
26 | elif "|" in input_str:
27 | lan, text = input_str.split("|")
28 | else:
29 | await edit_or_reply(event, "`.tl LanguageCode` as reply to a message")
30 | return
31 | text = deEmojify(text.strip())
32 | lan = lan.strip()
33 | translator = Translator()
34 | try:
35 | translated = translator.translate(text, dest=lan)
36 | after_tr_text = translated.text
37 | # TODO: emojify the :
38 | # either here, or before translation
39 | output_str = """**TRANSLATED** from {} to {}
40 | {}""".format(
41 | translated.src, lan, after_tr_text
42 | )
43 | await edit_or_reply(event, output_str)
44 | except Exception as exc:
45 | await edit_or_reply(event, str(exc))
46 |
47 |
48 | CMD_HELP.update(
49 | {
50 | "translate": "**Plugin :** `translate`\
51 | \n\nAvailable Commands:\
52 | \n.tl LanguageCode as reply to a message\
53 | \n.tl LangaugeCode | text to translate\
54 | "
55 | }
56 | )
57 |
--------------------------------------------------------------------------------
/userbot/plugins/sql_helper/gban_sql_helper.py:
--------------------------------------------------------------------------------
1 | """
2 | credits to @mrconfused and @sandy1709
3 | """
4 | # Copyright (C) 2020 sandeep.n(π.$)
5 | # This program is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU Affero General Public License as
7 | # published by the Free Software Foundation, either version 3 of the
8 | # License, or (at your option) any later version.
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU Affero General Public License for more details.
13 | # You should have received a copy of the GNU Affero General Public License
14 | # along with this program. If not, see .
15 | from sqlalchemy import Column, String
16 |
17 | from userbot.plugins.sql_helper import BASE, SESSION
18 |
19 |
20 | class GBan(BASE):
21 | __tablename__ = "gban"
22 | chat_id = Column(String(14), primary_key=True)
23 | reason = Column(String(127))
24 |
25 | def __init__(self, chat_id, reason=""):
26 | self.chat_id = chat_id
27 | self.reason = reason
28 |
29 |
30 | GBan.__table__.create(checkfirst=True)
31 |
32 |
33 | def is_gbanned(chat_id):
34 | try:
35 | return SESSION.query(GBan).filter(GBan.chat_id == str(chat_id)).one()
36 | except BaseException:
37 | return None
38 | finally:
39 | SESSION.close()
40 |
41 |
42 | def catgban(chat_id, reason):
43 | adder = GBan(str(chat_id), str(reason))
44 | SESSION.add(adder)
45 | SESSION.commit()
46 |
47 |
48 | def catungban(chat_id):
49 | rem = SESSION.query(GBan).get(str(chat_id))
50 | if rem:
51 | SESSION.delete(rem)
52 | SESSION.commit()
53 |
54 |
55 | def get_all_gbanned():
56 | rem = SESSION.query(GBan).all()
57 | SESSION.close()
58 | return rem
59 |
--------------------------------------------------------------------------------
/userbot/plugins/dictionary.py:
--------------------------------------------------------------------------------
1 | # This Source Code Form is subject to the terms of the Mozilla Public
2 | # License, v. 2.0. If a copy of the MPL was not distributed with this
3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 | """Urban Dictionary
5 | Syntax: .ud Query"""
6 | import asyncurban
7 | from PyDictionary import PyDictionary
8 |
9 | from .. import CMD_HELP
10 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
11 |
12 |
13 | @borg.on(admin_cmd(pattern="ud (.*)"))
14 | @borg.on(sudo_cmd(pattern="ud (.*)", allow_sudo=True))
15 | async def _(event):
16 | word = event.pattern_match.group(1)
17 | urban = asyncurban.UrbanDictionary()
18 | try:
19 | mean = await urban.get_word(word)
20 | await edit_or_reply(
21 | event,
22 | "Text: **{}**\n\nMeaning: **{}**\n\nExample: __{}__".format(
23 | mean.word, mean.definition, mean.example
24 | ),
25 | )
26 | except asyncurban.WordNotFoundError:
27 | await edit_or_reply(event, "No result found for **" + word + "**")
28 |
29 |
30 | @borg.on(admin_cmd(pattern="meaning (.*)"))
31 | @borg.on(sudo_cmd(pattern="meaning (.*)", allow_sudo=True))
32 | async def _(event):
33 | word = event.pattern_match.group(1)
34 | dictionary = PyDictionary()
35 | cat = dictionary.meaning(word)
36 | output = f"**Word :** __{word}__\n\n"
37 | try:
38 | for a, b in cat.items():
39 | output += f"**{a}**\n"
40 | for i in b:
41 | output += f"☞__{i}__\n"
42 | await edit_or_reply(event, output)
43 | except Exception:
44 | await edit_or_reply(event, f"Couldn't fetch meaning of {word}")
45 |
46 |
47 | CMD_HELP.update(
48 | {
49 | "dictionary": "**Plugin :** `dictionary`\
50 | \n\n**Syntax :** `.ud query`\
51 | \n**Usage : **fetches meaning from Urban dictionary\
52 | \n\n**Syntax : **`.meaning query`\
53 | \n**Usage : **Fetches meaning of the given word\
54 | "
55 | }
56 | )
57 |
--------------------------------------------------------------------------------
/userbot/plugins/sql_helper/gdrive_sql.py:
--------------------------------------------------------------------------------
1 | """
2 | credits to @mrconfused and @sandy1709
3 | """
4 | # Copyright (C) 2020 sandeep.n(π.$)
5 | # This program is free software: you can redistribute it and/or modify
6 | # it under the terms of the GNU Affero General Public License as
7 | # published by the Free Software Foundation, either version 3 of the
8 | # License, or (at your option) any later version.
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU Affero General Public License for more details.
13 | # You should have received a copy of the GNU Affero General Public License
14 | # along with this program. If not, see .
15 | from sqlalchemy import Column, String
16 |
17 | from userbot.plugins.sql_helper import BASE, SESSION
18 |
19 |
20 | class Gdrive(BASE):
21 | __tablename__ = "catgdrive"
22 | cat = Column(String(50), primary_key=True)
23 |
24 | def __init__(self, cat):
25 | self.cat = cat
26 |
27 |
28 | Gdrive.__table__.create(checkfirst=True)
29 |
30 |
31 | def is_folder(folder_id):
32 | try:
33 | return SESSION.query(Gdrive).filter(Gdrive.cat == str(folder_id))
34 | except BaseException:
35 | return None
36 | finally:
37 | SESSION.close()
38 |
39 |
40 | def gparent_id(folder_id):
41 | adder = SESSION.query(Gdrive).get(folder_id)
42 | if not adder:
43 | adder = Gdrive(folder_id)
44 | SESSION.add(adder)
45 | SESSION.commit()
46 |
47 |
48 | def get_parent_id():
49 | try:
50 | return SESSION.query(Gdrive).all()
51 | except BaseException:
52 | return None
53 | finally:
54 | SESSION.close()
55 |
56 |
57 | def rmparent_id(folder_id):
58 | note = SESSION.query(Gdrive).filter(Gdrive.cat == folder_id)
59 | if note:
60 | note.delete()
61 | SESSION.commit()
62 |
--------------------------------------------------------------------------------
/userbot/plugins/ezanvakti.py:
--------------------------------------------------------------------------------
1 | # ported from
2 | # https://github.com/muhammedfurkan/UniBorg/blob/master/stdplugins/ezanvakti.py
3 | import json
4 | import logging
5 |
6 | import requests
7 |
8 | from .. import LOGS
9 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
10 |
11 | logging.basicConfig(
12 | format="[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s", level=logging.WARNING
13 | )
14 | TEMPAT = ""
15 |
16 |
17 | @borg.on(admin_cmd(pattern=("ezanvakti ?(.*)")))
18 | @borg.on(sudo_cmd(pattern="ezanvakti ?(.*)", allow_sudo=True))
19 | async def get_adzan(adzan):
20 | if not adzan.pattern_match.group(1):
21 | LOKASI = TEMPAT
22 | if not LOKASI:
23 | await edit_or_reply(adzan, "Please specify a city or a state.")
24 | return
25 | else:
26 | LOKASI = adzan.pattern_match.group(1)
27 | url = f"http://muslimsalat.com/{LOKASI}.json?key=bd099c5825cbedb9aa934e255a81a5fc"
28 | request = requests.get(url)
29 | LOGS.info(request.text)
30 | result = json.loads((request.text))
31 | if request.status_code != 200:
32 | await edit_or_reply(adzan, f"{result['status_description']}")
33 | return
34 | tanggal = result["items"][0]["date_for"]
35 | lokasi = result["query"]
36 | lokasi2 = result["country"]
37 | lokasi3 = result["address"]
38 | lokasi4 = result["state"]
39 | subuh = result["items"][0]["fajr"]
40 | syuruk = result["items"][0]["shurooq"]
41 | zuhur = result["items"][0]["dhuhr"]
42 | ashar = result["items"][0]["asr"]
43 | maghrib = result["items"][0]["maghrib"]
44 | isya = result["items"][0]["isha"]
45 | textkirim = (
46 | f"⏱ **Tarih ** `{tanggal}`:\n"
47 | + f"`{lokasi} | {lokasi2} | {lokasi3} | {lokasi4}`\n\n"
48 | + f"**Güneş :** `{subuh}`\n"
49 | + f"**İmsak :** `{syuruk}`\n"
50 | + f"**Öğle :** `{zuhur}`\n"
51 | + f"**İkindi :** `{ashar}`\n"
52 | + f"**Akşam :** `{maghrib}`\n"
53 | + f"**Yatsı :** `{isya}`\n"
54 | )
55 | await edit_or_reply(adzan, textkirim)
56 |
--------------------------------------------------------------------------------
/userbot/plugins/externalplugins.py:
--------------------------------------------------------------------------------
1 | import os
2 | from pathlib import Path
3 |
4 | from telethon.tl.types import InputMessagesFilterDocument
5 |
6 | from userbot.utils import load_module
7 | from var import Var
8 |
9 | from .. import CMD_HELP
10 | from ..utils import admin_cmd, sudo_cmd
11 |
12 |
13 | @borg.on(admin_cmd(pattern="extdl$", outgoing=True))
14 | @borg.on(sudo_cmd(pattern="extdl$", allow_sudo=True))
15 | async def install(event):
16 | if event.fwd_from:
17 | return
18 | chat = Var.PLUGIN_CHANNEL
19 | documentss = await borg.get_messages(chat, None, filter=InputMessagesFilterDocument)
20 | total = int(documentss.total)
21 | total_doxx = range(0, total)
22 | await event.delete()
23 | for ixo in total_doxx:
24 | mxo = documentss[ixo].id
25 | downloaded_file_name = await event.client.download_media(
26 | await borg.get_messages(chat, ids=mxo), "userbot/plugins/"
27 | )
28 | if "(" not in downloaded_file_name:
29 | path1 = Path(downloaded_file_name)
30 | shortname = path1.stem
31 | load_module(shortname.replace(".py", ""))
32 | await borg.send_message(
33 | event.chat_id,
34 | "Installed Plugin `{}` successfully.".format(
35 | os.path.basename(downloaded_file_name)
36 | ),
37 | )
38 | else:
39 | await borg.send_message(
40 | event.chat_id,
41 | "Plugin `{}` has been pre-installed and cannot be installed.".format(
42 | os.path.basename(downloaded_file_name)
43 | ),
44 | )
45 |
46 |
47 | CMD_HELP.update(
48 | {
49 | "externalplugins": "**externalplugins**\
50 | \n**Syntax :** `.extdl`\
51 | \n**Usage : **To install external plugins Create a private channel and post there all your external modules and set a var in heroku as `PLUGIN_CHANNEL` and value with channel id \
52 | so after each restart or update simply type `.extdl` to install all external modules\
53 | "
54 | }
55 | )
56 |
--------------------------------------------------------------------------------
/userbot/plugins/sql_helper/snips_sql.py:
--------------------------------------------------------------------------------
1 | from sqlalchemy import Column, LargeBinary, Numeric, UnicodeText
2 |
3 | from userbot.plugins.sql_helper import BASE, SESSION
4 |
5 |
6 | class Snips(BASE):
7 | __tablename__ = "snips"
8 | snip = Column(UnicodeText, primary_key=True)
9 | reply = Column(UnicodeText)
10 | snip_type = Column(Numeric)
11 | media_id = Column(UnicodeText)
12 | media_access_hash = Column(UnicodeText)
13 | media_file_reference = Column(LargeBinary)
14 |
15 | def __init__(
16 | self,
17 | snip,
18 | reply,
19 | snip_type,
20 | media_id=None,
21 | media_access_hash=None,
22 | media_file_reference=None,
23 | ):
24 | self.snip = snip
25 | self.reply = reply
26 | self.snip_type = snip_type
27 | self.media_id = media_id
28 | self.media_access_hash = media_access_hash
29 | self.media_file_reference = media_file_reference
30 |
31 |
32 | Snips.__table__.create(checkfirst=True)
33 |
34 |
35 | def get_snips(keyword):
36 | try:
37 | return SESSION.query(Snips).get(keyword)
38 | except BaseException:
39 | return None
40 | finally:
41 | SESSION.close()
42 |
43 |
44 | def get_all_snips():
45 | try:
46 | return SESSION.query(Snips).all()
47 | except BaseException:
48 | return None
49 | finally:
50 | SESSION.close()
51 |
52 |
53 | def add_snip(
54 | keyword, reply, snip_type, media_id, media_access_hash, media_file_reference
55 | ):
56 | adder = SESSION.query(Snips).get(keyword)
57 | if adder:
58 | adder.reply = reply
59 | adder.snip_type = snip_type
60 | adder.media_id = media_id
61 | adder.media_access_hash = media_access_hash
62 | adder.media_file_reference = media_file_reference
63 | else:
64 | adder = Snips(
65 | keyword, reply, snip_type, media_id, media_access_hash, media_file_reference
66 | )
67 | SESSION.add(adder)
68 | SESSION.commit()
69 |
70 |
71 | def remove_snip(keyword):
72 | note = SESSION.query(Snips).filter(Snips.snip == keyword)
73 | if note:
74 | note.delete()
75 | SESSION.commit()
76 |
--------------------------------------------------------------------------------
/userbot/plugins/sql_helper/welcome_sql.py:
--------------------------------------------------------------------------------
1 | try:
2 | from . import BASE, SESSION
3 | except ImportError:
4 | raise AttributeError
5 |
6 | from sqlalchemy import BigInteger, Column, Numeric, String, UnicodeText
7 |
8 |
9 | class Welcome(BASE):
10 | __tablename__ = "catwelcome"
11 | chat_id = Column(String(14), primary_key=True)
12 | previous_welcome = Column(BigInteger)
13 | reply = Column(UnicodeText)
14 | f_mesg_id = Column(Numeric)
15 |
16 | def __init__(self, chat_id, previous_welcome, reply, f_mesg_id):
17 | self.chat_id = str(chat_id)
18 | self.previous_welcome = previous_welcome
19 | self.reply = reply
20 | self.f_mesg_id = f_mesg_id
21 |
22 |
23 | Welcome.__table__.create(checkfirst=True)
24 |
25 |
26 | def get_welcome(chat_id):
27 | try:
28 | return SESSION.query(Welcome).get(str(chat_id))
29 | finally:
30 | SESSION.close()
31 |
32 |
33 | def get_current_welcome_settings(chat_id):
34 | try:
35 | return SESSION.query(Welcome).filter(Welcome.chat_id == str(chat_id)).one()
36 | except BaseException:
37 | return None
38 | finally:
39 | SESSION.close()
40 |
41 |
42 | def add_welcome_setting(chat_id, previous_welcome, reply, f_mesg_id):
43 | to_check = get_welcome(chat_id)
44 | if not to_check:
45 | adder = Welcome(chat_id, previous_welcome, reply, f_mesg_id)
46 | SESSION.add(adder)
47 | SESSION.commit()
48 | return True
49 | else:
50 | rem = SESSION.query(Welcome).get(str(chat_id))
51 | SESSION.delete(rem)
52 | SESSION.commit()
53 | adder = Welcome(chat_id, previous_welcome, reply, f_mesg_id)
54 | SESSION.commit()
55 | return False
56 |
57 |
58 | def rm_welcome_setting(chat_id):
59 | try:
60 | rem = SESSION.query(Welcome).get(str(chat_id))
61 | if rem:
62 | SESSION.delete(rem)
63 | SESSION.commit()
64 | return True
65 | except BaseException:
66 | return False
67 |
68 |
69 | def update_previous_welcome(chat_id, previous_welcome):
70 | row = SESSION.query(Welcome).get(str(chat_id))
71 | row.previous_welcome = previous_welcome
72 | SESSION.commit()
73 |
--------------------------------------------------------------------------------
/userbot/plugins/sql_helper/welcomesql.py:
--------------------------------------------------------------------------------
1 | try:
2 | from . import BASE, SESSION
3 | except ImportError:
4 | raise AttributeError
5 |
6 | from sqlalchemy import BigInteger, Column, Numeric, String, UnicodeText
7 |
8 |
9 | class JoinWelcome(BASE):
10 | __tablename__ = "joinwelcome"
11 | chat_id = Column(String(14), primary_key=True)
12 | previous_welcome = Column(BigInteger)
13 | reply = Column(UnicodeText)
14 | f_mesg_id = Column(Numeric)
15 |
16 | def __init__(self, chat_id, previous_welcome, reply, f_mesg_id):
17 | self.chat_id = str(chat_id)
18 | self.previous_welcome = previous_welcome
19 | self.reply = reply
20 | self.f_mesg_id = f_mesg_id
21 |
22 |
23 | JoinWelcome.__table__.create(checkfirst=True)
24 |
25 |
26 | def getwelcome(chat_id):
27 | try:
28 | return SESSION.query(JoinWelcome).get(str(chat_id))
29 | finally:
30 | SESSION.close()
31 |
32 |
33 | def getcurrent_welcome_settings(chat_id):
34 | try:
35 | return (
36 | SESSION.query(JoinWelcome).filter(JoinWelcome.chat_id == str(chat_id)).one()
37 | )
38 | except BaseException:
39 | return None
40 | finally:
41 | SESSION.close()
42 |
43 |
44 | def addwelcome_setting(chat_id, previous_welcome, reply, f_mesg_id):
45 | to_check = getwelcome(chat_id)
46 | if not to_check:
47 | adder = JoinWelcome(chat_id, previous_welcome, reply, f_mesg_id)
48 | SESSION.add(adder)
49 | SESSION.commit()
50 | return True
51 | else:
52 | rem = SESSION.query(JoinWelcome).get(str(chat_id))
53 | SESSION.delete(rem)
54 | SESSION.commit()
55 | adder = JoinWelcome(chat_id, previous_welcome, reply, f_mesg_id)
56 | SESSION.commit()
57 | return False
58 |
59 |
60 | def rmwelcome_setting(chat_id):
61 | try:
62 | rem = SESSION.query(JoinWelcome).get(str(chat_id))
63 | if rem:
64 | SESSION.delete(rem)
65 | SESSION.commit()
66 | return True
67 | except BaseException:
68 | return False
69 |
70 |
71 | def updateprevious_welcome(chat_id, previous_welcome):
72 | row = SESSION.query(JoinWelcome).get(str(chat_id))
73 | row.previous_welcome = previous_welcome
74 | SESSION.commit()
75 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # CAT USERBOT
3 |
4 | ### The Easy Way to deploy the bot
5 | Get APP ID and API HASH from [HERE](https://my.telegram.org) and BOT TOKEN from [Bot Father](https://t.me/botfather) and then Generate stringsession by clicking on run.on.repl.it button below and then click on deploy to heroku . Before clicking on deploy to heroku just click on fork and star just below
6 |
7 | [](https://generatestringsession.sandeep1709.repl.run/)
8 |
9 | [](https://heroku.com/deploy?template=https://github.com/sandy1709/catuserbot)
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | [](https://heroku.com/deploy?template=https://github.com/sandy1709/catuserbot)
22 |
23 |
24 | ### Join [here](https://t.me/catuserbot17) for updates and tuts and [here](https://t.me/catuserbot_support) for discussion and bugs
25 |
26 | ### The Normal Way
27 |
28 | An example `local_config.py` file could be:
29 |
30 | **Not All of the variables are mandatory**
31 |
32 | __The Userbot should work by setting only the first two variables__
33 |
34 | ```python3
35 | from heroku_config import Var
36 |
37 | class Development(Var):
38 | APP_ID = 6
39 | API_HASH = "eb06d4abfb49dc3eeb1aeb98ae0f581e"
40 | ```
41 |
42 | ### UniBorg Configuration
43 |
44 |
45 |
46 | **Heroku Configuration**
47 | Simply just leave the Config as it is.
48 |
49 | **Local Configuration**
50 |
51 | Fortunately there are no Mandatory vars for the UniBorg Support Config.
52 |
53 | ## Mandatory Vars
54 |
55 | - Only two of the environment variables are mandatory.
56 | - This is because of `telethon.errors.rpc_error_list.ApiIdPublishedFloodError`
57 |
58 | - `APP_ID`: You can get this value from https://my.telegram.org
59 | - `API_HASH`: You can get this value from https://my.telegram.org
60 | - The userbot will not work without setting the mandatory vars.
61 |
--------------------------------------------------------------------------------
/userbot/plugins/images.py:
--------------------------------------------------------------------------------
1 | """
2 | Download & Upload Images on Telegram\n
3 | Syntax: `.img ` or `.img (replied message)`
4 | \n Upgraded and Google Image Error Fixed by @NeoMatrix90 aka @kirito6969
5 | from oub
6 | """
7 | import os
8 | import shutil
9 |
10 | from .. import CMD_HELP
11 | from ..helpers.google_image_download import googleimagesdownload
12 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
13 |
14 |
15 | @borg.on(admin_cmd(pattern=r"img(?: |$)(\d*)? ?(.*)"))
16 | @borg.on(sudo_cmd(pattern=r"img(?: |$)(\d*)? ?(.*)", allow_sudo=True))
17 | async def img_sampler(event):
18 | reply_to_id = event.message.id
19 | if event.reply_to_msg_id:
20 | reply_to_id = event.reply_to_msg_id
21 | if event.is_reply and not event.pattern_match.group(2):
22 | query = await event.get_reply_message()
23 | query = str(query.message)
24 | else:
25 | query = str(event.pattern_match.group(2))
26 | if not query:
27 | return await edit_or_reply(
28 | event, "Reply to a message or pass a query to search!"
29 | )
30 | cat = await edit_or_reply(event, "`Processing...`")
31 | if event.pattern_match.group(1) != "":
32 | lim = int(event.pattern_match.group(1))
33 | if lim > 10:
34 | lim = int(10)
35 | if lim <= 0:
36 | lim = int(1)
37 | else:
38 | lim = int(3)
39 | response = googleimagesdownload()
40 | # creating list of arguments
41 | arguments = {
42 | "keywords": query,
43 | "limit": lim,
44 | "format": "jpg",
45 | "no_directory": "no_directory",
46 | }
47 | # passing the arguments to the function
48 | try:
49 | paths = response.download(arguments)
50 | except Exception as e:
51 | return await cat.edit(f"Error: \n`{e}`")
52 | lst = paths[0][query]
53 | await bot.send_file(
54 | await bot.get_input_entity(event.chat_id), lst, reply_to=reply_to_id
55 | )
56 | shutil.rmtree(os.path.dirname(os.path.abspath(lst[0])))
57 | await cat.delete()
58 |
59 |
60 | CMD_HELP.update(
61 | {
62 | "images": "**Plugin :**`images`\
63 | \n\n**Syntax :** `.img ` or `.img (replied message)`\
64 | \n**Usage : **do google image search and sends 3 images. default if you havent mentioned limit"
65 | }
66 | )
67 |
--------------------------------------------------------------------------------
/userbot/plugins/sql_helper/filter_sql.py:
--------------------------------------------------------------------------------
1 | from sqlalchemy import Column, Numeric, String, UnicodeText
2 |
3 | from . import BASE, SESSION
4 |
5 |
6 | class Filter(BASE):
7 | __tablename__ = "catfilters"
8 | chat_id = Column(String(14), primary_key=True)
9 | keyword = Column(UnicodeText, primary_key=True, nullable=False)
10 | reply = Column(UnicodeText)
11 | f_mesg_id = Column(Numeric)
12 |
13 | def __init__(self, chat_id, keyword, reply, f_mesg_id):
14 | self.chat_id = str(chat_id)
15 | self.keyword = keyword
16 | self.reply = reply
17 | self.f_mesg_id = f_mesg_id
18 |
19 | def __eq__(self, other):
20 | return bool(
21 | isinstance(other, Filter)
22 | and self.chat_id == other.chat_id
23 | and self.keyword == other.keyword
24 | )
25 |
26 |
27 | Filter.__table__.create(checkfirst=True)
28 |
29 |
30 | def get_filter(chat_id, keyword):
31 | try:
32 | return SESSION.query(Filter).get((str(chat_id), keyword))
33 | finally:
34 | SESSION.close()
35 |
36 |
37 | def get_filters(chat_id):
38 | try:
39 | return SESSION.query(Filter).filter(Filter.chat_id == str(chat_id)).all()
40 | finally:
41 | SESSION.close()
42 |
43 |
44 | def add_filter(chat_id, keyword, reply, f_mesg_id):
45 | to_check = get_filter(chat_id, keyword)
46 | if not to_check:
47 | adder = Filter(str(chat_id), keyword, reply, f_mesg_id)
48 | SESSION.add(adder)
49 | SESSION.commit()
50 | return True
51 | else:
52 | rem = SESSION.query(Filter).get((str(chat_id), keyword))
53 | SESSION.delete(rem)
54 | SESSION.commit()
55 | adder = Filter(str(chat_id), keyword, reply, f_mesg_id)
56 | SESSION.add(adder)
57 | SESSION.commit()
58 | return False
59 |
60 |
61 | def remove_filter(chat_id, keyword):
62 | to_check = get_filter(chat_id, keyword)
63 | if not to_check:
64 | return False
65 | else:
66 | rem = SESSION.query(Filter).get((str(chat_id), keyword))
67 | SESSION.delete(rem)
68 | SESSION.commit()
69 | return True
70 |
71 |
72 | def remove_all_filters(chat_id):
73 | saved_filter = SESSION.query(Filter).filter(Filter.chat_id == str(chat_id))
74 | if saved_filter:
75 | saved_filter.delete()
76 | SESSION.commit()
77 |
--------------------------------------------------------------------------------
/userbot/plugins/power_tools.py:
--------------------------------------------------------------------------------
1 | import sys
2 | from os import execl
3 | from time import sleep
4 |
5 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
6 | from . import BOTLOG, BOTLOG_CHATID, CMD_HELP, bot
7 |
8 |
9 | @borg.on(admin_cmd(pattern="restart$"))
10 | @borg.on(sudo_cmd(pattern="restart$", allow_sudo=True))
11 | async def _(event):
12 | if event.fwd_from:
13 | return
14 | if BOTLOG:
15 | await event.client.send_message(BOTLOG_CHATID, "#RESTART \n" "Bot Restarted")
16 | await edit_or_reply(
17 | event,
18 | "Restarted. `.ping` me or `.help` to check if I am online, actually it takes 1-2 min for restarting",
19 | )
20 | await bot.disconnect()
21 | execl(sys.executable, sys.executable, *sys.argv)
22 |
23 |
24 | @borg.on(admin_cmd(pattern="shutdown$"))
25 | @borg.on(sudo_cmd(pattern="shutdown$", allow_sudo=True))
26 | async def _(event):
27 | if event.fwd_from:
28 | return
29 | if BOTLOG:
30 | await event.client.send_message(BOTLOG_CHATID, "#SHUTDOWN \n" "Bot shut down")
31 | await edit_or_reply(event, "Turning off ...Manually turn me on later")
32 | await bot.disconnect()
33 |
34 |
35 | @borg.on(admin_cmd(pattern="sleep( [0-9]+)?$"))
36 | @borg.on(sudo_cmd(pattern="sleep( [0-9]+)?$", allow_sudo=True))
37 | async def _(event):
38 | if " " not in event.pattern_match.group(1):
39 | return await edit_or_reply(event, "Syntax: `.sleep time`")
40 | counter = int(event.pattern_match.group(1))
41 | if BOTLOG:
42 | await event.client.send_message(
43 | BOTLOG_CHATID,
44 | "You put the bot to sleep for " + str(counter) + " seconds",
45 | )
46 | event = await edit_or_reply(event, f"`ok, let me sleep for {counter} seconds`")
47 | sleep(counter)
48 | await event.edit("`OK, I'm awake now.`")
49 |
50 |
51 | CMD_HELP.update(
52 | {
53 | "power_tools": "**Plugin : **`power_tools`\
54 | \n\n**Syntax : **`.restart`\
55 | \n**Usage : **Restarts the bot !!\
56 | \n\n**Syntax : **'.sleep \
57 | \n**Usage: **Userbots get tired too. Let yours snooze for a few seconds.\
58 | \n\n**Syntax : **`.shutdown`\
59 | \n**Usage : **Sometimes you need to shut down your bot. Sometimes you just hope to\
60 | hear Windows XP shutdown sound... but you don't."
61 | }
62 | )
63 |
--------------------------------------------------------------------------------
/heroku_config.py:
--------------------------------------------------------------------------------
1 | import os
2 |
3 |
4 | class Var(object):
5 | APP_ID = int(os.environ.get("APP_ID", 6))
6 | # 6 is a placeholder
7 | API_HASH = os.environ.get("API_HASH", "eb06d4abfb49dc3eeb1aeb98ae0f581e")
8 | STRING_SESSION = os.environ.get("STRING_SESSION", None)
9 | DB_URI = os.environ.get("DATABASE_URL", None)
10 | TEMP_DOWNLOAD_DIRECTORY = os.environ.get("TEMP_DOWNLOAD_DIRECTORY", None)
11 | LOGGER = True
12 | GITHUB_ACCESS_TOKEN = os.environ.get("GITHUB_ACCESS_TOKEN", None)
13 | GIT_REPO_NAME = os.environ.get("GIT_REPO_NAME", None)
14 | # Here for later purposes
15 | SUDO_USERS = set(int(x) for x in os.environ.get("SUDO_USERS", "1005520858").split())
16 | LYDIA_API_KEY = os.environ.get("LYDIA_API_KEY", None)
17 | LESS_SPAMMY = os.environ.get("LESS_SPAMMY", None)
18 | HEROKU_API_KEY = os.environ.get("HEROKU_API_KEY", None)
19 | HEROKU_APP_NAME = os.environ.get("HEROKU_APP_NAME", None)
20 | TG_BOT_TOKEN_BF_HER = os.environ.get("TG_BOT_TOKEN_BF_HER", None)
21 | # Send .get_id in any channel to fill this value.
22 | PLUGIN_CHANNEL = int(os.environ.get("PLUGIN_CHANNEL", -100))
23 | TG_BOT_USER_NAME_BF_HER = os.environ.get("TG_BOT_USER_NAME_BF_HER", None)
24 | NO_SONGS = bool(os.environ.get("NO_SONGS", False))
25 | DOWNLOAD_PFP_URL_CLOCK = os.environ.get("DOWNLOAD_PFP_URL_CLOCK", None)
26 | G_DRIVE_CLIENT_ID = os.environ.get("G_DRIVE_CLIENT_ID", None)
27 | G_DRIVE_CLIENT_SECRET = os.environ.get("G_DRIVE_CLIENT_SECRET", None)
28 | GDRIVE_FOLDER_ID = os.environ.get("GDRIVE_FOLDER_ID", "root")
29 | AUTH_TOKEN_DATA = os.environ.get("AUTH_TOKEN_DATA", None)
30 | MAX_FLOOD_IN_P_M_s = int(os.environ.get("MAX_FLOOD_IN_P_M_s", 5))
31 | if AUTH_TOKEN_DATA is not None:
32 | if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY):
33 | os.makedirs(TEMP_DOWNLOAD_DIRECTORY)
34 | t_file = open(TEMP_DOWNLOAD_DIRECTORY + "auth_token.txt", "w")
35 | t_file.write(AUTH_TOKEN_DATA)
36 | t_file.close()
37 | PRIVATE_GROUP_ID = os.environ.get("PRIVATE_GROUP_ID", None)
38 | if PRIVATE_GROUP_ID is not None:
39 | try:
40 | PRIVATE_GROUP_ID = int(PRIVATE_GROUP_ID)
41 | except ValueError:
42 | raise ValueError(
43 | "Invalid Private Group ID. Make sure your ID is starts with -100 and make sure that it is only numbers."
44 | )
45 |
46 |
47 | class Development(Var):
48 | LOGGER = True
49 |
--------------------------------------------------------------------------------
/userbot/plugins/sql_helper/locks_sql.py:
--------------------------------------------------------------------------------
1 | from sqlalchemy import Boolean, Column, String
2 |
3 | from userbot.plugins.sql_helper import BASE, SESSION
4 |
5 |
6 | class Locks(BASE):
7 | __tablename__ = "locks"
8 | chat_id = Column(String(14), primary_key=True)
9 | # Booleans are for "is this locked", _NOT_ "is this allowed"
10 | bots = Column(Boolean, default=False)
11 | commands = Column(Boolean, default=False)
12 | email = Column(Boolean, default=False)
13 | forward = Column(Boolean, default=False)
14 | url = Column(Boolean, default=False)
15 |
16 | def __init__(self, chat_id):
17 | self.chat_id = str(chat_id) # ensure string
18 | self.bots = False
19 | self.commands = False
20 | self.email = False
21 | self.forward = False
22 | self.url = False
23 |
24 |
25 | Locks.__table__.create(checkfirst=True)
26 |
27 |
28 | def init_locks(chat_id, reset=False):
29 | curr_restr = SESSION.query(Locks).get(str(chat_id))
30 | if reset:
31 | SESSION.delete(curr_restr)
32 | SESSION.flush()
33 | restr = Locks(str(chat_id))
34 | SESSION.add(restr)
35 | SESSION.commit()
36 | return restr
37 |
38 |
39 | def update_lock(chat_id, lock_type, locked):
40 | curr_perm = SESSION.query(Locks).get(str(chat_id))
41 | if not curr_perm:
42 | curr_perm = init_locks(chat_id)
43 | if lock_type == "bots":
44 | curr_perm.bots = locked
45 | elif lock_type == "commands":
46 | curr_perm.commands = locked
47 | elif lock_type == "email":
48 | curr_perm.email = locked
49 | elif lock_type == "forward":
50 | curr_perm.forward = locked
51 | elif lock_type == "url":
52 | curr_perm.url = locked
53 | SESSION.add(curr_perm)
54 | SESSION.commit()
55 |
56 |
57 | def is_locked(chat_id, lock_type):
58 | curr_perm = SESSION.query(Locks).get(str(chat_id))
59 | SESSION.close()
60 | if not curr_perm:
61 | return False
62 | if lock_type == "bots":
63 | return curr_perm.bots
64 | if lock_type == "commands":
65 | return curr_perm.commands
66 | if lock_type == "email":
67 | return curr_perm.email
68 | if lock_type == "forward":
69 | return curr_perm.forward
70 | if lock_type == "url":
71 | return curr_perm.url
72 |
73 |
74 | def get_locks(chat_id):
75 | try:
76 | return SESSION.query(Locks).get(str(chat_id))
77 | finally:
78 | SESSION.close()
79 |
--------------------------------------------------------------------------------
/userbot/plugins/inline.py:
--------------------------------------------------------------------------------
1 | # thanks to @null7410 for callbackquery code
2 | # created by @sandy1709 and @mrconfused
3 | import re
4 |
5 | from telethon import custom, events
6 |
7 | if Var.TG_BOT_USER_NAME_BF_HER is not None and tgbot is not None:
8 |
9 | @tgbot.on(events.InlineQuery)
10 | async def inline_handler(event):
11 | builder = event.builder
12 | result = None
13 | query = event.text
14 | hmm = re.compile("secret (.*) (.*)")
15 | match = re.findall(hmm, query)
16 | if event.query.user_id == bot.uid and match:
17 | query = query[7:]
18 | user, txct = query.split(" ", 1)
19 | try:
20 | # if u is user id
21 | u = int(user)
22 | buttons = [
23 | custom.Button.inline("show message 🔐", data=f"secret_{u}_ {txct}")
24 | ]
25 | try:
26 | u = await event.client.get_entity(u)
27 | if u.username:
28 | sandy = f"@{u.username}"
29 | else:
30 | sandy = f"[{u.first_name}](tg://user?id={u.id})"
31 | except ValueError:
32 | # ValueError: Could not find the input entity
33 | sandy = f"[user](tg://user?id={u})"
34 | result = builder.article(
35 | title="secret message",
36 | text=f"🔒 A whisper message to {sandy}, Only he/she can open it.",
37 | buttons=buttons,
38 | )
39 | await event.answer([result] if result else None)
40 | except ValueError:
41 | # if u is username
42 | u = await event.client.get_entity(user)
43 | buttons = [
44 | custom.Button.inline(
45 | "show message 🔐", data=f"secret_{u.id}_ {txct}"
46 | )
47 | ]
48 | if u.username:
49 | sandy = f"@{u.username}"
50 | else:
51 | sandy = f"[{u.first_name}](tg://user?id={u.id})"
52 | result = builder.article(
53 | title="secret message",
54 | text=f"🔒 A whisper message to {sandy}, Only he/she can open it.",
55 | buttons=buttons,
56 | )
57 | await event.answer([result] if result else None)
58 |
--------------------------------------------------------------------------------
/userbot/plugins/gbun.py:
--------------------------------------------------------------------------------
1 | # This is a troll indeed ffs *facepalm*
2 | import asyncio
3 |
4 | from telethon.tl.functions.users import GetFullUserRequest
5 | from telethon.tl.types import ChannelParticipantsAdmins
6 |
7 | from userbot.utils import admin_cmd
8 |
9 |
10 | @borg.on(admin_cmd(pattern="gbun"))
11 | async def gbun(event):
12 | if event.fwd_from:
13 | return
14 | gbunVar = event.text
15 | gbunVar = gbunVar[6:]
16 | mentions = "`Warning!! User 𝙂𝘽𝘼𝙉𝙉𝙀𝘿 By Admin...\n`"
17 | no_reason = "__Reason: Potential spammer. __"
18 | await event.edit("**Summoning out le Gungnir ❗️⚜️☠️**")
19 | await asyncio.sleep(3.5)
20 | chat = await event.get_input_chat()
21 | async for x in borg.iter_participants(chat, filter=ChannelParticipantsAdmins):
22 | mentions += f""
23 | reply_message = None
24 | if event.reply_to_msg_id:
25 | reply_message = await event.get_reply_message()
26 | replied_user = await event.client(GetFullUserRequest(reply_message.from_id))
27 | firstname = replied_user.user.first_name
28 | usname = replied_user.user.username
29 | idd = reply_message.from_id
30 | # make meself invulnerable cuz why not xD
31 | if idd == 1035034432:
32 | await reply_message.reply(
33 | "`Wait a second, This is my master!`\n**How dare you threaten to ban my master nigger!**\n\n__Your account has been hacked! Pay 69$ to my master__ [π.$](tg://user?id=1035034432) __to release your account__😏"
34 | )
35 | else:
36 | jnl = (
37 | "`Warning!! `"
38 | "[{}](tg://user?id={})"
39 | "` 𝙂𝘽𝘼𝙉𝙉𝙀𝘿 By Admin...\n\n`"
40 | "**user's Name: ** __{}__\n"
41 | "**ID : ** `{}`\n"
42 | ).format(firstname, idd, firstname, idd)
43 | if usname is None:
44 | jnl += "**Victim Nigga's username: ** `Doesn't own a username!`\n"
45 | else:
46 | jnl += "**Victim Nigga's username** : @{}\n".format(usname)
47 | if len(gbunVar) > 0:
48 | gbunm = "`{}`".format(gbunVar)
49 | gbunr = "**Reason: **" + gbunm
50 | jnl += gbunr
51 | else:
52 | jnl += no_reason
53 | await reply_message.reply(jnl)
54 | else:
55 | mention = "`Warning!! User 𝙂𝘽𝘼𝙉𝙉𝙀𝘿 By Admin...\nReason: Potential spammer. `"
56 | await event.reply(mention)
57 | await event.delete()
58 |
--------------------------------------------------------------------------------
/userbot/plugins/emojify.py:
--------------------------------------------------------------------------------
1 | """
2 | Created by @Jisan7509
3 | modified by @mrconfused
4 | Userbot plugin for CatUserbot
5 | """
6 | import emoji
7 |
8 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
9 | from . import CMD_HELP
10 | from . import fonts as emojify
11 |
12 |
13 | @borg.on(admin_cmd(pattern="emoji(?: |$)(.*)"))
14 | @borg.on(sudo_cmd(pattern="emoji(?: |$)(.*)", allow_sudo=True))
15 | async def itachi(event):
16 | args = event.pattern_match.group(1)
17 | if not args:
18 | get = await event.get_reply_message()
19 | args = get.text
20 | if not args:
21 | await edit_or_reply(
22 | event, "`What am I Supposed to do with this stupid, Give me a text. `"
23 | )
24 | return
25 | result = ""
26 | for a in args:
27 | a = a.lower()
28 | if a in emojify.kakashitext:
29 | char = emojify.kakashiemoji[emojify.kakashitext.index(a)]
30 | result += char
31 | else:
32 | result += a
33 | await edit_or_reply(event, result)
34 |
35 |
36 | @borg.on(admin_cmd(pattern="cmoji(?: |$)(.*)"))
37 | @borg.on(sudo_cmd(pattern="cmoji(?: |$)(.*)", allow_sudo=True))
38 | async def itachi(event):
39 | args = event.pattern_match.group(1)
40 | if not args:
41 | get = await event.get_reply_message()
42 | args = get.text
43 | if not args:
44 | await edit_or_reply(
45 | event, "`What am I Supposed to do with this stupid, Give me a text. `"
46 | )
47 | return
48 | try:
49 | emoji, arg = args.split(" ", 1)
50 | except:
51 | arg = args
52 | emoji = "😺"
53 | if not char_is_emoji(emoji):
54 | arg = args
55 | emoji = "😺"
56 | result = ""
57 | for a in arg:
58 | a = a.lower()
59 | if a in emojify.kakashitext:
60 | char = emojify.itachiemoji[emojify.kakashitext.index(a)].format(cj=emoji)
61 | result += char
62 | else:
63 | result += a
64 | await edit_or_reply(event, result)
65 |
66 |
67 | def char_is_emoji(character):
68 | return character in emoji.UNICODE_EMOJI
69 |
70 |
71 | CMD_HELP.update(
72 | {
73 | "emojify": "**Plugin :** `emojify`\
74 | \n\n**Syntax :** `.emoji` \
75 | \n****Usage : **Converts your text to big emoji text, with default emoji. \
76 | \n\n**Syntax :** `.cmoji` \
77 | \n****Usage : **Converts your text to big emoji text, with your custom emoji.\
78 | "
79 | }
80 | )
81 |
--------------------------------------------------------------------------------
/userbot/plugins/ocr.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2019 The Raphielscape Company LLC.
2 | #
3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License");
4 | # you may not use this file except in compliance with the License.
5 |
6 | import os
7 |
8 | import requests
9 |
10 | from userbot import CMD_HELP, TEMP_DOWNLOAD_DIRECTORY, bot
11 | from userbot.utils import admin_cmd
12 |
13 | OCR_SPACE_API_KEY = Config.OCR_SPACE_API_KEY
14 |
15 |
16 | async def ocr_space_file(
17 | filename, overlay=False, api_key=OCR_SPACE_API_KEY, language="eng"
18 | ):
19 | """OCR.space API request with local file.
20 | Python3.5 - not tested on 2.7
21 | :param filename: Your file path & name.
22 | :param overlay: Is OCR.space overlay required in your response.
23 | Defaults to False.
24 | :param api_key: OCR.space API key.
25 | Defaults to 'helloworld'.
26 | :param language: Language code to be used in OCR.
27 | List of available language codes can be found on https://ocr.space/OCRAPI
28 | Defaults to 'en'.
29 | :return: Result in JSON format.
30 | """
31 |
32 | payload = {
33 | "isOverlayRequired": overlay,
34 | "apikey": api_key,
35 | "language": language,
36 | }
37 | with open(filename, "rb") as f:
38 | r = requests.post(
39 | "https://api.ocr.space/parse/image",
40 | files={filename: f},
41 | data=payload,
42 | )
43 | return r.json()
44 |
45 |
46 | @borg.on(admin_cmd(pattern="ocr(?: |$)(.*)", outgoing=True))
47 | async def ocr(event):
48 | await event.edit("`Reading...`")
49 | if not os.path.isdir(TEMP_DOWNLOAD_DIRECTORY):
50 | os.makedirs(TEMP_DOWNLOAD_DIRECTORY)
51 | lang_code = event.pattern_match.group(1)
52 | downloaded_file_name = await bot.download_media(
53 | await event.get_reply_message(), TEMP_DOWNLOAD_DIRECTORY
54 | )
55 | test_file = await ocr_space_file(filename=downloaded_file_name, language=lang_code)
56 | try:
57 | ParsedText = test_file["ParsedResults"][0]["ParsedText"]
58 | except BaseException:
59 | await event.edit("`Couldn't read it.`\n`I guess I need new glasses.`")
60 | else:
61 | await event.edit(f"`Here's what I could read from it:`\n\n{ParsedText}")
62 | os.remove(downloaded_file_name)
63 |
64 |
65 | CMD_HELP.update(
66 | {
67 | "ocr": ".ocr \nUsage: Reply to an image or sticker to extract text from it.\n\nGet language codes from [here](https://ocr.space/ocrapi)"
68 | }
69 | )
70 |
--------------------------------------------------------------------------------
/userbot/plugins/mention.py:
--------------------------------------------------------------------------------
1 | """Mention/Tag Replied Users\n
2 | `.men`
3 | """
4 | # By: @INF1N17Y
5 | # plugin from uniborg
6 |
7 | from telethon.tl.types import ChannelParticipantsAdmins
8 |
9 | from userbot.utils import admin_cmd
10 |
11 |
12 | @borg.on(admin_cmd(pattern="tagall$"))
13 | async def _(event):
14 | if event.fwd_from:
15 | return
16 | reply_to_id = event.message
17 | if event.reply_to_msg_id:
18 | reply_to_id = await event.get_reply_message()
19 | mentions = "@all"
20 | chat = await event.get_input_chat()
21 | async for x in borg.iter_participants(chat, 100):
22 | mentions += f"[\u2063](tg://user?id={x.id})"
23 | await reply_to_id.reply(mentions)
24 | await event.delete()
25 |
26 |
27 | @borg.on(admin_cmd(pattern="all (.*)"))
28 | async def _(event):
29 | if event.fwd_from:
30 | return
31 | reply_to_id = event.message
32 | if event.reply_to_msg_id:
33 | reply_to_id = await event.get_reply_message()
34 | input_str = event.pattern_match.group(1)
35 |
36 | if not input_str:
37 | return await event.edit("what should i do try `.all hello`.")
38 |
39 | mentions = input_str
40 | chat = await event.get_input_chat()
41 | async for x in borg.iter_participants(chat, 100):
42 | mentions += f"[\u2063](tg://user?id={x.id})"
43 | await reply_to_id.reply(mentions)
44 | await event.delete()
45 |
46 |
47 | @borg.on(admin_cmd(pattern="admins$"))
48 | async def _(event):
49 | if event.fwd_from:
50 | return
51 | mentions = "@admin: **Spam Spotted**"
52 | chat = await event.get_input_chat()
53 | async for x in borg.iter_participants(chat, filter=ChannelParticipantsAdmins):
54 | mentions += f"[\u2063](tg://user?id={x.id})"
55 | reply_message = None
56 | if event.reply_to_msg_id:
57 | reply_message = await event.get_reply_message()
58 | await reply_message.reply(mentions)
59 | else:
60 | await event.reply(mentions)
61 | await event.delete()
62 |
63 |
64 | @borg.on(admin_cmd(pattern="men (.*)"))
65 | async def _(event):
66 | if event.fwd_from:
67 | return
68 | if event.reply_to_msg_id:
69 | input_str = event.pattern_match.group(1)
70 | reply_msg = await event.get_reply_message()
71 | caption = """{}""".format(
72 | reply_msg.from_id, input_str
73 | )
74 | await event.delete()
75 | await borg.send_message(event.chat_id, caption, parse_mode="HTML")
76 | else:
77 | await event.edit("Reply to user with `.mention `")
78 |
--------------------------------------------------------------------------------
/userbot/plugins/mashup.py:
--------------------------------------------------------------------------------
1 | # created by @Mr_Hops
2 | """
3 | video meme mashup:
4 | Syntax: .mash
5 | """
6 | from telethon import events
7 | from telethon.errors.rpcerrorlist import YouBlockedUserError
8 |
9 | from userbot import CMD_HELP
10 | from userbot.utils import admin_cmd, sudo_cmd
11 |
12 |
13 | @borg.on(admin_cmd(pattern="mash ?(.*)"))
14 | async def _(event):
15 | if event.fwd_from:
16 | return
17 | input_str = event.pattern_match.group(1)
18 | reply_to_id = event.message
19 | if event.reply_to_msg_id:
20 | reply_to_id = await event.get_reply_message()
21 | chat = "@vixtbot"
22 | await event.edit("```Checking...```")
23 | async with event.client.conversation(chat) as conv:
24 | try:
25 | response = conv.wait_event(
26 | events.NewMessage(incoming=True, from_users=285336877)
27 | )
28 | await event.client.send_message(chat, "{}".format(input_str))
29 | response = await response
30 | except YouBlockedUserError:
31 | await event.reply("Unblock @vixtbot")
32 | return
33 | if response.text.startswith("I can't find that"):
34 | await event.edit("sorry i can't find it")
35 | else:
36 | await event.delete()
37 | await borg.send_file(event.chat_id, response.message, reply_to=reply_to_id)
38 |
39 |
40 | @borg.on(sudo_cmd(pattern="mash ?(.*)", allow_sudo=True))
41 | async def _(event):
42 | if event.fwd_from:
43 | return
44 | input_str = event.pattern_match.group(1)
45 | reply_to_id = event.message
46 | if event.reply_to_msg_id:
47 | reply_to_id = await event.get_reply_message()
48 | chat = "@vixtbot"
49 | await event.delete()
50 | async with event.client.conversation(chat) as conv:
51 | try:
52 | response = conv.wait_event(
53 | events.NewMessage(incoming=True, from_users=285336877)
54 | )
55 | await event.client.send_message(chat, "{}".format(input_str))
56 | response = await response
57 | except YouBlockedUserError:
58 | await event.reply("Unblock @vixtbot")
59 | return
60 | if response.text.startswith("I can't find that"):
61 | await event.reply("sorry i can't find it")
62 | else:
63 | await event.delete()
64 | await borg.send_file(event.chat_id, response.message, reply_to=reply_to_id)
65 |
66 |
67 | CMD_HELP.update(
68 | {
69 | "mashup": "`.mash` :\
70 | \n**USAGE:** Send you the related video message of given text . "
71 | }
72 | )
73 |
--------------------------------------------------------------------------------
/userbot/plugins/dagd.py:
--------------------------------------------------------------------------------
1 | """DA.GD helpers in @UniBorg
2 | Available Commands:
3 | .isup URL
4 | .dns google.com
5 | .url
6 | .unshort """
7 |
8 | import requests
9 |
10 | from userbot import CMD_HELP
11 |
12 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
13 |
14 |
15 | @borg.on(admin_cmd(pattern="dns (.*)"))
16 | @borg.on(sudo_cmd(pattern="dns (.*)", allow_sudo=True))
17 | async def _(event):
18 | if event.fwd_from:
19 | return
20 | input_str = event.pattern_match.group(1)
21 | sample_url = "https://da.gd/dns/{}".format(input_str)
22 | response_api = requests.get(sample_url).text
23 | if response_api:
24 | await edit_or_reply(
25 | event, "DNS records of {} are \n{}".format(input_str, response_api)
26 | )
27 | else:
28 | await edit_or_reply(
29 | event, "i can't seem to find {} on the internet".format(input_str)
30 | )
31 |
32 |
33 | @borg.on(admin_cmd(pattern="url (.*)"))
34 | @borg.on(sudo_cmd(pattern="url (.*)", allow_sudo=True))
35 | async def _(event):
36 | if event.fwd_from:
37 | return
38 | input_str = event.pattern_match.group(1)
39 | sample_url = "https://da.gd/s?url={}".format(input_str)
40 | response_api = requests.get(sample_url).text
41 | if response_api:
42 | await edit_or_reply(
43 | event, "Generated {} for {}.".format(response_api, input_str)
44 | )
45 | else:
46 | await edit_or_reply(event, "something is wrong. please try again later.")
47 |
48 |
49 | @borg.on(admin_cmd(pattern="unshort (.*)"))
50 | @borg.on(sudo_cmd(pattern="unshort (.*)", allow_sudo=True))
51 | async def _(event):
52 | if event.fwd_from:
53 | return
54 | input_str = event.pattern_match.group(1)
55 | if not input_str.startswith("http"):
56 | input_str = "http://" + input_str
57 | r = requests.get(input_str, allow_redirects=False)
58 | if str(r.status_code).startswith("3"):
59 | await edit_or_reply(
60 | event,
61 | "Input URL: {}\nReDirected URL: {}".format(
62 | input_str, r.headers["Location"]
63 | ),
64 | )
65 | else:
66 | await edit_or_reply(
67 | event,
68 | "Input URL {} returned status_code {}".format(input_str, r.status_code),
69 | )
70 |
71 |
72 | CMD_HELP.update(
73 | {
74 | "ping": "**Syntax :** `.dns link`\
75 | \n**Usage : **Shows you Domain Name System(dns) of the given link . example `.dns google.com` or `.dns github.cm`\
76 | \n\n**Syntax : **`.url link`\
77 | \n**Usage : **shortens the given link\
78 | \n\n**Syntax : **`.unshort link`\
79 | \n**Usage : **unshortens the given short link\
80 | "
81 | }
82 | )
83 |
--------------------------------------------------------------------------------
/userbot/plugins/sql_helper/antiflood_sql.py:
--------------------------------------------------------------------------------
1 | import threading
2 |
3 | from sqlalchemy import Column, Integer, String
4 |
5 | from userbot.plugins.sql_helper import BASE, SESSION
6 |
7 | DEF_COUNT = 0
8 | DEF_LIMIT = 0
9 | DEF_OBJ = (None, DEF_COUNT, DEF_LIMIT)
10 |
11 |
12 | class FloodControl(BASE):
13 | __tablename__ = "antiflood"
14 | chat_id = Column(String(14), primary_key=True)
15 | user_id = Column(Integer)
16 | count = Column(Integer, default=DEF_COUNT)
17 | limit = Column(Integer, default=DEF_LIMIT)
18 |
19 | def __init__(self, chat_id):
20 | self.chat_id = str(chat_id) # ensure string
21 |
22 | def __repr__(self):
23 | return "" % self.chat_id
24 |
25 |
26 | FloodControl.__table__.create(checkfirst=True)
27 |
28 | INSERTION_LOCK = threading.RLock()
29 |
30 | CHAT_FLOOD = {}
31 |
32 |
33 | def set_flood(chat_id, amount):
34 | with INSERTION_LOCK:
35 | flood = SESSION.query(FloodControl).get(str(chat_id))
36 | if not flood:
37 | flood = FloodControl(str(chat_id))
38 |
39 | flood.user_id = None
40 | flood.limit = amount
41 |
42 | CHAT_FLOOD[str(chat_id)] = (None, DEF_COUNT, amount)
43 |
44 | SESSION.add(flood)
45 | SESSION.commit()
46 |
47 |
48 | def update_flood(chat_id: str, user_id) -> bool:
49 | if str(chat_id) in CHAT_FLOOD:
50 | curr_user_id, count, limit = CHAT_FLOOD.get(str(chat_id), DEF_OBJ)
51 |
52 | if limit == 0: # no antiflood
53 | return False
54 |
55 | if user_id != curr_user_id or user_id is None: # other user
56 | CHAT_FLOOD[str(chat_id)] = (user_id, DEF_COUNT + 1, limit)
57 | return False
58 |
59 | count += 1
60 | if count > limit: # too many msgs, kick
61 | CHAT_FLOOD[str(chat_id)] = (None, DEF_COUNT, limit)
62 | return True
63 |
64 | # default -> update
65 | CHAT_FLOOD[str(chat_id)] = (user_id, count, limit)
66 | return False
67 |
68 |
69 | def get_flood_limit(chat_id):
70 | return CHAT_FLOOD.get(str(chat_id), DEF_OBJ)[2]
71 |
72 |
73 | def migrate_chat(old_chat_id, new_chat_id):
74 | with INSERTION_LOCK:
75 | flood = SESSION.query(FloodControl).get(str(old_chat_id))
76 | if flood:
77 | CHAT_FLOOD[str(new_chat_id)] = CHAT_FLOOD.get(str(old_chat_id), DEF_OBJ)
78 | flood.chat_id = str(new_chat_id)
79 | SESSION.commit()
80 |
81 | SESSION.close()
82 |
83 |
84 | def __load_flood_settings():
85 | global CHAT_FLOOD
86 | try:
87 | all_chats = SESSION.query(FloodControl).all()
88 | CHAT_FLOOD = {chat.chat_id: (None, DEF_COUNT, chat.limit) for chat in all_chats}
89 | finally:
90 | SESSION.close()
91 | return CHAT_FLOOD
92 |
--------------------------------------------------------------------------------
/userbot/plugins/antiflood.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 |
3 | from telethon.tl.functions.channels import EditBannedRequest
4 | from telethon.tl.types import ChatBannedRights
5 |
6 | import userbot.plugins.sql_helper.antiflood_sql as sql
7 |
8 | from .. import CMD_HELP
9 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
10 |
11 | CHAT_FLOOD = sql.__load_flood_settings()
12 | # warn mode for anti flood
13 | ANTI_FLOOD_WARN_MODE = ChatBannedRights(
14 | until_date=None, view_messages=None, send_messages=True
15 | )
16 |
17 |
18 | @borg.on(admin_cmd(incoming=True))
19 | async def _(event):
20 | if not CHAT_FLOOD:
21 | return
22 | if not (str(event.chat_id) in CHAT_FLOOD):
23 | return
24 | should_ban = sql.update_flood(event.chat_id, event.message.from_id)
25 | if not should_ban:
26 | return
27 | try:
28 | await event.client(
29 | EditBannedRequest(
30 | event.chat_id, event.message.from_id, ANTI_FLOOD_WARN_MODE
31 | )
32 | )
33 | except Exception as e: # pylint:disable=C0103,W0703
34 | no_admin_privilege_message = await event.client.send_message(
35 | entity=event.chat_id,
36 | message="""**Automatic AntiFlooder**
37 | @admin [User](tg://user?id={}) is flooding this chat.
38 | `{}`""".format(
39 | event.message.from_id, str(e)
40 | ),
41 | reply_to=event.message.id,
42 | )
43 | await asyncio.sleep(10)
44 | await no_admin_privilege_message.edit(
45 | "This is useless SPAM dude . stop this enjoy chat man ", link_preview=False
46 | )
47 | else:
48 | await event.client.send_message(
49 | entity=event.chat_id,
50 | message="""**Automatic AntiFlooder**
51 | [User](tg://user?id={}) has been automatically restricted
52 | because he reached the defined flood limit.""".format(
53 | event.message.from_id
54 | ),
55 | reply_to=event.message.id,
56 | )
57 |
58 |
59 | @borg.on(admin_cmd(pattern="setflood(?: |$)(.*)"))
60 | @borg.on(sudo_cmd(pattern="setflood(?: |$)(.*)", allow_sudo=True))
61 | async def _(event):
62 | input_str = event.pattern_match.group(1)
63 | event = await edit_or_reply(event, "updating flood settings!")
64 | try:
65 | sql.set_flood(event.chat_id, input_str)
66 | sql.__load_flood_settings()
67 | await event.edit(
68 | "Antiflood updated to {} in the current chat".format(input_str)
69 | )
70 | except Exception as e: # pylint:disable=C0103,W0703
71 | await event.edit(str(e))
72 |
73 |
74 | CMD_HELP.update(
75 | {
76 | "antiflood": ".setflood [number]\
77 | \nUsage: warns the user if he spams the chat if you are admin mutes him in that group .\
78 | "
79 | }
80 | )
81 |
--------------------------------------------------------------------------------
/userbot/plugins/randomsticker.py:
--------------------------------------------------------------------------------
1 | # This Source Code Form is subject to the terms of the Mozilla Public
2 | # License, v. 2.0. If a copy of the MPL was not distributed with this
3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 |
5 | """ Command: .dab , .brain
6 | credit: lejend @r4v4n4
7 | """
8 | import random
9 | from os import remove
10 | from random import choice
11 | from urllib import parse
12 |
13 | import requests
14 | from telethon import events, functions, types, utils
15 |
16 | from userbot.utils import admin_cmd
17 |
18 | BASE_URL = "https://headp.at/pats/{}"
19 | PAT_IMAGE = "pat.jpg"
20 |
21 |
22 | def choser(cmd, pack, blacklist={}):
23 | docs = None
24 |
25 | @borg.on(events.NewMessage(pattern=rf"\.{cmd}", outgoing=True))
26 | async def handler(event):
27 | await event.delete()
28 | nonlocal docs
29 | if docs is None:
30 | docs = [
31 | utils.get_input_document(x)
32 | for x in (
33 | await borg(
34 | functions.messages.GetStickerSetRequest(
35 | types.InputStickerSetShortName(pack)
36 | )
37 | )
38 | ).documents
39 | if x.id not in blacklist
40 | ]
41 | await event.respond(file=random.choice(docs))
42 |
43 |
44 | choser("brain", "supermind")
45 | choser(
46 | "dab",
47 | "DabOnHaters",
48 | {
49 | 1653974154589768377,
50 | 1653974154589768312,
51 | 1653974154589767857,
52 | 1653974154589768311,
53 | 1653974154589767816,
54 | 1653974154589767939,
55 | 1653974154589767944,
56 | 1653974154589767912,
57 | 1653974154589767911,
58 | 1653974154589767910,
59 | 1653974154589767909,
60 | 1653974154589767863,
61 | 1653974154589767852,
62 | 1653974154589768677,
63 | },
64 | )
65 |
66 | # HeadPat Module for Userbot (http://headp.at)
67 | # cmd:- .pat username or reply to msg
68 | # By:- git: jaskaranSM tg: @Zero_cool7870
69 |
70 |
71 | @borg.on(admin_cmd(pattern="pat ?(.*)", outgoing=True))
72 | async def lastfm(event):
73 | if event.fwd_from:
74 | return
75 | username = event.pattern_match.group(1)
76 | if not username and not event.reply_to_msg_id:
77 | await event.edit("`Reply to a message or provide username`")
78 | return
79 | resp = requests.get("http://headp.at/js/pats.json")
80 | pats = resp.json()
81 | pat = BASE_URL.format(parse.quote(choice(pats)))
82 | await event.delete()
83 | with open(PAT_IMAGE, "wb") as f:
84 | f.write(requests.get(pat).content)
85 | if username:
86 | await borg.send_file(event.chat_id, PAT_IMAGE, caption=username)
87 | else:
88 | await borg.send_file(event.chat_id, PAT_IMAGE, reply_to=event.reply_to_msg_id)
89 | remove(PAT_IMAGE)
90 |
--------------------------------------------------------------------------------
/userbot/plugins/warnbun.py:
--------------------------------------------------------------------------------
1 | """.admin Plugin for @UniBorg"""
2 | import html
3 |
4 | import userbot.plugins.sql_helper.warns_sql as sql
5 |
6 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
7 |
8 |
9 | @borg.on(admin_cmd(pattern="warn (.*)"))
10 | @borg.on(sudo_cmd(pattern="warn (.*)", allow_sudo=True))
11 | async def _(event):
12 | if event.fwd_from:
13 | return
14 | warn_reason = event.pattern_match.group(1)
15 | reply_message = await event.get_reply_message()
16 | limit, soft_warn = sql.get_warn_setting(event.chat_id)
17 | num_warns, reasons = sql.warn_user(
18 | reply_message.from_id, event.chat_id, warn_reason
19 | )
20 | if num_warns >= limit:
21 | sql.reset_warns(reply_message.from_id, event.chat_id)
22 | if soft_warn:
23 | logger.info("TODO: kick user")
24 | reply = "{} warnings, [user](tg://user?id={}) has to bee kicked!".format(
25 | limit, reply_message.from_id
26 | )
27 | else:
28 | logger.info("TODO: ban user")
29 | reply = "{} warnings, [user](tg://user?id={}) has to bee banned!".format(
30 | limit, reply_message.from_id
31 | )
32 | else:
33 | reply = "[user](tg://user?id={}) has {}/{} warnings... watch out!".format(
34 | reply_message.from_id, num_warns, limit
35 | )
36 | if warn_reason:
37 | reply += "\nReason for last warn:\n{}".format(html.escape(warn_reason))
38 | await edit_or_reply(event, reply)
39 |
40 |
41 | @borg.on(admin_cmd(pattern="get_warns$"))
42 | @borg.on(sudo_cmd(pattern="get_warns$", allow_sudo=True))
43 | async def _(event):
44 | if event.fwd_from:
45 | return
46 | reply_message = await event.get_reply_message()
47 | result = sql.get_warns(reply_message.from_id, event.chat_id)
48 | if result and result[0] != 0:
49 | num_warns, reasons = result
50 | limit, soft_warn = sql.get_warn_setting(event.chat_id)
51 | if reasons:
52 | text = "This user has {}/{} warnings, for the following reasons:".format(
53 | num_warns, limit
54 | )
55 | text += "\r\n"
56 | text += reasons
57 | await event.edit(text)
58 | else:
59 | await edit_or_reply(
60 | event,
61 | "this user has {} / {} warning, but no reasons for any of them.".format(
62 | num_warns, limit
63 | ),
64 | )
65 | else:
66 | await edit_or_reply(event, "this user hasn't got any warnings!")
67 |
68 |
69 | @borg.on(admin_cmd(pattern="reset_warns$"))
70 | @borg.on(sudo_cmd(pattern="reset_warns$", allow_sudo=True))
71 | async def _(event):
72 | if event.fwd_from:
73 | return
74 | reply_message = await event.get_reply_message()
75 | sql.reset_warns(reply_message.from_id, event.chat_id)
76 | await edit_or_reply(event, "Warnings have been reset!")
77 |
--------------------------------------------------------------------------------
/userbot/plugins/gps.py:
--------------------------------------------------------------------------------
1 | """Syntax : .gps
2 | help from @sunda005 and @SpEcHIDe
3 | credits :@mrconfused
4 | don't edit credits"""
5 | # Copyright (C) 2020 sandeep.n(π.$)
6 | # This program is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU Affero General Public License as
8 | # published by the Free Software Foundation, either version 3 of the
9 | # License, or (at your option) any later version.
10 | # This program is distributed in the hope that it will be useful,
11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 | # GNU Affero General Public License for more details.
14 | # You should have received a copy of the GNU Affero General Public License
15 | # along with this program. If not, see .
16 | from geopy.geocoders import Nominatim
17 | from telethon.tl import types
18 |
19 | from userbot import CMD_HELP
20 | from userbot.utils import admin_cmd, sudo_cmd
21 |
22 |
23 | @borg.on(admin_cmd(pattern="gps ?(.*)"))
24 | async def gps(event):
25 | if event.fwd_from:
26 | return
27 | reply_to_id = event.message
28 | if event.reply_to_msg_id:
29 | reply_to_id = await event.get_reply_message()
30 | input_str = event.pattern_match.group(1)
31 |
32 | if not input_str:
33 | return await event.edit("what should i find give me location.")
34 |
35 | await event.edit("finding")
36 |
37 | geolocator = Nominatim(user_agent="catuserbot")
38 | geoloc = geolocator.geocode(input_str)
39 |
40 | if geoloc:
41 | lon = geoloc.longitude
42 | lat = geoloc.latitude
43 | await reply_to_id.reply(
44 | input_str, file=types.InputMediaGeoPoint(types.InputGeoPoint(lat, lon))
45 | )
46 | await event.delete()
47 | else:
48 | await event.edit("i coudn't find it")
49 |
50 |
51 | @borg.on(sudo_cmd(pattern="gps ?(.*)", allow_sudo=True))
52 | async def gps(event):
53 | if event.fwd_from:
54 | return
55 | reply_to_id = event.message
56 | if event.reply_to_msg_id:
57 | reply_to_id = await event.get_reply_message()
58 | input_str = event.pattern_match.group(1)
59 |
60 | if not input_str:
61 | return await event.reply("what should i find give me location.")
62 |
63 | cat = await event.reply("finding")
64 |
65 | geolocator = Nominatim(user_agent="catuserbot")
66 | geoloc = geolocator.geocode(input_str)
67 |
68 | if geoloc:
69 | lon = geoloc.longitude
70 | lat = geoloc.latitude
71 | await reply_to_id.reply(
72 | input_str, file=types.InputMediaGeoPoint(types.InputGeoPoint(lat, lon))
73 | )
74 | await cat.delete()
75 | else:
76 | await cat.edit("i coudn't find it")
77 |
78 |
79 | CMD_HELP.update(
80 | {
81 | "gps": "`.gps` :\
82 | \nUSAGE: sends you the given location name\
83 | "
84 | }
85 | )
86 |
--------------------------------------------------------------------------------
/userbot/plugins/hash.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2019 The Raphielscape Company LLC.
2 | #
3 | # Licensed under the Raphielscape Public License, Version 1.c (the "License");
4 | # you may not use this file except in compliance with the License.
5 | #
6 | """ Userbot module containing hash and encode/decode commands. """
7 |
8 | from subprocess import PIPE
9 | from subprocess import run as runapp
10 |
11 | import pybase64
12 |
13 | from userbot import CMD_HELP
14 | from userbot.utils import admin_cmd, errors_handler
15 |
16 |
17 | @borg.on(admin_cmd(outgoing=True, pattern="hash (.*)"))
18 | @errors_handler
19 | async def gethash(hash_q):
20 | """ For .hash command, find the md5, sha1, sha256, sha512 of the string. """
21 | hashtxt_ = hash_q.pattern_match.group(1)
22 | hashtxt = open("hashdis.txt", "w+")
23 | hashtxt.write(hashtxt_)
24 | hashtxt.close()
25 | md5 = runapp(["md5sum", "hashdis.txt"], stdout=PIPE)
26 | md5 = md5.stdout.decode()
27 | sha1 = runapp(["sha1sum", "hashdis.txt"], stdout=PIPE)
28 | sha1 = sha1.stdout.decode()
29 | sha256 = runapp(["sha256sum", "hashdis.txt"], stdout=PIPE)
30 | sha256 = sha256.stdout.decode()
31 | sha512 = runapp(["sha512sum", "hashdis.txt"], stdout=PIPE)
32 | runapp(["rm", "hashdis.txt"], stdout=PIPE)
33 | sha512 = sha512.stdout.decode()
34 | ans = (
35 | "Text: `"
36 | + hashtxt_
37 | + "`\nMD5: `"
38 | + md5
39 | + "`SHA1: `"
40 | + sha1
41 | + "`SHA256: `"
42 | + sha256
43 | + "`SHA512: `"
44 | + sha512[:-1]
45 | + "`"
46 | )
47 | if len(ans) > 4096:
48 | hashfile = open("hashes.txt", "w+")
49 | hashfile.write(ans)
50 | hashfile.close()
51 | await hash_q.client.send_file(
52 | hash_q.chat_id,
53 | "hashes.txt",
54 | reply_to=hash_q.id,
55 | caption="`It's too big, sending a text file instead. `",
56 | )
57 | runapp(["rm", "hashes.txt"], stdout=PIPE)
58 | else:
59 | await hash_q.reply(ans)
60 |
61 |
62 | @borg.on(admin_cmd(outgoing=True, pattern="hbase (en|de) (.*)"))
63 | @errors_handler
64 | async def endecrypt(query):
65 | """ For .base64 command, find the base64 encoding of the given string. """
66 | if query.pattern_match.group(1) == "en":
67 | lething = str(pybase64.b64encode(bytes(query.pattern_match.group(2), "utf-8")))[
68 | 2:
69 | ]
70 | await query.reply("Shhh! It's Encoded: `" + lething[:-1] + "`")
71 | else:
72 | lething = str(
73 | pybase64.b64decode(
74 | bytes(query.pattern_match.group(2), "utf-8"), validate=True
75 | )
76 | )[2:]
77 | await query.reply("Decoded: `" + lething[:-1] + "`")
78 |
79 |
80 | CMD_HELP.update(
81 | {
82 | "hash": ".hbase en or .hbase de \nUsage: Find the base64 encoding of the given string\
83 | \n\n.hash\nUsage: Find the md5, sha1, sha256, sha512 of the string when written into a txt file."
84 | }
85 | )
86 |
--------------------------------------------------------------------------------
/userbot/plugins/speedtest.py:
--------------------------------------------------------------------------------
1 | """Check your internet speed powered by speedtest.net
2 | Syntax: .speedtest
3 | Available Options: image, file, text"""
4 | from datetime import datetime
5 |
6 | import speedtest
7 |
8 | from userbot.utils import admin_cmd
9 |
10 |
11 | @borg.on(admin_cmd(pattern="speedtest ?(.*)"))
12 | async def _(event):
13 | if event.fwd_from:
14 | return
15 | input_str = event.pattern_match.group(1)
16 | as_text = True
17 | as_document = False
18 | if input_str == "image":
19 | as_document = False
20 | elif input_str == "file":
21 | as_document = True
22 | elif input_str == "text":
23 | as_text = True
24 | await event.edit("`Calculating my internet speed. Please wait!`")
25 | start = datetime.now()
26 | s = speedtest.Speedtest()
27 | s.get_best_server()
28 | s.download()
29 | s.upload()
30 | end = datetime.now()
31 | ms = (end - start).microseconds / 1000
32 | response = s.results.dict()
33 | download_speed = response.get("download")
34 | upload_speed = response.get("upload")
35 | ping_time = response.get("ping")
36 | client_infos = response.get("client")
37 | i_s_p = client_infos.get("isp")
38 | i_s_p_rating = client_infos.get("isprating")
39 | reply_msg_id = event.message.id
40 | if event.reply_to_msg_id:
41 | reply_msg_id = event.reply_to_msg_id
42 | try:
43 | response = s.results.share()
44 | speedtest_image = response
45 | if as_text:
46 | await event.edit(
47 | """`SpeedTest completed in {} seconds`
48 |
49 | `Download: {}`
50 | `Upload: {}`
51 | `Ping: {}`
52 | `Internet Service Provider: {}`
53 | `ISP Rating: {}`""".format(
54 | ms,
55 | convert_from_bytes(download_speed),
56 | convert_from_bytes(upload_speed),
57 | ping_time,
58 | i_s_p,
59 | i_s_p_rating,
60 | )
61 | )
62 | else:
63 | await borg.send_file(
64 | event.chat_id,
65 | speedtest_image,
66 | caption="**SpeedTest** completed in {} seconds".format(ms),
67 | force_document=as_document,
68 | reply_to=reply_msg_id,
69 | allow_cache=False,
70 | )
71 | await event.delete()
72 | except Exception as exc:
73 | await event.edit(
74 | """**SpeedTest** completed in {} seconds
75 | Download: {}
76 | Upload: {}
77 | Ping: {}
78 |
79 | __With the Following ERRORs__
80 | {}""".format(
81 | ms,
82 | convert_from_bytes(download_speed),
83 | convert_from_bytes(upload_speed),
84 | ping_time,
85 | str(exc),
86 | )
87 | )
88 |
89 |
90 | def convert_from_bytes(size):
91 | power = 2 ** 10
92 | n = 0
93 | units = {0: "", 1: "kilobytes", 2: "megabytes", 3: "gigabytes", 4: "terabytes"}
94 | while size > power:
95 | size /= power
96 | n += 1
97 | return f"{round(size, 2)} {units[n]}"
98 |
--------------------------------------------------------------------------------
/userbot/plugins/gdrive_download.py:
--------------------------------------------------------------------------------
1 | """
2 | G-Drive File Downloader Plugin For Userbot.
3 | usage: .gdl File-Link
4 | By: @Zero_cool7870
5 |
6 | """
7 | import requests
8 |
9 | from userbot import CMD_HELP
10 | from userbot.utils import admin_cmd
11 |
12 |
13 | async def download_file_from_google_drive(id):
14 | URL = "https://docs.google.com/uc?export=download"
15 |
16 | session = requests.Session()
17 |
18 | response = session.get(URL, params={"id": id}, stream=True)
19 | token = await get_confirm_token(response)
20 | if token:
21 | params = {"id": id, "confirm": token}
22 | response = session.get(URL, params=params, stream=True)
23 |
24 | headers = response.headers
25 | content = headers["Content-Disposition"]
26 | destination = await get_file_name(content)
27 |
28 | file_name = await save_response_content(response, destination)
29 | return file_name
30 |
31 |
32 | async def get_confirm_token(response):
33 | for key, value in response.cookies.items():
34 | if key.startswith("download_warning"):
35 | return value
36 |
37 | return None
38 |
39 |
40 | async def save_response_content(response, destination):
41 | CHUNK_SIZE = 32768
42 | with open(destination, "wb") as f:
43 | for chunk in response.iter_content(CHUNK_SIZE):
44 | if chunk: # filter out keep-alive new chunks
45 | f.write(chunk)
46 | return destination
47 |
48 |
49 | async def get_id(link): # Extract File Id from G-Drive Link
50 | file_id = ""
51 | c_append = False
52 | if link[1:33] == "https://drive.google.com/file/d/":
53 | link = link[33:]
54 | fid = ""
55 | for c in link:
56 | if c == "/":
57 | break
58 | fid = fid + c
59 | return fid
60 | for c in link:
61 | if c == "=":
62 | c_append = True
63 | if c == "&":
64 | break
65 | if c_append:
66 | file_id = file_id + c
67 | file_id = file_id[1:]
68 | return file_id
69 |
70 |
71 | async def get_file_name(content):
72 | file_name = ""
73 | c_append = False
74 | for c in str(content):
75 | if c == '"':
76 | c_append = True
77 | if c == ";":
78 | c_append = False
79 | if c_append:
80 | file_name = file_name + c
81 | file_name = file_name.replace('"', "")
82 | print("File Name: " + str(file_name))
83 | return file_name
84 |
85 |
86 | @borg.on(admin_cmd(pattern=f"gdl (.*)", outgoing=True))
87 | async def g_download(event):
88 | if event.fwd_from:
89 | return
90 | drive_link = event.text[4:]
91 | file_id = await get_id(drive_link)
92 | await event.edit("Downloading Requested File from G-Drive...")
93 | file_name = await download_file_from_google_drive(file_id)
94 | await event.edit("File Downloaded.\nName: `" + str(file_name) + "`")
95 |
96 |
97 | CMD_HELP.update(
98 | {
99 | "gdrive_download": ".gdl \
100 | \nUsage:G-Drive File Downloader Plugin For Userbot."
101 | }
102 | )
103 |
--------------------------------------------------------------------------------
/userbot/plugins/tts.py:
--------------------------------------------------------------------------------
1 | """ Google Text to Speech
2 | Available Commands:
3 | .tts LanguageCode as reply to a message
4 | .tts LangaugeCode | text to speak"""
5 | import asyncio
6 | import os
7 | import subprocess
8 | from datetime import datetime
9 |
10 | from gtts import gTTS
11 |
12 | from .. import CMD_HELP
13 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
14 | from . import deEmojify
15 |
16 |
17 | @borg.on(admin_cmd(pattern="tts (.*)"))
18 | @borg.on(sudo_cmd(pattern="tts (.*)", allow_sudo=True))
19 | async def _(event):
20 | if event.fwd_from:
21 | return
22 | input_str = event.pattern_match.group(1)
23 | start = datetime.now()
24 | if event.reply_to_msg_id:
25 | previous_message = await event.get_reply_message()
26 | text = previous_message.message
27 | lan = input_str
28 | elif "|" in input_str:
29 | lan, text = input_str.split("|")
30 | else:
31 | await edit_or_reply(event, "Invalid Syntax. Module stopping.")
32 | return
33 | text = deEmojify(text.strip())
34 | lan = lan.strip()
35 | if not os.path.isdir("./temp/"):
36 | os.makedirs("./temp/")
37 | required_file_name = "./temp/" + "voice.ogg"
38 | try:
39 | # https://github.com/SpEcHiDe/UniBorg/commit/17f8682d5d2df7f3921f50271b5b6722c80f4106
40 | tts = gTTS(text, lang=lan)
41 | tts.save(required_file_name)
42 | command_to_execute = [
43 | "ffmpeg",
44 | "-i",
45 | required_file_name,
46 | "-map",
47 | "0:a",
48 | "-codec:a",
49 | "libopus",
50 | "-b:a",
51 | "100k",
52 | "-vbr",
53 | "on",
54 | required_file_name + ".opus",
55 | ]
56 | try:
57 | t_response = subprocess.check_output(
58 | command_to_execute, stderr=subprocess.STDOUT
59 | )
60 | except (subprocess.CalledProcessError, NameError, FileNotFoundError) as exc:
61 | await event.edit(str(exc))
62 | # continue sending required_file_name
63 | else:
64 | os.remove(required_file_name)
65 | required_file_name = required_file_name + ".opus"
66 | end = datetime.now()
67 | ms = (end - start).seconds
68 | await borg.send_file(
69 | event.chat_id,
70 | required_file_name,
71 | # caption="Processed {} ({}) in {} seconds!".format(text[0:97], lan, ms),
72 | reply_to=event.message.reply_to_msg_id,
73 | allow_cache=False,
74 | voice_note=True,
75 | )
76 | os.remove(required_file_name)
77 | event = await edit_or_reply(
78 | event, "Processed {} ({}) in {} seconds!".format(text[0:97], lan, ms)
79 | )
80 | await asyncio.sleep(5)
81 | await event.delete()
82 | except Exception as e:
83 | await edit_or_reply(event, str(e))
84 |
85 |
86 | CMD_HELP.update(
87 | {
88 | "tts": "**Plugin :** `tts`\
89 | \n\nAvailable Commands:\
90 | \n.tts LanguageCode as reply to a message\
91 | \n.tts LangaugeCode | text to speak\
92 | "
93 | }
94 | )
95 |
--------------------------------------------------------------------------------
/userbot/plugins/stt.py:
--------------------------------------------------------------------------------
1 | """Speech to Text
2 | Syntax: .stt as reply to a speech message"""
3 | import os
4 | from datetime import datetime
5 |
6 | import requests
7 |
8 | from userbot.utils import admin_cmd
9 |
10 |
11 | @borg.on(admin_cmd(pattern="stt (.*)"))
12 | async def _(event):
13 | if event.fwd_from:
14 | return
15 | start = datetime.now()
16 | input_str = event.pattern_match.group(1)
17 | if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY):
18 | os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY)
19 | await event.edit("Downloading to my local, for analysis 🙇")
20 | if event.reply_to_msg_id:
21 | previous_message = await event.get_reply_message()
22 | required_file_name = await borg.download_media(
23 | previous_message, Config.TMP_DOWNLOAD_DIRECTORY
24 | )
25 | lan = input_str
26 | if (
27 | Config.IBM_WATSON_CRED_URL is None
28 | or Config.IBM_WATSON_CRED_PASSWORD is None
29 | ):
30 | await event.edit(
31 | "You need to set the required ENV variables for this module. \nModule stopping"
32 | )
33 | else:
34 | await event.edit("Starting analysis, using IBM WatSon Speech To Text")
35 | headers = {
36 | "Content-Type": previous_message.media.document.mime_type,
37 | }
38 | data = open(required_file_name, "rb").read()
39 | response = requests.post(
40 | Config.IBM_WATSON_CRED_URL + "/v1/recognize",
41 | headers=headers,
42 | data=data,
43 | auth=("apikey", Config.IBM_WATSON_CRED_PASSWORD),
44 | )
45 | r = response.json()
46 | if "results" in r:
47 | # process the json to appropriate string format
48 | results = r["results"]
49 | transcript_response = ""
50 | transcript_confidence = ""
51 | for alternative in results:
52 | alternatives = alternative["alternatives"][0]
53 | transcript_response += " " + str(alternatives["transcript"]) + " + "
54 | transcript_confidence += (
55 | " " + str(alternatives["confidence"]) + " + "
56 | )
57 | end = datetime.now()
58 | ms = (end - start).seconds
59 | if transcript_response != "":
60 | string_to_show = "Language: `{}`\nTRANSCRIPT: `{}`\nTime Taken: {} seconds\nConfidence: `{}`".format(
61 | lan, transcript_response, ms, transcript_confidence
62 | )
63 | else:
64 | string_to_show = "Language: `{}`\nTime Taken: {} seconds\n**No Results Found**".format(
65 | lan, ms
66 | )
67 | await event.edit(string_to_show)
68 | else:
69 | await event.edit(r["error"])
70 | # now, remove the temporary file
71 | os.remove(required_file_name)
72 | else:
73 | await event.edit("Reply to a voice message, to get the relevant transcript.")
74 |
--------------------------------------------------------------------------------
/userbot/plugins/greetings.py:
--------------------------------------------------------------------------------
1 | from ..utils import admin_cmd
2 |
3 |
4 | @borg.on(admin_cmd(pattern="gnt$"))
5 | async def gn(event):
6 | await event.edit(
7 | "。♥。・゚♡゚・。♥。・。・。・。♥。・\n╱╱╱╱╱╱╱╭╮╱╱╱╭╮╱╭╮╭╮\n╭━┳━┳━┳╯┃╭━┳╋╋━┫╰┫╰╮\n┃╋┃╋┃╋┃╋┃┃┃┃┃┃╋┃┃┃╭┫\n┣╮┣━┻━┻━╯╰┻━┻╋╮┣┻┻━╯\n╰━╯╱╱╱╱╱╱╱╱╱╱╰━╯\n。♥。・゚♡゚・。♥° ♥。・゚♡゚・"
8 | )
9 |
10 |
11 | @borg.on(admin_cmd(pattern="gmg$"))
12 | async def gm(event):
13 | await event.edit(
14 | "。♥。・゚♡゚・。♥。・。・。・。♥。・。♥。・゚♡゚・\n╱╱╱╱╱╱╱╭╮╱╱╱╱╱╱╱╱╱╱╭╮\n╭━┳━┳━┳╯┃╭━━┳━┳┳┳━┳╋╋━┳┳━╮\n┃╋┃╋┃╋┃╋┃┃┃┃┃╋┃╭┫┃┃┃┃┃┃┃╋┃\n┣╮┣━┻━┻━╯╰┻┻┻━┻╯╰┻━┻┻┻━╋╮┃\n╰━╯╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰━╯\n。♥。・゚♡゚・。♥。・。・。・。♥。・。♥。・゚♡゚・"
15 | )
16 |
17 |
18 | # by @Halto_Tha
19 | @borg.on(admin_cmd(pattern=r"lmoon$"))
20 | async def test(event):
21 | if event.fwd_from:
22 | return
23 | await event.edit(
24 | "🌕🌕🌕🌕🌕🌕🌕🌕\n🌕🌕🌖🌔🌖🌔🌕🌕\n🌕🌕🌗🌔🌖🌓🌕🌕\n🌕🌕🌗🌔🌖🌓🌕🌕\n🌕🌕🌖🌓🌗🌔🌕🌕\n🌕🌕🌗🌑🌑🌓🌕🌕\n🌕🌕🌗👀🌑🌓🌕🌕\n🌕🌕🌘👄🌑🌓🌕🌕\n🌕🌕🌗🌑🌑🌒🌕🌕\n🌕🌖🌑🌑🌑🌑🌔🌕\n🌕🌘🌑🌑🌑🌑🌒🌕\n🌖🌑🌑🌑🌑🌑🌑🌔\n🌕🤜🏻🌑🌑🌑🌑🤛🏻🌕\n🌕🌖🌑🌑🌑🌑🌔🌕\n🌘🌑🌑🌑🌑🌑🌑🌒\n🌕🌕🌕🌕🌕🌕🌕🌕"
25 | )
26 |
27 |
28 | @borg.on(admin_cmd(pattern=r"city$"))
29 | async def test(event):
30 | if event.fwd_from:
31 | return
32 | await event.edit(
33 | """☁☁🌞 ☁ ☁
34 | ☁ ✈ ☁ 🚁 ☁ ☁ ☁ ☁ ☁ ☁
35 | 🏬🏨🏫🏢🏤🏥🏦🏪🏫
36 | 🌲/ l🚍\🌳👭
37 | 🌳/ 🚘 l 🏃 \🌴 👬 👬 🌴/ l 🚔 \🌲
38 | 🌲/ 🚖 l \
39 | 🌳/🚶 | 🚍 \ 🌴🚴🚴
40 | 🌴/ | \🌲"""
41 | )
42 |
43 |
44 | # @PhycoNinja13b 's Part begin from here
45 |
46 |
47 | @borg.on(admin_cmd(pattern=r"hi ?(.*)"))
48 | async def hi(event):
49 | giveVar = event.text
50 | cat = giveVar[4:5]
51 | if not cat:
52 | cat = "🌺"
53 | await event.edit(
54 | f"{cat}✨✨{cat}✨{cat}{cat}{cat}\n{cat}✨✨{cat}✨✨{cat}✨\n{cat}{cat}{cat}{cat}✨✨{cat}✨\n{cat}✨✨{cat}✨✨{cat}✨\n{cat}✨✨{cat}✨{cat}{cat}{cat}\n☁☁☁☁☁☁☁☁"
55 | )
56 |
57 |
58 | @borg.on(admin_cmd(pattern=r"cheer$"))
59 | async def cheer(event):
60 | if event.fwd_from:
61 | return
62 | await event.edit(
63 | "💐💐😉😊💐💐\n☕ Cheer Up 🍵\n🍂 ✨ )) ✨ 🍂\n🍂┃ (( * ┣┓ 🍂\n🍂┃*💗 ┣┛ 🍂 \n🍂┗━━┛ 🍂🎂 For YOU 🍰\n💐💐😌😚💐💐"
64 | )
65 |
66 |
67 | @borg.on(admin_cmd(pattern=r"getwell$"))
68 | async def getwell(event):
69 | if event.fwd_from:
70 | return
71 | await event.edit("🌹🌹🌹🌹🌹🌹🌹🌹 \n🌹😷😢😓😷😢💨🌹\n🌹💝💉🍵💊💐💝🌹\n🌹 GetBetter Soon! 🌹\n🌹🌹🌹🌹🌹🌹🌹🌹")
72 |
73 |
74 | @borg.on(admin_cmd(pattern=r"luck$"))
75 | async def luck(event):
76 | if event.fwd_from:
77 | return
78 | await event.edit(
79 | "💚~🍀🍀🍀🍀🍀\n🍀╔╗╔╗╔╗╦╗✨🍀\n🍀║╦║║║║║║👍🍀\n🍀╚╝╚╝╚╝╩╝。 🍀\n🍀・・ⓁⓊⒸⓀ🍀\n🍀🍀🍀 to you💚"
80 | )
81 |
82 |
83 | @borg.on(admin_cmd(pattern=r"sprinkle$"))
84 | async def sprinkle(event):
85 | if event.fwd_from:
86 | return
87 | await event.edit(
88 | "✨.•*¨*.¸.•*¨*.¸¸.•*¨*• ƸӜƷ\n🌸🌺🌸🌺🌸🌺🌸🌺\n Sprinkled with love❤\n🌷🌻🌷🌻🌷🌻🌷🌻\n ¨*.¸.•*¨*. ¸.•*¨*.¸¸.•*¨`*•.✨\n🌹🍀🌹🍀🌹🍀🌹🍀"
89 | )
90 |
--------------------------------------------------------------------------------
/userbot/plugins/create.py:
--------------------------------------------------------------------------------
1 | """Create Private Groups
2 | Available Commands:
3 | .create (b|g) GroupName"""
4 | from telethon.tl import functions
5 |
6 | from .. import CMD_HELP
7 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
8 |
9 |
10 | @borg.on(admin_cmd(pattern="create (b|g|c) (.*)")) # pylint:disable=E0602
11 | @borg.on(sudo_cmd(pattern="create (b|g|c) (.*)", allow_sudo=True))
12 | async def _(event):
13 | if event.fwd_from:
14 | return
15 | type_of_group = event.pattern_match.group(1)
16 | group_name = event.pattern_match.group(2)
17 | event = await edit_or_reply(event, "creating......")
18 | if type_of_group == "b":
19 | try:
20 | result = await borg(
21 | functions.messages.CreateChatRequest( # pylint:disable=E0602
22 | users=["@sarah_robot"],
23 | # Not enough users (to create a chat, for example)
24 | # Telegram, no longer allows creating a chat with ourselves
25 | title=group_name,
26 | )
27 | )
28 | created_chat_id = result.chats[0].id
29 | await borg(
30 | functions.messages.DeleteChatUserRequest(
31 | chat_id=created_chat_id, user_id="@sarah_robot"
32 | )
33 | )
34 | result = await borg(
35 | functions.messages.ExportChatInviteRequest(
36 | peer=created_chat_id,
37 | )
38 | )
39 | await event.edit(
40 | "Group `{}` created successfully. Join {}".format(
41 | group_name, result.link
42 | )
43 | )
44 | except Exception as e: # pylint:disable=C0103,W0703
45 | await event.edit(str(e))
46 | elif type_of_group == "g" or type_of_group == "c":
47 | try:
48 | r = await borg(
49 | functions.channels.CreateChannelRequest( # pylint:disable=E0602
50 | title=group_name,
51 | about="This is a Test from @mrconfused",
52 | megagroup=False if type_of_group == "c" else True,
53 | )
54 | )
55 | created_chat_id = r.chats[0].id
56 | result = await borg(
57 | functions.messages.ExportChatInviteRequest(
58 | peer=created_chat_id,
59 | )
60 | )
61 | await event.edit(
62 | "Channel `{}` created successfully. Join {}".format(
63 | group_name, result.link
64 | )
65 | )
66 | except Exception as e: # pylint:disable=C0103,W0703
67 | await event.edit(str(e))
68 | else:
69 | await event.edit("Read `.info create` to know how to use me")
70 |
71 |
72 | CMD_HELP.update(
73 | {
74 | "create": "**SYNTAX :** `.create b`\
75 | \n**USAGE : **Creates a super group and send you link\
76 | \n\n**SYNTAX : **`.create g`\
77 | \n**USAGE : **Creates a private group and sends you link\
78 | \n\n**SYNTAX : **`.create c`\
79 | \n**USAGE : **Creates a Channel and sends you link\
80 | \n\nhere the bot accout is owner\
81 | "
82 | }
83 | )
84 |
--------------------------------------------------------------------------------
/userbot/plugins/invite.py:
--------------------------------------------------------------------------------
1 | """Invite the user(s) to the current chat
2 | Syntax: .invite """
3 |
4 | from telethon import functions
5 |
6 | from userbot.utils import admin_cmd, sudo_cmd
7 |
8 |
9 | @borg.on(admin_cmd(pattern="invite ?(.*)"))
10 | async def _(event):
11 | if event.fwd_from:
12 | return
13 | to_add_users = event.pattern_match.group(1)
14 | if event.is_private:
15 | await event.edit("`.invite` users to a chat, not to a Private Message")
16 | else:
17 | logger.info(to_add_users)
18 | if not event.is_channel and event.is_group:
19 | # https://lonamiwebs.github.io/Telethon/methods/messages/add_chat_user.html
20 | for user_id in to_add_users.split(" "):
21 | try:
22 | await borg(
23 | functions.messages.AddChatUserRequest(
24 | chat_id=event.chat_id, user_id=user_id, fwd_limit=1000000
25 | )
26 | )
27 | except Exception as e:
28 | await event.reply(str(e))
29 | await event.edit("Invited Successfully")
30 | else:
31 | # https://lonamiwebs.github.io/Telethon/methods/channels/invite_to_channel.html
32 | for user_id in to_add_users.split(" "):
33 | try:
34 | await borg(
35 | functions.channels.InviteToChannelRequest(
36 | channel=event.chat_id, users=[user_id]
37 | )
38 | )
39 | except Exception as e:
40 | await event.reply(str(e))
41 | await event.edit("Invited Successfully")
42 |
43 |
44 | @borg.on(sudo_cmd(pattern="invite ?(.*)", allow_sudo=True))
45 | async def _(event):
46 | if event.fwd_from:
47 | return
48 | to_add_users = event.pattern_match.group(1)
49 | if event.is_private:
50 | await event.edit("`.invite` users to a chat, not to a Private Message")
51 | else:
52 | logger.info(to_add_users)
53 | if not event.is_channel and event.is_group:
54 | # https://lonamiwebs.github.io/Telethon/methods/messages/add_chat_user.html
55 | for user_id in to_add_users.split(" "):
56 | try:
57 | await borg(
58 | functions.messages.AddChatUserRequest(
59 | chat_id=event.chat_id, user_id=user_id, fwd_limit=1000000
60 | )
61 | )
62 | except Exception as e:
63 | await event.reply(str(e))
64 | await event.reply("Invited Successfully")
65 | else:
66 | # https://lonamiwebs.github.io/Telethon/methods/channels/invite_to_channel.html
67 | for user_id in to_add_users.split(" "):
68 | try:
69 | await borg(
70 | functions.channels.InviteToChannelRequest(
71 | channel=event.chat_id, users=[user_id]
72 | )
73 | )
74 | except Exception as e:
75 | await event.reply(str(e))
76 | await event.reply("Invited Successfully")
77 |
--------------------------------------------------------------------------------
/userbot/plugins/channel_download.py:
--------------------------------------------------------------------------------
1 | """
2 | Telegram Channel Media Downloader Plugin for userbot.
3 | usage: .geta channel_username [will get all media from channel, tho there is limit of 3000 there to prevent API limits.]
4 | .getc number_of_messsages channel_username
5 | By: @Zero_cool7870
6 | """
7 | import os
8 | import subprocess
9 |
10 | from .. import CMD_HELP
11 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
12 |
13 |
14 | @borg.on(admin_cmd(pattern=r"getc(?: |$)(.*)"))
15 | @borg.on(sudo_cmd(pattern="getc(?: |$)(.*)", allow_sudo=True))
16 | async def get_media(event):
17 | if event.fwd_from:
18 | return
19 | dir = "./temp/"
20 | try:
21 | os.makedirs("./temp/")
22 | except BaseException:
23 | pass
24 | catty = event.pattern_match.group(1)
25 | limit = int(catty.split(" ")[0])
26 | channel_username = str(catty.split(" ")[1])
27 | event = await edit_or_reply(event, "Downloading Media From this Channel.")
28 | msgs = await borg.get_messages(channel_username, limit=int(limit))
29 | with open("log.txt", "w") as f:
30 | f.write(str(msgs))
31 | i = 0
32 | for msg in msgs:
33 | if msg.media is not None:
34 | await borg.download_media(msg, dir)
35 | i += 1
36 | await event.edit(
37 | f"Downloading Media From this Channel.\n **DOWNLOADED : **`{i}`"
38 | )
39 | ps = subprocess.Popen(("ls", "temp"), stdout=subprocess.PIPE)
40 | output = subprocess.check_output(("wc", "-l"), stdin=ps.stdout)
41 | ps.wait()
42 | output = str(output)
43 | output = output.replace("b'", " ")
44 | output = output.replace("\\n'", " ")
45 | await event.edit("Downloaded " + output + " files.")
46 |
47 |
48 | @borg.on(admin_cmd(pattern="geta(?: |$)(.*)"))
49 | @borg.on(sudo_cmd(pattern="geta(?: |$)(.*)", allow_sudo=True))
50 | async def get_media(event):
51 | if event.fwd_from:
52 | return
53 | dir = "./temp/"
54 | try:
55 | os.makedirs("./temp/")
56 | except BaseException:
57 | pass
58 | channel_username = event.pattern_match.group(1)
59 | event = await edit_or_reply(event, "Downloading All Media From this Channel.")
60 | msgs = await borg.get_messages(channel_username, limit=3000)
61 | with open("log.txt", "w") as f:
62 | f.write(str(msgs))
63 | i = 0
64 | for msg in msgs:
65 | if msg.media is not None:
66 | await borg.download_media(msg, dir)
67 | i += 1
68 | await event.edit(
69 | f"Downloading Media From this Channel.\n **DOWNLOADED : **`{i}`"
70 | )
71 | ps = subprocess.Popen(("ls", "temp"), stdout=subprocess.PIPE)
72 | output = subprocess.check_output(("wc", "-l"), stdin=ps.stdout)
73 | ps.wait()
74 | output = str(output)
75 | output = output.replace("b'", "")
76 | output = output.replace("\\n'", "")
77 | await event.edit("Downloaded " + output + " files.")
78 |
79 |
80 | CMD_HELP.update(
81 | {
82 | "channel_download": "Telegram Channel Media Downloader Plugin for userbot.\
83 | \n\n**USAGE :**\n .geta channel_username [will get all media from channel, tho there is limit of 3000 there to prevent API limits.]\
84 | \n\n.getc number_of_messsages channel_username"
85 | }
86 | )
87 |
--------------------------------------------------------------------------------
/userbot/plugins/autopfp.py:
--------------------------------------------------------------------------------
1 | # Made By @Nihinivi Keep Credits If You Are Goanna Kang This Lol
2 | # And Thanks To The Creator Of Autopic This Script Was Made from Snippets From That Script
3 | # Usage .gamerpfp Im Not Responsible For Any Ban caused By This
4 | import asyncio
5 | import os
6 | import random
7 | import re
8 | import urllib
9 |
10 | import requests
11 | from telethon.tl import functions
12 |
13 | from userbot.utils import admin_cmd
14 |
15 | COLLECTION_STRING1 = [
16 | "awesome-batman-wallpapers",
17 | "batman-arkham-knight-4k-wallpaper",
18 | "batman-hd-wallpapers-1080p",
19 | "the-joker-hd-wallpaper",
20 | "dark-knight-joker-wallpaper",
21 | ]
22 | COLLECTION_STRING2 = [
23 | "thor-wallpapers",
24 | "thor-wallpaper",
25 | "thor-iphone-wallpaper",
26 | "thor-wallpaper-hd",
27 | ]
28 |
29 |
30 | async def animeppbat():
31 | rnd = random.randint(0, len(COLLECTION_STRING1) - 1)
32 | pack = COLLECTION_STRING1[rnd]
33 | pc = requests.get("http://getwallpapers.com/collection/" + pack).text
34 | f = re.compile(r"/\w+/full.+.jpg")
35 | f = f.findall(pc)
36 | fy = "http://getwallpapers.com" + random.choice(f)
37 | if not os.path.exists("f.ttf"):
38 | urllib.request.urlretrieve(
39 | "https://github.com/rebel6969/mym/raw/master/Rebel-robot-Regular.ttf",
40 | "f.ttf",
41 | )
42 | urllib.request.urlretrieve(fy, "donottouch.jpg")
43 |
44 |
45 | async def animeppthor():
46 | rnd = random.randint(0, len(COLLECTION_STRING2) - 1)
47 | pack = COLLECTION_STRING2[rnd]
48 | pc = requests.get("http://getwallpapers.com/collection/" + pack).text
49 | f = re.compile(r"/\w+/full.+.jpg")
50 | f = f.findall(pc)
51 | fy = "http://getwallpapers.com" + random.choice(f)
52 | if not os.path.exists("f.ttf"):
53 | urllib.request.urlretrieve(
54 | "https://github.com/rebel6969/mym/raw/master/Rebel-robot-Regular.ttf",
55 | "f.ttf",
56 | )
57 | urllib.request.urlretrieve(fy, "donottouch.jpg")
58 |
59 |
60 | @borg.on(admin_cmd(pattern="batmanpfp$"))
61 | async def main(event):
62 | await event.edit("Starting batman Profile Pic.") # Owner @NihiNivi
63 | while True:
64 | await animeppbat()
65 | file = await event.client.upload_file("donottouch.jpg")
66 | await event.client(
67 | functions.photos.DeletePhotosRequest(
68 | await event.client.get_profile_photos("me", limit=1)
69 | )
70 | )
71 | await event.client(functions.photos.UploadProfilePhotoRequest(file))
72 | os.system("rm -rf donottouch.jpg")
73 | await asyncio.sleep(120) # Edit this to your required needs
74 |
75 |
76 | @borg.on(admin_cmd(pattern="thorpfp$"))
77 | async def main(event):
78 | await event.edit("Starting thor Profile Pic.") # Owner @NihiNivi
79 | while True:
80 | await animeppthor()
81 | file = await event.client.upload_file("donottouch.jpg")
82 | await event.client(
83 | functions.photos.DeletePhotosRequest(
84 | await event.client.get_profile_photos("me", limit=1)
85 | )
86 | )
87 | await event.client(functions.photos.UploadProfilePhotoRequest(file))
88 | os.system("rm -rf donottouch.jpg")
89 | await asyncio.sleep(120) # Edit this to your required needs
90 |
--------------------------------------------------------------------------------
/userbot/plugins/poll.py:
--------------------------------------------------------------------------------
1 | import random
2 |
3 | from telethon.errors.rpcbaseerrors import ForbiddenError
4 | from telethon.errors.rpcerrorlist import PollOptionInvalidError
5 | from telethon.tl.types import InputMediaPoll, Poll
6 |
7 | from .. import CMD_HELP
8 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
9 | from . import Build_Poll
10 |
11 |
12 | @borg.on(admin_cmd(pattern="poll( (.*)|$)"))
13 | @borg.on(sudo_cmd(pattern="poll( (.*)|$)", allow_sudo=True))
14 | async def pollcreator(catpoll):
15 | reply_to_id = None
16 | if catpoll.reply_to_msg_id:
17 | reply_to_id = catpoll.reply_to_msg_id
18 | string = "".join(catpoll.text.split(maxsplit=1)[1:])
19 | if not string:
20 | options = Build_Poll(["Yah sure 😊✌️", "Nah 😏😕", "Whatever die sur 🥱🙄"])
21 | try:
22 | await bot.send_message(
23 | catpoll.chat_id,
24 | file=InputMediaPoll(
25 | poll=Poll(
26 | id=random.getrandbits(32),
27 | question="👆👆So do you guys agree with this?",
28 | answers=options,
29 | )
30 | ),
31 | reply_to=reply_to_id,
32 | )
33 | await catpoll.delete()
34 | except PollOptionInvalidError:
35 | await edit_or_reply(
36 | catpoll, "`A poll option used invalid data (the data may be too long).`"
37 | )
38 | except ForbiddenError:
39 | await edit_or_reply(catpoll, "`This chat has forbidden the polls`")
40 | except exception as e:
41 | await edit_or_reply(catpoll, str(e))
42 | else:
43 | catinput = string.split(";")
44 | if len(catinput) > 2 and len(catinput) < 12:
45 | options = Build_Poll(catinput[1:])
46 | try:
47 | await bot.send_message(
48 | catpoll.chat_id,
49 | file=InputMediaPoll(
50 | poll=Poll(
51 | id=random.getrandbits(32),
52 | question=catinput[0],
53 | answers=options,
54 | )
55 | ),
56 | reply_to=reply_to_id,
57 | )
58 | await catpoll.delete()
59 | except PollOptionInvalidError:
60 | await edit_or_reply(
61 | catpoll,
62 | "`A poll option used invalid data (the data may be too long).`",
63 | )
64 | except ForbiddenError:
65 | await edit_or_reply(catpoll, "`This chat has forbidden the polls`")
66 | except exception as e:
67 | await edit_or_reply(catpoll, str(e))
68 | else:
69 | await edit_or_reply(
70 | catpoll,
71 | "Make sure that you used Correct syntax `.poll question ; option1 ; option2`",
72 | )
73 |
74 |
75 | CMD_HELP.update(
76 | {
77 | "poll": "**Plugin :**`poll`\
78 | \n\n**Syntax :** `.poll`\
79 | \n**Usage : **If you doesnt give any input it sends a default poll. if you like customize it then use this syntax :\
80 | \n `.poll question ; option 1; option2 ;`\
81 | \n ';' this seperates the each option and question \
82 | "
83 | }
84 | )
85 |
--------------------------------------------------------------------------------
/userbot/plugins/sql_helper/blacklist_sql.py:
--------------------------------------------------------------------------------
1 | import threading
2 |
3 | from sqlalchemy import Column, String, UnicodeText, distinct, func
4 |
5 | from userbot.plugins.sql_helper import BASE, SESSION
6 |
7 |
8 | class BlackListFilters(BASE):
9 | __tablename__ = "blacklist"
10 | chat_id = Column(String(14), primary_key=True)
11 | trigger = Column(UnicodeText, primary_key=True, nullable=False)
12 |
13 | def __init__(self, chat_id, trigger):
14 | self.chat_id = str(chat_id) # ensure string
15 | self.trigger = trigger
16 |
17 | def __repr__(self):
18 | return "" % (self.trigger, self.chat_id)
19 |
20 | def __eq__(self, other):
21 | return bool(
22 | isinstance(other, BlackListFilters)
23 | and self.chat_id == other.chat_id
24 | and self.trigger == other.trigger
25 | )
26 |
27 |
28 | BlackListFilters.__table__.create(checkfirst=True)
29 |
30 | BLACKLIST_FILTER_INSERTION_LOCK = threading.RLock()
31 |
32 | CHAT_BLACKLISTS = {}
33 |
34 |
35 | def add_to_blacklist(chat_id, trigger):
36 | with BLACKLIST_FILTER_INSERTION_LOCK:
37 | blacklist_filt = BlackListFilters(str(chat_id), trigger)
38 |
39 | SESSION.merge(blacklist_filt) # merge to avoid duplicate key issues
40 | SESSION.commit()
41 | CHAT_BLACKLISTS.setdefault(str(chat_id), set()).add(trigger)
42 |
43 |
44 | def rm_from_blacklist(chat_id, trigger):
45 | with BLACKLIST_FILTER_INSERTION_LOCK:
46 | blacklist_filt = SESSION.query(BlackListFilters).get((str(chat_id), trigger))
47 | if blacklist_filt:
48 | if trigger in CHAT_BLACKLISTS.get(str(chat_id), set()): # sanity check
49 | CHAT_BLACKLISTS.get(str(chat_id), set()).remove(trigger)
50 |
51 | SESSION.delete(blacklist_filt)
52 | SESSION.commit()
53 | return True
54 |
55 | SESSION.close()
56 | return False
57 |
58 |
59 | def get_chat_blacklist(chat_id):
60 | return CHAT_BLACKLISTS.get(str(chat_id), set())
61 |
62 |
63 | def num_blacklist_filters():
64 | try:
65 | return SESSION.query(BlackListFilters).count()
66 | finally:
67 | SESSION.close()
68 |
69 |
70 | def num_blacklist_chat_filters(chat_id):
71 | try:
72 | return (
73 | SESSION.query(BlackListFilters.chat_id)
74 | .filter(BlackListFilters.chat_id == str(chat_id))
75 | .count()
76 | )
77 | finally:
78 | SESSION.close()
79 |
80 |
81 | def num_blacklist_filter_chats():
82 | try:
83 | return SESSION.query(func.count(distinct(BlackListFilters.chat_id))).scalar()
84 | finally:
85 | SESSION.close()
86 |
87 |
88 | def __load_chat_blacklists():
89 | global CHAT_BLACKLISTS
90 | try:
91 | chats = SESSION.query(BlackListFilters.chat_id).distinct().all()
92 | for (chat_id,) in chats: # remove tuple by ( ,)
93 | CHAT_BLACKLISTS[chat_id] = []
94 |
95 | all_filters = SESSION.query(BlackListFilters).all()
96 | for x in all_filters:
97 | CHAT_BLACKLISTS[x.chat_id] += [x.trigger]
98 |
99 | CHAT_BLACKLISTS = {x: set(y) for x, y in CHAT_BLACKLISTS.items()}
100 |
101 | finally:
102 | SESSION.close()
103 |
104 |
105 | __load_chat_blacklists()
106 |
--------------------------------------------------------------------------------
/userbot/plugins/antispambot.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2020 sandeep.n(π.$)
2 | # baning spmmers plugin for catuserbot by @sandy1709 and @mrconfused
3 | # included both cas(combot antispam service) and spamwatch (need to add more feaututres)
4 |
5 |
6 | from requests import get
7 | from telethon import events
8 | from telethon.tl.types import ChannelParticipantsAdmins
9 |
10 | from .. import LOGS
11 | from ..utils import is_admin
12 | from . import spamwatch
13 |
14 | if Config.PRIVATE_GROUP_BOT_API_ID is None:
15 | BOTLOG = False
16 | else:
17 | BOTLOG = True
18 | BOTLOG_CHATID = Config.PRIVATE_GROUP_BOT_API_ID
19 |
20 | if Config.ANTISPAMBOT_BAN:
21 |
22 | @bot.on(events.ChatAction())
23 | async def _(event):
24 | chat = event.chat_id
25 | if event.user_joined or event.user_added:
26 | user = await event.get_user()
27 | catadmin = await is_admin(bot, chat, bot.uid)
28 | if not catadmin:
29 | return
30 | catbanned = None
31 | adder = None
32 | ignore = False
33 | if event.user_added:
34 | try:
35 | adder = event.action_message.from_id
36 | except AttributeError:
37 | return
38 | async for admin in bot.iter_participants(
39 | event.chat_id, filter=ChannelParticipantsAdmins
40 | ):
41 | if admin.id == adder:
42 | ignore = True
43 | break
44 | if ignore:
45 | return
46 | if spamwatch:
47 | ban = spamwatch.get_ban(user.id)
48 | if ban:
49 | hmm = await event.reply(
50 | f"[{user.first_name}](tg://user?id={user.id}) was banned by spamwatch For the reason `{ban.reason}`"
51 | )
52 | try:
53 | await bot.edit_permissions(chat, user.id, view_messages=False)
54 | catbanned = True
55 | except Exception as e:
56 | LOGS.info(e)
57 | if not catbanned:
58 | try:
59 | casurl = "https://api.cas.chat/check?user_id={}".format(user.id)
60 | data = get(casurl).json()
61 | except Exception as e:
62 | LOGS.info(e)
63 | data = None
64 | if data and data["ok"]:
65 | reason = f"[Banned by Combot Anti Spam](https://cas.chat/query?u={user.id})"
66 | hmm = await event.reply(
67 | f"[{user.first_name}](tg://user?id={user.id}) was banned by Combat anti-spam service(CAS) For the reason check {reason}"
68 | )
69 | try:
70 | await bot.edit_permissions(
71 | chat, user.id, view_messages=False
72 | )
73 | catbanned = True
74 | except Exception as e:
75 | LOGS.info(e)
76 | if BOTLOG and catbanned:
77 | await bot.send_message(
78 | BOTLOG_CHATID,
79 | "#ANTISPAMBOT\n"
80 | f"**User :** [{user.first_name}](tg://user?id={user.id})\n"
81 | f"**Chat :** {event.chat.title} (`{event.chat_id}`)\n"
82 | f"**Reason :** {hmm.text}",
83 | )
84 |
--------------------------------------------------------------------------------
/userbot/plugins/recognize.py:
--------------------------------------------------------------------------------
1 | # credits: @Mr_Hops
2 |
3 | from telethon import events
4 | from telethon.errors.rpcerrorlist import YouBlockedUserError
5 |
6 | from userbot import CMD_HELP
7 | from userbot.utils import admin_cmd, sudo_cmd
8 |
9 |
10 | @borg.on(admin_cmd(pattern="recognize ?(.*)"))
11 | async def _(event):
12 | if event.fwd_from:
13 | return
14 | if not event.reply_to_msg_id:
15 | await event.edit("Reply to any user's media message.")
16 | return
17 | reply_message = await event.get_reply_message()
18 | if not reply_message.media:
19 | await event.edit("reply to media file")
20 | return
21 | chat = "@Rekognition_Bot"
22 | reply_message.sender
23 | if reply_message.sender.bot:
24 | await event.edit("Reply to actual users message.")
25 | return
26 | cat = await event.edit("recognizeing this media")
27 | async with event.client.conversation(chat) as conv:
28 | try:
29 | response = conv.wait_event(
30 | events.NewMessage(incoming=True, from_users=461083923)
31 | )
32 | await event.client.forward_messages(chat, reply_message)
33 | response = await response
34 | except YouBlockedUserError:
35 | await event.reply("unblock @Rekognition_Bot and try again")
36 | await cat.delete()
37 | return
38 | if response.text.startswith("See next message."):
39 | response = conv.wait_event(
40 | events.NewMessage(incoming=True, from_users=461083923)
41 | )
42 | response = await response
43 | cat = response.message.message
44 | await event.edit(cat)
45 |
46 | else:
47 | await event.edit("sorry, I couldnt find it")
48 |
49 |
50 | @borg.on(sudo_cmd(pattern="recognize ?(.*)", allow_sudo=True))
51 | async def _(event):
52 | if event.fwd_from:
53 | return
54 | if not event.reply_to_msg_id:
55 | await event.reply("Reply to any user's media message.")
56 | return
57 | reply_message = await event.get_reply_message()
58 | if not reply_message.media:
59 | await event.reply("reply to media file")
60 | return
61 | chat = "@Rekognition_Bot"
62 | reply_message.sender
63 | if reply_message.sender.bot:
64 | await event.reply("Reply to actual users message.")
65 | return
66 | cat = await event.reply("recognizeing this media")
67 | async with event.client.conversation(chat) as conv:
68 | try:
69 | response = conv.wait_event(
70 | events.NewMessage(incoming=True, from_users=461083923)
71 | )
72 | await event.client.forward_messages(chat, reply_message)
73 | response = await response
74 | except YouBlockedUserError:
75 | await event.reply("unblock @Rekognition_Bot and try again")
76 | await cat.delete()
77 | return
78 | if response.text.startswith("See next message."):
79 | response = conv.wait_event(
80 | events.NewMessage(incoming=True, from_users=461083923)
81 | )
82 | response = await response
83 | cat = response.message.message
84 | await event.reply(cat)
85 | await cat.delete()
86 | else:
87 | await event.reply("sorry, I couldn't find it")
88 | await cat.delete()
89 |
90 |
91 | CMD_HELP.update(
92 | {
93 | "recognize": "`.recognize` reply this to any media file\
94 | \nUSAGE : Get information about an image using AWS Rekognition.\
95 | \nFind out information including detected labels, faces. text and moderation tags."
96 | }
97 | )
98 |
--------------------------------------------------------------------------------
/userbot/plugins/sed.py:
--------------------------------------------------------------------------------
1 | import re
2 | from collections import defaultdict, deque
3 |
4 | import regex
5 | from telethon import events, utils
6 | from telethon.tl import functions, types
7 |
8 | from userbot import CMD_HELP
9 |
10 | HEADER = "「sed」\n"
11 | KNOWN_RE_BOTS = re.compile(
12 | r"(regex|moku|BananaButler_|rgx|l4mR)bot", flags=re.IGNORECASE
13 | )
14 |
15 | # Heavily based on
16 | # https://github.com/SijmenSchoon/regexbot/blob/master/regexbot.py
17 |
18 | last_msgs = defaultdict(lambda: deque(maxlen=10))
19 |
20 |
21 | def doit(chat_id, match, original):
22 | fr = match.group(1)
23 | to = match.group(2)
24 | to = to.replace("\\/", "/")
25 | try:
26 | fl = match.group(3)
27 | if fl is None:
28 | fl = ""
29 | fl = fl[1:]
30 | except IndexError:
31 | fl = ""
32 |
33 | # Build Python regex flags
34 | count = 1
35 | flags = 0
36 | for f in fl:
37 | if f == "i":
38 | flags |= regex.IGNORECASE
39 | elif f == "g":
40 | count = 0
41 | else:
42 | return None, f"Unknown flag: {f}"
43 |
44 | def actually_doit(original):
45 | try:
46 | s = original.message
47 | if s.startswith(HEADER):
48 | s = s[len(HEADER) :]
49 | s, i = regex.subn(fr, to, s, count=count, flags=flags)
50 | if i > 0:
51 | return original, s
52 | except Exception as e:
53 | return None, f"u dun goofed m8: {str(e)}"
54 | return None, None
55 |
56 | if original is not None:
57 | return actually_doit(original)
58 | # Try matching the last few messages
59 | for original in last_msgs[chat_id]:
60 | m, s = actually_doit(original)
61 | if s is not None:
62 | return m, s
63 | return None, None
64 |
65 |
66 | async def group_has_sedbot(group):
67 | if isinstance(group, types.InputPeerChannel):
68 | full = await bot(functions.channels.GetFullChannelRequest(group))
69 | elif isinstance(group, types.InputPeerChat):
70 | full = await bot(functions.messages.GetFullChatRequest(group.chat_id))
71 | else:
72 | return False
73 |
74 | return any(KNOWN_RE_BOTS.match(x.username or "") for x in full.users)
75 |
76 |
77 | @command()
78 | async def on_message(event):
79 | last_msgs[event.chat_id].appendleft(event.message)
80 |
81 |
82 | @command(allow_edited_updates=True)
83 | async def on_edit(event):
84 | for m in last_msgs[event.chat_id]:
85 | if m.id == event.id:
86 | m.raw_text = event.raw_text
87 | break
88 |
89 |
90 | @command(pattern=re.compile(r"^s/((?:\\/|[^/])+)/((?:\\/|[^/])*)(/.*)?"), outgoing=True)
91 | async def on_regex(event):
92 | if event.fwd_from:
93 | return
94 | if not event.is_private and await group_has_sedbot(await event.get_input_chat()):
95 | # await event.edit("This group has a sed bot. Ignoring this message!")
96 | return
97 |
98 | chat_id = utils.get_peer_id(await event.get_input_chat())
99 |
100 | m, s = doit(chat_id, event.pattern_match, await event.get_reply_message())
101 |
102 | if m is not None:
103 | s = f"{HEADER}{s}"
104 | out = await bot.send_message(await event.get_input_chat(), s, reply_to=m.id)
105 | last_msgs[chat_id].appendleft(out)
106 | elif s is not None:
107 | await event.edit(s)
108 |
109 | raise events.StopPropagation
110 |
111 |
112 | CMD_HELP.update(
113 | {
114 | "sed": ".s\
115 | \nUsage: Replaces a word or words using sed.\
116 | \nDelimiters: `/, :, |, _`\
117 | example: tag any sentence and type s/a/b. where is required word to replace and b is correct word."
118 | }
119 | )
120 |
--------------------------------------------------------------------------------
/userbot/plugins/poto.py:
--------------------------------------------------------------------------------
1 | # Friendly Telegram (telegram userbot)
2 | # Copyright (C) 2018-2019 The Authors
3 |
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU Affero General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 |
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU Affero General Public License for more details.
13 |
14 | # You should have received a copy of the GNU Affero General Public License
15 | # along with this program. If not, see .
16 |
17 | """
18 | ----------------------------------------------------------------
19 | All Thenks goes to Emily ( The creater of This Plugin)
20 | \nSome credits goes to me ( @kirito6969 ) for ported this plugin
21 | \nand `SnapDragon for` Helping me.
22 | ----------------------------------------------------------------
23 |
24 | Type `.poto` for get **All profile pics of that User**
25 | \nOr type `.poto (number)` to get the **desired number of photo of a User** .
26 | """
27 |
28 | import asyncio
29 | import logging
30 |
31 | from userbot.utils import admin_cmd
32 |
33 | logger = logging.getLogger(__name__)
34 |
35 | if 1 == 1:
36 | name = "Profile Photos"
37 | client = borg
38 |
39 | @borg.on(admin_cmd(pattern="poto ?(.*)"))
40 | async def potocmd(event):
41 | """Gets the profile photos of replied users, channels or chats"""
42 | id = "".join(event.raw_text.split(maxsplit=2)[1:])
43 | user = await event.get_reply_message()
44 | chat = event.input_chat
45 | if user:
46 | photos = await event.client.get_profile_photos(user.sender)
47 | u = True
48 | else:
49 | photos = await event.client.get_profile_photos(chat)
50 | u = False
51 | if id.strip() == "":
52 | id = 1
53 | if int(id) <= (len(photos)):
54 | send_photos = await event.client.download_media(photos[id - 1])
55 | await event.client.send_file(event.chat_id, send_photos)
56 | else:
57 | await event.edit("No photo found of this NIBBA / NIBBI. Now u Die!")
58 | await asyncio.sleep(2)
59 | return
60 | elif id.strip() == "all":
61 | if len(photos) > 0:
62 | await event.client.send_file(event.chat_id, photos)
63 | else:
64 | try:
65 | if u is True:
66 | photo = await event.client.download_profile_photo(user.sender)
67 | else:
68 | photo = await event.client.download_profile_photo(
69 | event.input_chat
70 | )
71 | await event.client.send_file(event.chat_id, photo)
72 | except a:
73 | await event.edit("**This user has no photos!**")
74 | return
75 | else:
76 | try:
77 | id = int(id)
78 | if id <= 0:
79 | await event.edit("```number Invalid!``` **Are you Comedy Me ?**")
80 | return
81 | except BaseException:
82 | await event.edit("Are you comedy me ?")
83 | return
84 | if int(id) <= (len(photos)):
85 | send_photos = await event.client.download_media(photos[id - 1])
86 | await event.client.send_file(event.chat_id, send_photos)
87 | else:
88 | await event.edit("No photo found of this NIBBA / NIBBI. Now u Die!")
89 | await asyncio.sleep(2)
90 | return
91 |
--------------------------------------------------------------------------------
/userbot/helpers/progress.py:
--------------------------------------------------------------------------------
1 | # Copyright (C) 2020 Adek Maulana
2 | #
3 | # SPDX-License-Identifier: GPL-3.0-or-later
4 | # This program is free software: you can redistribute it and/or modify
5 | # it under the terms of the GNU General Public License as published by
6 | # the Free Software Foundation, either version 3 of the License, or
7 | # (at your option) any later version.
8 | #
9 | # This program is distributed in the hope that it will be useful,
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | # GNU General Public License for more details.
13 | #
14 | # You should have received a copy of the GNU General Public License
15 | # along with this program. If not, see .
16 |
17 |
18 | import hashlib
19 | import math
20 | import re
21 | import time
22 |
23 | from .exceptions import CancelProcess
24 |
25 |
26 | async def md5(fname: str) -> str:
27 | hash_md5 = hashlib.md5()
28 | with open(fname, "rb") as f:
29 | for chunk in iter(lambda: f.read(4096), b""):
30 | hash_md5.update(chunk)
31 | return hash_md5.hexdigest()
32 |
33 |
34 | def humanbytes(size: int) -> str:
35 | if size is None or isinstance(size, str):
36 | return ""
37 |
38 | power = 2 ** 10
39 | raised_to_pow = 0
40 | dict_power_n = {0: "", 1: "Ki", 2: "Mi", 3: "Gi", 4: "Ti"}
41 | while size > power:
42 | size /= power
43 | raised_to_pow += 1
44 | return str(round(size, 2)) + " " + dict_power_n[raised_to_pow] + "B"
45 |
46 |
47 | def time_formatter(seconds: int) -> str:
48 | minutes, seconds = divmod(seconds, 60)
49 | hours, minutes = divmod(minutes, 60)
50 | days, hours = divmod(hours, 24)
51 | tmp = (
52 | ((str(days) + " day(s), ") if days else "")
53 | + ((str(hours) + " hour(s), ") if hours else "")
54 | + ((str(minutes) + " minute(s), ") if minutes else "")
55 | + ((str(seconds) + " second(s), ") if seconds else "")
56 | )
57 | return tmp[:-2]
58 |
59 |
60 | def human_to_bytes(size: str) -> int:
61 | units = {
62 | "M": 2 ** 20,
63 | "MB": 2 ** 20,
64 | "G": 2 ** 30,
65 | "GB": 2 ** 30,
66 | "T": 2 ** 40,
67 | "TB": 2 ** 40,
68 | }
69 |
70 | size = size.upper()
71 | if not re.match(r" ", size):
72 | size = re.sub(r"([KMGT])", r" \1", size)
73 | number, unit = [string.strip() for string in size.split()]
74 | return int(float(number) * units[unit])
75 |
76 |
77 | async def progress(
78 | current, total, gdrive, start, prog_type, file_name=None, is_cancelled=False
79 | ):
80 | now = time.time()
81 | diff = now - start
82 | if is_cancelled is True:
83 | raise CancelProcess
84 |
85 | if round(diff % 10.00) == 0 or current == total:
86 | percentage = current * 100 / total
87 | speed = current / diff
88 | elapsed_time = round(diff)
89 | eta = round((total - current) / speed)
90 | if "upload" in prog_type.lower():
91 | status = "Uploading"
92 | elif "download" in prog_type.lower():
93 | status = "Downloading"
94 | else:
95 | status = "Unknown"
96 | progress_str = "`{0}` | [{1}{2}] `{3}%`".format(
97 | status,
98 | "".join(["▰" for i in range(math.floor(percentage / 10))]),
99 | "".join(["▱" for i in range(10 - math.floor(percentage / 10))]),
100 | round(percentage, 2),
101 | )
102 | tmp = (
103 | f"{progress_str}\n"
104 | f"`{humanbytes(current)} of {humanbytes(total)}"
105 | f" @ {humanbytes(speed)}`\n"
106 | f"**ETA :**` {time_formatter(eta)}`\n"
107 | f"**Duration :** `{time_formatter(elapsed_time)}`"
108 | )
109 | await gdrive.edit(f"**{prog_type}**\n\n" f"**Status**\n{tmp}")
110 |
--------------------------------------------------------------------------------
/userbot/plugins/fake.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | import logging
3 | from datetime import datetime
4 |
5 | from telethon.tl.functions.channels import EditAdminRequest
6 | from telethon.tl.types import ChatAdminRights
7 |
8 | from .. import ALIVE_NAME, CMD_HELP
9 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
10 |
11 | logging.basicConfig(
12 | format="[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s", level=logging.WARNING
13 | )
14 |
15 | DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "cat"
16 |
17 |
18 | @borg.on(admin_cmd(pattern="scam ?(.*)"))
19 | @borg.on(sudo_cmd(pattern="scam ?(.*)", allow_sudo=True))
20 | async def _(event):
21 | if event.fwd_from:
22 | return
23 | input_str = event.pattern_match.group(1)
24 | action = "typing"
25 | if input_str:
26 | action = input_str
27 | try:
28 | await event.delete()
29 | except BaseException:
30 | pass
31 | async with borg.action(event.chat_id, action):
32 | await asyncio.sleep(86400) # type for 10 seconds
33 |
34 |
35 | @borg.on(admin_cmd(pattern="prankpromote ?(.*)"))
36 | @borg.on(sudo_cmd(pattern="prankpromote ?(.*)", allow_sudo=True))
37 | async def _(event):
38 | if event.fwd_from:
39 | return
40 | datetime.now()
41 | to_promote_id = None
42 | rights = ChatAdminRights(post_messages=True)
43 | input_str = event.pattern_match.group(1)
44 | reply_msg_id = event.message.id
45 | if reply_msg_id:
46 | r_mesg = await event.get_reply_message()
47 | to_promote_id = r_mesg.sender_id
48 | elif input_str:
49 | to_promote_id = input_str
50 | try:
51 | await borg(EditAdminRequest(event.chat_id, to_promote_id, rights, ""))
52 | except (Exception) as exc:
53 | await edit_or_reply(event, str(exc))
54 | else:
55 | await edit_or_reply(event, "Successfully Promoted")
56 |
57 |
58 | @borg.on(admin_cmd(pattern=f"padmin$", outgoing=True))
59 | @borg.on(sudo_cmd(pattern="padmin$", allow_sudo=True))
60 | async def _(event):
61 | if event.fwd_from:
62 | return
63 | animation_interval = 1
64 | animation_ttl = range(0, 20)
65 | event = await edit_or_reply(event, "promoting.......")
66 | animation_chars = [
67 | "**Promoting User As Admin...**",
68 | "**Enabling All Permissions To User...**",
69 | "**(1) Send Messages: ☑️**",
70 | "**(1) Send Messages: ✅**",
71 | "**(2) Send Media: ☑️**",
72 | "**(2) Send Media: ✅**",
73 | "**(3) Send Stickers & GIFs: ☑️**",
74 | "**(3) Send Stickers & GIFs: ✅**",
75 | "**(4) Send Polls: ☑️**",
76 | "**(4) Send Polls: ✅**",
77 | "**(5) Embed Links: ☑️**",
78 | "**(5) Embed Links: ✅**",
79 | "**(6) Add Users: ☑️**",
80 | "**(6) Add Users: ✅**",
81 | "**(7) Pin Messages: ☑️**",
82 | "**(7) Pin Messages: ✅**",
83 | "**(8) Change Chat Info: ☑️**",
84 | "**(8) Change Chat Info: ✅**",
85 | "**Permission Granted Successfully**",
86 | f"**pRoMooTeD SuCcEsSfUlLy bY: {DEFAULTUSER}**",
87 | ]
88 | for i in animation_ttl:
89 | await asyncio.sleep(animation_interval)
90 | await event.edit(animation_chars[i % 20])
91 |
92 |
93 | CMD_HELP.update(
94 | {
95 | "fake": "**fake**\
96 | \n\n**Syntax :** `.scam ` \
97 | \n**Usage : **Type .scam (action name) this shows the fake action in the group the actions are typing ,contact ,game, location, voice, round, video,photo,document, cancel.\
98 | \n\n**Syntax :** `.prankpromote` reply to user to who you want to prank promote\
99 | \n**Usage : **it promotes him to admin but he will not have any permission to take action that is he can see rection actions but cant take any admin action\
100 | \n\n**Syntax :** `.padmin`\
101 | \n**Usage : ** An animation that shows enableing all permissions to him that he is admin(fake promotion)\
102 | "
103 | }
104 | )
105 |
--------------------------------------------------------------------------------
/userbot/plugins/stat.py:
--------------------------------------------------------------------------------
1 | """Count the Number of Dialogs you have in your Telegram Account
2 | Syntax: .stat"""
3 | import time
4 |
5 | from telethon.events import NewMessage
6 | from telethon.tl.custom import Dialog
7 | from telethon.tl.types import Channel, Chat, User
8 |
9 | from userbot.utils import admin_cmd
10 |
11 |
12 | @borg.on(admin_cmd(pattern="stat"))
13 | async def stats(
14 | event: NewMessage.Event,
15 | ) -> None: # pylint: disable = R0912, R0914, R0915
16 | """Command to get stats about the account"""
17 | await event.edit("`Collecting stats, Wait man`")
18 | start_time = time.time()
19 | private_chats = 0
20 | bots = 0
21 | groups = 0
22 | broadcast_channels = 0
23 | admin_in_groups = 0
24 | creator_in_groups = 0
25 | admin_in_broadcast_channels = 0
26 | creator_in_channels = 0
27 | unread_mentions = 0
28 | unread = 0
29 | dialog: Dialog
30 | async for dialog in event.client.iter_dialogs():
31 | entity = dialog.entity
32 | if isinstance(entity, Channel):
33 | # participants_count = (await event.get_participants(dialog,
34 | # limit=0)).total
35 | if entity.broadcast:
36 | broadcast_channels += 1
37 | if entity.creator or entity.admin_rights:
38 | admin_in_broadcast_channels += 1
39 | if entity.creator:
40 | creator_in_channels += 1
41 | elif entity.megagroup:
42 | groups += 1
43 | # if participants_count > largest_group_member_count:
44 | # largest_group_member_count = participants_count
45 | if entity.creator or entity.admin_rights:
46 | # if participants_count > largest_group_with_admin:
47 | # largest_group_with_admin = participants_count
48 | admin_in_groups += 1
49 | if entity.creator:
50 | creator_in_groups += 1
51 | elif isinstance(entity, User):
52 | private_chats += 1
53 | if entity.bot:
54 | bots += 1
55 | elif isinstance(entity, Chat):
56 | groups += 1
57 | if entity.creator or entity.admin_rights:
58 | admin_in_groups += 1
59 | if entity.creator:
60 | creator_in_groups += 1
61 | unread_mentions += dialog.unread_mentions_count
62 | unread += dialog.unread_count
63 | stop_time = time.time() - start_time
64 | full_name = inline_mention(await event.client.get_me())
65 | response = f"📌 **Stats for {full_name}** \n\n"
66 | response += f"**Private Chats:** {private_chats} \n"
67 | response += f" ★ `Users: {private_chats - bots}` \n"
68 | response += f" ★ `Bots: {bots}` \n"
69 | response += f"**Groups:** {groups} \n"
70 | response += f"**Channels:** {broadcast_channels} \n"
71 | response += f"**Admin in Groups:** {admin_in_groups} \n"
72 | response += f" ★ `Creator: {creator_in_groups}` \n"
73 | response += f" ★ `Admin Rights: {admin_in_groups - creator_in_groups}` \n"
74 | response += f"**Admin in Channels:** {admin_in_broadcast_channels} \n"
75 | response += f" ★ `Creator: {creator_in_channels}` \n"
76 | response += (
77 | f" ★ `Admin Rights: {admin_in_broadcast_channels - creator_in_channels}` \n"
78 | )
79 | response += f"**Unread:** {unread} \n"
80 | response += f"**Unread Mentions:** {unread_mentions} \n\n"
81 | response += f"📌 __It Took:__ {stop_time:.02f}s \n"
82 | await event.edit(response)
83 |
84 |
85 | def make_mention(user):
86 | if user.username:
87 | return f"@{user.username}"
88 | return inline_mention(user)
89 |
90 |
91 | def inline_mention(user):
92 | full_name = user_full_name(user) or "No Name"
93 | return f"[{full_name}](tg://user?id={user.id})"
94 |
95 |
96 | def user_full_name(user):
97 | names = [user.first_name, user.last_name]
98 | names = [i for i in list(names) if i]
99 | full_name = " ".join(names)
100 | return full_name
101 |
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Catuserbot",
3 | "description": "Userbot created by a SNAPDRAGON and custom fork by https://t.me/mrconfused contact @catuserbot_support for support",
4 | "logo": "https://telegra.ph/file/3d60313110c58684b31ea.jpg",
5 | "keywords": [
6 | "telegram",
7 | "userbot",
8 | "plugin",
9 | "modular",
10 | "productivity"
11 | ],
12 | "repository": "https://github.com/sandy1709/catuserbot/",
13 | "website": "#TODO",
14 | "success_url": "#TODO",
15 | "stack": "container",
16 | "env": {
17 | "ENV": {
18 | "description": "Setting this to ANYTHING will enable heroku.",
19 | "value": "ANYTHING"
20 | },
21 | "TMP_DOWNLOAD_DIRECTORY": {
22 | "description": "Where downloaded files will go.",
23 | "value": "./DOWNLOADS/",
24 | "required": false
25 | },
26 | "ALIVE_NAME": {
27 | "description": "give your name",
28 | "value": ""
29 | },
30 | "APP_ID": {
31 | "description": "Get this value from my.telegram.org! Please do not steal",
32 | "value": ""
33 | },
34 | "API_HASH": {
35 | "description": "Get this value from my.telegram.org! Please do not steal",
36 | "value": ""
37 | },
38 | "STRING_SESSION": {
39 | "description": "Get this value by running python3 telesetup.py locally",
40 | "value": ""
41 | },
42 | "TG_BOT_USER_NAME_BF_HER": {
43 | "description": "Needed for inline buttons maker. Make a bot at http://telegram.dog/BotFather and get the username of your bot",
44 | "value": ""
45 | },
46 | "TG_BOT_TOKEN_BF_HER": {
47 | "description": "Needed for inline buttons maker. Make a bot at http://telegram.dog/BotFather and get the token of your bot.Worth it. Get it.",
48 | "value": ""
49 | },
50 | "HEROKU_API_KEY": {
51 | "description": "Required for updating the bot and other stuff get it from https://dashboard.heroku.com/account",
52 | "value": "",
53 | "required": false
54 | },
55 | "HEROKU_APP_NAME": {
56 | "description": "YOUR app name ",
57 | "value": "",
58 | "required": false
59 | },
60 | "DEFAULT_BIO": {
61 | "description": "Your bio here note bio must have only 70characters or less.",
62 | "value": "",
63 | "required": false
64 | },
65 | "MAX_FLOOD_IN_P_M_s": {
66 | "description": "Maximum number of messages a person can send in pm before getting blocked. Value must be an integer. 6 by default.",
67 | "value": "6",
68 | "required": false
69 | },
70 | "OCR_SPACE_API_KEY": {
71 | "description": "Required for OCR functionality. Get from https://ocr.space/ocrapi",
72 | "value": "",
73 | "required": false
74 | },
75 | "REM_BG_API_KEY": {
76 | "description": "Required for Removing image background functionality. Get from https://www.remove.bg/",
77 | "value": "",
78 | "required": false
79 | },
80 | "ALIVE_PIC": {
81 | "description": "the pic that to show in your alive message url.",
82 | "value": "",
83 | "required": false
84 | },
85 | "AUTONAME": {
86 | "description": "for .autoname command",
87 | "value": "",
88 | "required": false
89 | },
90 | "LYDIA_API_KEY": {
91 | "description": "Needed for Lydia AI. Follow https://telegra.ph/Lydia-09-05 to get your API.",
92 | "value": "",
93 | "required": false
94 | },
95 | "UB_BLACK_LIST_CHAT": {
96 | "description": "set blacklist_chats where you do not want userbot features",
97 | "value": "-1051754159",
98 | "required": false
99 | },
100 | "DOWNLOAD_PFP_URL_CLOCK": {
101 | "description": "Needed for autopic module. A url that is a preview link of your Profile Pic",
102 | "value": "",
103 | "required": false
104 | },
105 | "TZ": {
106 | "description": "Required for Correct Time on autopic/get time. Know your timezone from http://www.timezoneconverter.com/cgi-bin/findzone.tzc",
107 | "value": "Asia/Kolkata",
108 | "required": false
109 | }
110 | },
111 | "addons": [{
112 | "plan": "heroku-postgresql",
113 | "options": {
114 | "version": "12"
115 | }
116 | }]
117 | }
118 |
--------------------------------------------------------------------------------
/userbot/plugins/blacklist.py:
--------------------------------------------------------------------------------
1 | # This Source Code Form is subject to the terms of the Mozilla Public
2 | # License, v. 2.0. If a copy of the MPL was not distributed with this
3 | # file, You can obtain one at http://mozilla.org/MPL/2.0/.
4 | """Filters
5 | Available Commands:
6 | .addblacklist
7 | .listblacklist
8 | .rmblacklist"""
9 |
10 | import re
11 |
12 | from telethon import events
13 |
14 | import userbot.plugins.sql_helper.blacklist_sql as sql
15 |
16 | from .. import CMD_HELP
17 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd
18 |
19 |
20 | @borg.on(events.NewMessage(incoming=True))
21 | async def on_new_message(event):
22 | # TODO: exempt admins from locks
23 | name = event.raw_text
24 | snips = sql.get_chat_blacklist(event.chat_id)
25 | for snip in snips:
26 | pattern = r"( |^|[^\w])" + re.escape(snip) + r"( |$|[^\w])"
27 | if re.search(pattern, name, flags=re.IGNORECASE):
28 | try:
29 | await event.delete()
30 | except Exception:
31 | await event.reply("I do not have DELETE permission in this chat")
32 | sql.rm_from_blacklist(event.chat_id, snip.lower())
33 | break
34 |
35 |
36 | @borg.on(admin_cmd(pattern="addblacklist ((.|\n)*)"))
37 | @borg.on(sudo_cmd(pattern="addblacklist ((.|\n)*)", allow_sudo=True))
38 | async def on_add_black_list(event):
39 | text = event.pattern_match.group(1)
40 | to_blacklist = list(
41 | set(trigger.strip() for trigger in text.split("\n") if trigger.strip())
42 | )
43 | for trigger in to_blacklist:
44 | sql.add_to_blacklist(event.chat_id, trigger.lower())
45 | await edit_or_reply(
46 | event,
47 | "Added {} triggers to the blacklist in the current chat".format(
48 | len(to_blacklist)
49 | ),
50 | )
51 |
52 |
53 | @borg.on(admin_cmd(pattern="rmblacklist ((.|\n)*)"))
54 | @borg.on(sudo_cmd(pattern="rmblacklist ((.|\n)*)", allow_sudo=True))
55 | async def on_delete_blacklist(event):
56 | text = event.pattern_match.group(1)
57 | to_unblacklist = list(
58 | set(trigger.strip() for trigger in text.split("\n") if trigger.strip())
59 | )
60 | successful = 0
61 | for trigger in to_unblacklist:
62 | if sql.rm_from_blacklist(event.chat_id, trigger.lower()):
63 | successful += 1
64 | await edit_or_reply(
65 | event, f"Removed {successful} / {len(to_unblacklist)} from the blacklist"
66 | )
67 |
68 |
69 | @borg.on(admin_cmd(pattern="listblacklist$"))
70 | @borg.on(sudo_cmd(pattern="listblacklist$", allow_sudo=True))
71 | async def on_view_blacklist(event):
72 | all_blacklisted = sql.get_chat_blacklist(event.chat_id)
73 | OUT_STR = "Blacklists in the Current Chat:\n"
74 | if len(all_blacklisted) > 0:
75 | for trigger in all_blacklisted:
76 | OUT_STR += f"👉 {trigger} \n"
77 | else:
78 | OUT_STR = "No BlackLists. Start Saving using `.addblacklist`"
79 | if len(OUT_STR) > Config.MAX_MESSAGE_SIZE_LIMIT:
80 | with io.BytesIO(str.encode(OUT_STR)) as out_file:
81 | out_file.name = "blacklist.text"
82 | await borg.send_file(
83 | event.chat_id,
84 | out_file,
85 | force_document=True,
86 | allow_cache=False,
87 | caption="BlackLists in the Current Chat",
88 | reply_to=event,
89 | )
90 | await event.delete()
91 | else:
92 | await edit_or_reply(event, OUT_STR)
93 |
94 |
95 | CMD_HELP.update(
96 | {
97 | "blacklist": "**blacklist**\
98 | \n**Syntax : **`.addblacklist` \
99 | \n**Usage : **The given word or words will be added to blacklist in that specific chat if any user sends then the message deletes.\
100 | \n\n**Syntax : **`.rmblacklist` \
101 | \n**Usage : **The given word or words will be removed from blacklist in that specific chat\
102 | \n\n**Syntax : **`.listblacklist`\
103 | \n**Usage : **Shows you the list of blacklist words in that specific chat\
104 | \n\n**Note : **if you are adding more than one word at time via this then remember that new word must be given in new line that is not [hi hello] . it must be as\
105 | \n[hi \n hello]"
106 | }
107 | )
108 |
--------------------------------------------------------------------------------
/userbot/plugins/imdb.py:
--------------------------------------------------------------------------------
1 | # For UniBorg
2 | # Copyright (c) JeepBot | 2019
3 | # (c) JeepBot is not occur to all modules in here
4 | """
5 | Imdb Module
6 | .imdb
7 | """
8 |
9 | import re
10 |
11 | import bs4
12 | import requests
13 |
14 | from userbot.utils import admin_cmd
15 |
16 | langi = "en"
17 |
18 | # kanged from Blank-x ;---;
19 |
20 |
21 | @borg.on(admin_cmd(pattern="imdb (.*)", outgoing=True))
22 | async def imdb(e):
23 | try:
24 | movie_name = e.pattern_match.group(1)
25 | remove_space = movie_name.split(" ")
26 | final_name = "+".join(remove_space)
27 | page = requests.get(
28 | "https://www.imdb.com/find?ref_=nv_sr_fn&q=" + final_name + "&s=all"
29 | )
30 | str(page.status_code)
31 | soup = bs4.BeautifulSoup(page.content, "lxml")
32 | odds = soup.findAll("tr", "odd")
33 | mov_title = odds[0].findNext("td").findNext("td").text
34 | mov_link = (
35 | "http://www.imdb.com/" + odds[0].findNext("td").findNext("td").a["href"]
36 | )
37 | page1 = requests.get(mov_link)
38 | soup = bs4.BeautifulSoup(page1.content, "lxml")
39 | if soup.find("div", "poster"):
40 | poster = soup.find("div", "poster").img["src"]
41 | else:
42 | poster = ""
43 | if soup.find("div", "title_wrapper"):
44 | pg = soup.find("div", "title_wrapper").findNext("div").text
45 | mov_details = re.sub(r"\s+", " ", pg)
46 | else:
47 | mov_details = ""
48 | credits = soup.findAll("div", "credit_summary_item")
49 | if len(credits) == 1:
50 | director = credits[0].a.text
51 | writer = "Not available"
52 | stars = "Not available"
53 | elif len(credits) > 2:
54 | director = credits[0].a.text
55 | writer = credits[1].a.text
56 | actors = []
57 | for x in credits[2].findAll("a"):
58 | actors.append(x.text)
59 | actors.pop()
60 | stars = actors[0] + "," + actors[1] + "," + actors[2]
61 | else:
62 | director = credits[0].a.text
63 | writer = "Not available"
64 | actors = []
65 | for x in credits[1].findAll("a"):
66 | actors.append(x.text)
67 | actors.pop()
68 | stars = actors[0] + "," + actors[1] + "," + actors[2]
69 | if soup.find("div", "inline canwrap"):
70 | story_line = soup.find("div", "inline canwrap").findAll("p")[0].text
71 | else:
72 | story_line = "Not available"
73 | info = soup.findAll("div", "txt-block")
74 | if info:
75 | mov_country = []
76 | mov_language = []
77 | for node in info:
78 | a = node.findAll("a")
79 | for i in a:
80 | if "country_of_origin" in i["href"]:
81 | mov_country.append(i.text)
82 | elif "primary_language" in i["href"]:
83 | mov_language.append(i.text)
84 | if soup.findAll("div", "ratingValue"):
85 | for r in soup.findAll("div", "ratingValue"):
86 | mov_rating = r.strong["title"]
87 | else:
88 | mov_rating = "Not available"
89 | await e.edit(
90 | ""
91 | "Title : "
92 | + mov_title
93 | + "\n"
94 | + mov_details
95 | + "\nRating : "
96 | + mov_rating
97 | + "\nCountry : "
98 | + mov_country[0]
99 | + "\nLanguage : "
100 | + mov_language[0]
101 | + "\nDirector : "
102 | + director
103 | + "\nWriter : "
104 | + writer
105 | + "\nStars : "
106 | + stars
107 | + "\nIMDB Url : "
108 | + mov_link
109 | + "\nStory Line : "
110 | + story_line,
111 | link_preview=True,
112 | parse_mode="HTML",
113 | )
114 | except IndexError:
115 | await e.edit("Plox enter **Valid movie name** kthx")
116 |
--------------------------------------------------------------------------------
/userbot/plugins/quotly.py:
--------------------------------------------------------------------------------
1 | """
2 | imported from nicegrill
3 | modified by @mrconfused
4 | QuotLy: Avaible commands: .qbot
5 | """
6 | import os
7 |
8 | from telethon import events
9 | from telethon.errors.rpcerrorlist import YouBlockedUserError
10 |
11 | from .. import process
12 | from ..utils import admin_cmd, sudo_cmd
13 |
14 |
15 | @borg.on(admin_cmd(pattern="q(?: |$)(.*)"))
16 | async def stickerchat(catquotes):
17 | if catquotes.fwd_from:
18 | return
19 | reply = await catquotes.get_reply_message()
20 | if not reply:
21 | await catquotes.edit("I cant quote the message . reply to a message")
22 | return
23 | fetchmsg = reply.message
24 | repliedreply = await reply.get_reply_message()
25 | if reply.media:
26 | if reply.media.document.mime_type in ("mp4"):
27 | await catquotes.edit("animated stickers and mp4 formats are not supported")
28 | return
29 | await catquotes.delete()
30 | user = (
31 | await borg.get_entity(reply.forward.sender) if reply.fwd_from else reply.sender
32 | )
33 | res, catmsg = await process(fetchmsg, user, borg, reply, repliedreply)
34 | if not res:
35 | return
36 | catmsg.save("./temp/sticker.webp")
37 | await borg.send_file(catquotes.chat_id, "./temp/sticker.webp", reply_to=reply)
38 | os.remove("./temp/sticker.webp")
39 |
40 |
41 | @borg.on(admin_cmd(pattern="qbot(?: |$)(.*)", outgoing=True))
42 | async def _(event):
43 | if event.fwd_from:
44 | return
45 | if not event.reply_to_msg_id:
46 | await event.edit("```Reply to any user message.```")
47 | return
48 | reply_message = await event.get_reply_message()
49 | if not reply_message.text:
50 | await event.edit("```Reply to text message```")
51 | return
52 | chat = "@QuotLyBot"
53 | reply_message.sender
54 | if reply_message.sender.bot:
55 | await event.edit("```Reply to actual users message.```")
56 | return
57 | await event.edit("```Making a Quote```")
58 | async with event.client.conversation(chat) as conv:
59 | try:
60 | response = conv.wait_event(
61 | events.NewMessage(incoming=True, from_users=1031952739)
62 | )
63 | await event.client.forward_messages(chat, reply_message)
64 | response = await response
65 | except YouBlockedUserError:
66 | await event.reply("```Please unblock me (@QuotLyBot) u Nigga```")
67 | return
68 | await borg.send_read_acknowledge(conv.chat_id)
69 | if response.text.startswith("Hi!"):
70 | await event.edit(
71 | "```Can you kindly disable your forward privacy settings for good?```"
72 | )
73 | else:
74 | await event.delete()
75 | await event.client.send_message(event.chat_id, response.message)
76 |
77 |
78 | @borg.on(sudo_cmd(pattern="qbot(?: |$)(.*)", allow_sudo=True))
79 | async def _(event):
80 | if event.fwd_from:
81 | return
82 | if not event.reply_to_msg_id:
83 | await event.reply("```Reply to any user message.```")
84 | return
85 | reply_message = await event.get_reply_message()
86 | if not reply_message.text:
87 | await event.reply("```Reply to text message```")
88 | return
89 | chat = "@QuotLyBot"
90 | reply_message.sender
91 | if reply_message.sender.bot:
92 | await event.reply("```Reply to actual users message.```")
93 | return
94 | cat = await event.reply("```Making a Quote```")
95 | await borg.send_read_acknowledge(conv.chat_id)
96 | async with event.client.conversation(chat) as conv:
97 | try:
98 | response = conv.wait_event(
99 | events.NewMessage(incoming=True, from_users=1031952739)
100 | )
101 | await event.client.forward_messages(chat, reply_message)
102 | response = await response
103 | except YouBlockedUserError:
104 | await event.reply("```Please unblock me (@QuotLyBot) u Nigga```")
105 | return
106 | if response.text.startswith("Hi!"):
107 | await event.reply(
108 | "```Can you kindly disable your forward privacy settings for good?```"
109 | )
110 | else:
111 | await cat.delete()
112 | await event.client.send_message(event.chat_id, response.message)
113 |
--------------------------------------------------------------------------------
/userbot/plugins/telegraph.py:
--------------------------------------------------------------------------------
1 | """@telegraph Utilities
2 | Available Commands:
3 | .telegraph media as reply to a media
4 | .telegraph text as reply to a large text"""
5 | import os
6 | from datetime import datetime
7 |
8 | from PIL import Image
9 | from telegraph import Telegraph, exceptions, upload_file
10 |
11 | from userbot.utils import admin_cmd
12 |
13 | telegraph = Telegraph()
14 | r = telegraph.create_account(short_name=Config.TELEGRAPH_SHORT_NAME)
15 | auth_url = r["auth_url"]
16 |
17 | if Config.PRIVATE_GROUP_BOT_API_ID is None:
18 | BOTLOG = False
19 | else:
20 | BOTLOG = True
21 | BOTLOG_CHATID = Config.PRIVATE_GROUP_BOT_API_ID
22 |
23 |
24 | @borg.on(admin_cmd(pattern="telegraph (media|text) ?(.*)"))
25 | async def _(event):
26 | if event.fwd_from:
27 | return
28 | if not os.path.isdir(Config.TMP_DOWNLOAD_DIRECTORY):
29 | os.makedirs(Config.TMP_DOWNLOAD_DIRECTORY)
30 | if BOTLOG:
31 | await borg.send_message(
32 | Config.PRIVATE_GROUP_BOT_API_ID,
33 | "Created New Telegraph account {} for the current session. \n**Do not give this url to anyone, even if they say they are from Telegram!**".format(
34 | auth_url
35 | ),
36 | )
37 | optional_title = event.pattern_match.group(2)
38 | if event.reply_to_msg_id:
39 | start = datetime.now()
40 | r_message = await event.get_reply_message()
41 | input_str = event.pattern_match.group(1)
42 | if input_str == "media":
43 | downloaded_file_name = await borg.download_media(
44 | r_message, Config.TMP_DOWNLOAD_DIRECTORY
45 | )
46 | end = datetime.now()
47 | ms = (end - start).seconds
48 | await event.edit(
49 | "Downloaded to {} in {} seconds.".format(downloaded_file_name, ms)
50 | )
51 | if downloaded_file_name.endswith((".webp")):
52 | resize_image(downloaded_file_name)
53 | try:
54 | start = datetime.now()
55 | media_urls = upload_file(downloaded_file_name)
56 | except exceptions.TelegraphException as exc:
57 | await event.edit("ERROR: " + str(exc))
58 | os.remove(downloaded_file_name)
59 | else:
60 | end = datetime.now()
61 | ms_two = (end - start).seconds
62 | os.remove(downloaded_file_name)
63 | await event.edit(
64 | "Uploaded to https://telegra.ph{} in {} seconds.".format(
65 | media_urls[0], (ms + ms_two)
66 | ),
67 | link_preview=True,
68 | )
69 | elif input_str == "text":
70 | user_object = await borg.get_entity(r_message.from_id)
71 | title_of_page = user_object.first_name # + " " + user_object.last_name
72 | # apparently, all Users do not have last_name field
73 | if optional_title:
74 | title_of_page = optional_title
75 | page_content = r_message.message
76 | if r_message.media:
77 | if page_content != "":
78 | title_of_page = page_content
79 | downloaded_file_name = await borg.download_media(
80 | r_message, Config.TMP_DOWNLOAD_DIRECTORY
81 | )
82 | m_list = None
83 | with open(downloaded_file_name, "rb") as fd:
84 | m_list = fd.readlines()
85 | for m in m_list:
86 | page_content += m.decode("UTF-8") + "\n"
87 | os.remove(downloaded_file_name)
88 | page_content = page_content.replace("\n", "
")
89 | response = telegraph.create_page(title_of_page, html_content=page_content)
90 | end = datetime.now()
91 | ms = (end - start).seconds
92 | await event.edit(
93 | "Pasted to https://telegra.ph/{} in {} seconds.".format(
94 | response["path"], ms
95 | ),
96 | link_preview=True,
97 | )
98 | else:
99 | await event.edit(
100 | "Reply to a message to get a permanent telegra.ph link. (Inspired by @ControllerBot)"
101 | )
102 |
103 |
104 | def resize_image(image):
105 | im = Image.open(image)
106 | im.save(image, "PNG")
107 |
--------------------------------------------------------------------------------
/userbot/plugins/corecmds.py:
--------------------------------------------------------------------------------
1 | import asyncio
2 | import os
3 | from datetime import datetime
4 | from pathlib import Path
5 |
6 | from .. import ALIVE_NAME
7 | from ..utils import admin_cmd, edit_or_reply, load_module, remove_plugin, sudo_cmd
8 |
9 | DELETE_TIMEOUT = 5
10 | thumb_image_path = Config.TMP_DOWNLOAD_DIRECTORY + "/thumb_image.jpg"
11 | DEFAULTUSER = str(ALIVE_NAME) if ALIVE_NAME else "cat"
12 |
13 |
14 | @borg.on(admin_cmd(pattern="install$"))
15 | @borg.on(sudo_cmd(pattern="install$", allow_sudo=True))
16 | async def install(event):
17 | if event.fwd_from:
18 | return
19 | if event.reply_to_msg_id:
20 | try:
21 | downloaded_file_name = (
22 | await event.client.download_media( # pylint:disable=E0602
23 | await event.get_reply_message(),
24 | "userbot/plugins/", # pylint:disable=E0602
25 | )
26 | )
27 | if "(" not in downloaded_file_name:
28 | path1 = Path(downloaded_file_name)
29 | shortname = path1.stem
30 | load_module(shortname.replace(".py", ""))
31 | await edit_or_reply(
32 | event,
33 | "Installed Plugin `{}`".format(
34 | os.path.basename(downloaded_file_name)
35 | ),
36 | )
37 | else:
38 | os.remove(downloaded_file_name)
39 | await edit_or_reply(
40 | event, "Errors! This plugin is already installed/pre-installed."
41 | )
42 | except Exception as e: # pylint:disable=C0103,W0703
43 | await edit_or_reply(event, str(e))
44 | os.remove(downloaded_file_name)
45 | await asyncio.sleep(DELETE_TIMEOUT)
46 | await event.delete()
47 |
48 |
49 | @borg.on(admin_cmd(pattern=r"send (?P\w+)$", outgoing=True))
50 | @borg.on(sudo_cmd(pattern=r"send (?P\w+)$", allow_sudo=True))
51 | async def send(event):
52 | if event.fwd_from:
53 | return
54 | reply_to_id = None
55 | if event.reply_to_msg_id:
56 | reply_to_id = event.reply_to_msg_id
57 | thumb = None
58 | if os.path.exists(thumb_image_path):
59 | thumb = thumb_image_path
60 | input_str = event.pattern_match["shortname"]
61 | the_plugin_file = "./userbot/plugins/{}.py".format(input_str)
62 | if os.path.exists(the_plugin_file):
63 | start = datetime.now()
64 | caat = await event.client.send_file( # pylint:disable=E0602
65 | event.chat_id,
66 | the_plugin_file,
67 | force_document=True,
68 | allow_cache=False,
69 | reply_to=reply_to_id,
70 | thumb=thumb,
71 | )
72 | end = datetime.now()
73 | ms = (end - start).seconds
74 | await event.delete()
75 | await caat.edit(
76 | f"__**➥ Plugin Name:- {input_str} .**__\n__**➥ Uploaded in {ms} seconds.**__\n__**➥ Uploaded by :-**__ {DEFAULTUSER}"
77 | )
78 | else:
79 | await edit_or_reply(event, "404: File Not Found")
80 |
81 |
82 | @borg.on(admin_cmd(pattern=r"unload (?P\w+)$", outgoing=True))
83 | @borg.on(sudo_cmd(pattern=r"unload (?P\w+)$", allow_sudo=True))
84 | async def unload(event):
85 | if event.fwd_from:
86 | return
87 | shortname = event.pattern_match["shortname"]
88 | try:
89 | remove_plugin(shortname)
90 | await edit_or_reply(event, f"Unloaded {shortname} successfully")
91 | except Exception as e:
92 | await edit_or_reply(
93 | event, "Successfully unload {shortname}\n{}".format(shortname, str(e))
94 | )
95 |
96 |
97 | @borg.on(admin_cmd(pattern=r"load (?P\w+)$", outgoing=True))
98 | @borg.on(sudo_cmd(pattern=r"load (?P\w+)$", allow_sudo=True))
99 | async def load(event):
100 | if event.fwd_from:
101 | return
102 | shortname = event.pattern_match["shortname"]
103 | try:
104 | try:
105 | remove_plugin(shortname)
106 | except BaseException:
107 | pass
108 | load_module(shortname)
109 | await edit_or_reply(event, f"Successfully loaded {shortname}")
110 | except Exception as e:
111 | await edit_or_reply(
112 | event,
113 | f"Could not load {shortname} because of the following error.\n{str(e)}",
114 | )
115 |
--------------------------------------------------------------------------------
/userbot/plugins/fun.py:
--------------------------------------------------------------------------------
1 | """COMMAND : .join , .pay , .work , .push , .aag , .climb"""
2 | from telethon.tl.types import ChannelParticipantsAdmins
3 |
4 | from userbot.utils import admin_cmd
5 |
6 |
7 | @borg.on(admin_cmd(pattern="join$"))
8 | async def _(event):
9 | if event.fwd_from:
10 | return
11 | mentions = "`━━━━━┓ \n┓┓┓┓┓┃\n┓┓┓┓┓┃ ヽ○ノ ⇦ Me When You Joined \n┓┓┓┓┓┃. / \n┓┓┓┓┓┃ ノ) \n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃`"
12 | chat = await event.get_input_chat()
13 | async for x in borg.iter_participants(chat, filter=ChannelParticipantsAdmins):
14 | mentions += f""
15 | reply_message = None
16 | if event.reply_to_msg_id:
17 | reply_message = await event.get_reply_message()
18 | await reply_message.reply(mentions)
19 | else:
20 | await event.reply(mentions)
21 | await event.delete()
22 |
23 |
24 | @borg.on(admin_cmd(pattern="pay$"))
25 | async def _(event):
26 | if event.fwd_from:
27 | return
28 | mentions = "`█▀▀▀▀▀█░▀▀░░░█░░░░█▀▀▀▀▀█\n█░███░█░█▄░█▀▀░▄▄░█░███░█\n█░▀▀▀░█░▀█▀▀▄▀█▀▀░█░▀▀▀░█\n▀▀▀▀▀▀▀░▀▄▀▄▀▄█▄▀░▀▀▀▀▀▀▀\n█▀█▀▄▄▀░█▄░░░▀▀░▄█░▄▀█▀░▀\n░█▄▀░▄▀▀░░░▄▄▄█░▀▄▄▄▀▄▄▀▄\n░░▀█░▀▀▀▀▀▄█░▄░████ ██▀█▄\n▄▀█░░▄▀█▀█▀░█▄▀░▀█▄██▀░█▄\n░░▀▀▀░▀░█▄▀▀▄▄░▄█▀▀▀█░█▀▀\n█▀▀▀▀▀█░░██▀█░░▄█░▀░█▄░██\n█░███░█░▄▀█▀██▄▄▀▀█▀█▄░▄▄\n█░▀▀▀░█░█░░▀▀▀░█░▀▀▀▀▄█▀░\n▀▀▀▀▀▀▀░▀▀░░▀░▀░░░▀▀░▀▀▀▀`"
29 | chat = await event.get_input_chat()
30 | async for x in borg.iter_participants(chat, filter=ChannelParticipantsAdmins):
31 | mentions += f""
32 | reply_message = None
33 | if event.reply_to_msg_id:
34 | reply_message = await event.get_reply_message()
35 | await reply_message.reply(mentions)
36 | else:
37 | await event.reply(mentions)
38 | await event.delete()
39 |
40 |
41 | @borg.on(admin_cmd(pattern="climb$"))
42 | async def _(event):
43 | if event.fwd_from:
44 | return
45 | mentions = "`😏/\n/▌ \n/ \\n████\n╬╬\n╬╬\n╬╬\n╬╬\n╬╬\n╬╬\n╬╬\😦\n╬╬/▌\n╬╬/\`"
46 | chat = await event.get_input_chat()
47 | async for x in borg.iter_participants(chat, filter=ChannelParticipantsAdmins):
48 | mentions += f""
49 | reply_message = None
50 | if event.reply_to_msg_id:
51 | reply_message = await event.get_reply_message()
52 | await reply_message.reply(mentions)
53 | else:
54 | await event.reply(mentions)
55 | await event.delete()
56 |
57 |
58 | @borg.on(admin_cmd(pattern="aag$"))
59 | async def _(event):
60 | if event.fwd_from:
61 | return
62 | mentions = "`😲💨 🔥\n/|\ 🔥🔥\n/ \ 🔥🔥🔥`"
63 | chat = await event.get_input_chat()
64 | async for x in borg.iter_participants(chat, filter=ChannelParticipantsAdmins):
65 | mentions += f""
66 | reply_message = None
67 | if event.reply_to_msg_id:
68 | reply_message = await event.get_reply_message()
69 | await reply_message.reply(mentions)
70 | else:
71 | await event.reply(mentions)
72 | await event.delete()
73 |
74 |
75 | @borg.on(admin_cmd(pattern="push$"))
76 | async def _(event):
77 | if event.fwd_from:
78 | return
79 | mentions = "`. 😎\n |\👐\n / \\\n━━━━━┓ \\ \n┓┓┓┓┓┃\n┓┓┓┓┓┃ ヽ😩ノ\n┓┓┓┓┓┃ / \n┓┓┓┓┓┃ ノ) \n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃\n┓┓┓┓┓┃`"
80 | chat = await event.get_input_chat()
81 | async for x in borg.iter_participants(chat, filter=ChannelParticipantsAdmins):
82 | mentions += f""
83 | reply_message = None
84 | if event.reply_to_msg_id:
85 | reply_message = await event.get_reply_message()
86 | await reply_message.reply(mentions)
87 | else:
88 | await event.reply(mentions)
89 | await event.delete()
90 |
91 |
92 | @borg.on(admin_cmd(pattern="work$"))
93 | async def _(event):
94 | if event.fwd_from:
95 | return
96 | mentions = "`📔📚 📚\n📓📚📖 😫 📚📚📓\n📕📚📚 📝 📗💻📘\n📖📖📖📖📖📖📖📖📖`"
97 | chat = await event.get_input_chat()
98 | async for x in borg.iter_participants(chat, filter=ChannelParticipantsAdmins):
99 | mentions += f""
100 | reply_message = None
101 | if event.reply_to_msg_id:
102 | reply_message = await event.get_reply_message()
103 | await reply_message.reply(mentions)
104 | else:
105 | await event.reply(mentions)
106 | await event.delete()
107 |
--------------------------------------------------------------------------------