├── runtime.txt ├── Procfile ├── .gitlab-ci.yml ├── heroku.yml ├── userbot ├── helpers │ ├── styles │ │ ├── digital.ttf │ │ └── impact.ttf │ ├── __init__.py │ ├── exceptions.py │ └── progress.py ├── plugins │ ├── sql_helper │ │ ├── DS_Store │ │ ├── __init__.py │ │ ├── no_log_pms_sql.py │ │ ├── gmute_sql.py │ │ ├── mute_sql.py │ │ ├── pmpermit_sql.py │ │ ├── echo_sql.py │ │ ├── google_drive_sql.py │ │ ├── globals.py │ │ ├── snip_sql.py │ │ ├── lydia_ai_sql.py │ │ ├── gban_sql_helper.py │ │ ├── gdrive_sql.py │ │ ├── snips_sql.py │ │ ├── welcome_sql.py │ │ ├── welcomesql.py │ │ ├── filter_sql.py │ │ ├── locks_sql.py │ │ ├── antiflood_sql.py │ │ └── blacklist_sql.py │ ├── hyperlink.py │ ├── repeat.py │ ├── resend.py │ ├── kk.py │ ├── funtxts.py │ ├── README.md │ ├── scramble │ ├── schd.py │ ├── pin_message.py │ ├── frwd.py │ ├── fpost.py │ ├── quotes.py │ ├── get_id.py │ ├── json.py │ ├── chain.py │ ├── gizoogle │ ├── fileext.py │ ├── undlt.py │ ├── gali.py │ ├── linkpreview.py │ ├── get_bot.py │ ├── yify │ ├── transfer_channel.py │ ├── spotify_downloader.py │ ├── selfdestruct.py │ ├── calc.py │ ├── coronavirus.py │ ├── shout.py │ ├── figlet.py │ ├── translate.py │ ├── dictionary.py │ ├── ezanvakti.py │ ├── externalplugins.py │ ├── images.py │ ├── power_tools.py │ ├── inline.py │ ├── gbun.py │ ├── emojify.py │ ├── ocr.py │ ├── mention.py │ ├── mashup.py │ ├── dagd.py │ ├── antiflood.py │ ├── randomsticker.py │ ├── warnbun.py │ ├── gps.py │ ├── hash.py │ ├── speedtest.py │ ├── gdrive_download.py │ ├── tts.py │ ├── stt.py │ ├── greetings.py │ ├── create.py │ ├── invite.py │ ├── channel_download.py │ ├── autopfp.py │ ├── poll.py │ ├── antispambot.py │ ├── recognize.py │ ├── sed.py │ ├── poto.py │ ├── fake.py │ ├── stat.py │ ├── blacklist.py │ ├── imdb.py │ ├── quotly.py │ ├── telegraph.py │ ├── corecmds.py │ └── fun.py └── __main__.py ├── .deepsource.toml ├── var.py ├── Dockerfile ├── telesetup.py ├── requirements.txt ├── .github └── workflows │ ├── pythonapp.yml │ └── pylint.yml ├── .gitignore ├── README.md ├── heroku_config.py └── app.json /runtime.txt: -------------------------------------------------------------------------------- 1 | python-3.8.5 2 | -------------------------------------------------------------------------------- /Procfile: -------------------------------------------------------------------------------- 1 | userbot: python -m userbot 2 | -------------------------------------------------------------------------------- /.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | CheckUserBotWorking: 2 | script: 3 | - echo "Nothing" 4 | -------------------------------------------------------------------------------- /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | worker: Dockerfile 4 | run: 5 | worker: python3 -m userbot 6 | -------------------------------------------------------------------------------- /userbot/helpers/styles/digital.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xditya/catuserbot/master/userbot/helpers/styles/digital.ttf -------------------------------------------------------------------------------- /userbot/helpers/styles/impact.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xditya/catuserbot/master/userbot/helpers/styles/impact.ttf -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xditya/catuserbot/master/userbot/plugins/sql_helper/DS_Store -------------------------------------------------------------------------------- /.deepsource.toml: -------------------------------------------------------------------------------- 1 | version = 1 2 | 3 | [[analyzers]] 4 | name = "python" 5 | enabled = true 6 | 7 | [analyzers.meta] 8 | runtime_version = "3.x.x" -------------------------------------------------------------------------------- /userbot/helpers/__init__.py: -------------------------------------------------------------------------------- 1 | from . import fonts 2 | from .exceptions import CancelProcess 3 | from .functions import * 4 | from .memeifyhelpers import * 5 | from .progress import progress 6 | from .qhelper import process 7 | -------------------------------------------------------------------------------- /var.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | ENV = bool(os.environ.get("ENV", False)) 4 | if ENV: 5 | from heroku_config import Var as Config 6 | else: 7 | from local_config import Development as Config 8 | 9 | 10 | Var = Config 11 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM sandy1709/catuserbot:latest 2 | 3 | #clonning repo 4 | RUN git clone https://github.com/sandy1709/catuserbot.git /root/userbot 5 | #working directory 6 | WORKDIR /root/userbot 7 | 8 | # Install requirements 9 | RUN pip3 install -U -r requirements.txt 10 | 11 | ENV PATH="/home/userbot/bin:$PATH" 12 | 13 | CMD ["python3","-m","userbot"] 14 | -------------------------------------------------------------------------------- /userbot/plugins/hyperlink.py: -------------------------------------------------------------------------------- 1 | # For UniBorg 2 | # By Priyam Kalra 3 | # Syntax (.hl ) 4 | 5 | from userbot.utils import admin_cmd 6 | 7 | 8 | @borg.on(admin_cmd(pattern="hl ?(.*)")) 9 | async def _(event): 10 | if event.fwd_from: 11 | return 12 | input = event.pattern_match.group(1) 13 | await event.edit("[ㅤㅤㅤㅤㅤㅤㅤ](" + input + ")") 14 | -------------------------------------------------------------------------------- /userbot/plugins/repeat.py: -------------------------------------------------------------------------------- 1 | from asyncio import wait 2 | 3 | from userbot.utils import admin_cmd 4 | 5 | 6 | @borg.on(admin_cmd(pattern="repeat ?(.*)")) 7 | async def _(event): 8 | message = event.text[10:] 9 | count = int(event.text[8:10]) 10 | repmessage = message * count 11 | await wait([event.respond(repmessage)]) 12 | await event.delete() 13 | -------------------------------------------------------------------------------- /userbot/plugins/resend.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 | from userbot.utils import admin_cmd 6 | 7 | 8 | @borg.on(admin_cmd(pattern="resend")) 9 | async def _(event): 10 | await event.delete() 11 | m = await event.get_reply_message() 12 | if not m: 13 | return 14 | await event.respond(m) 15 | -------------------------------------------------------------------------------- /userbot/plugins/kk.py: -------------------------------------------------------------------------------- 1 | """command: .kk""" 2 | """By @Grandpaa_please """ 3 | 4 | 5 | import random 6 | 7 | from telethon import events 8 | 9 | 10 | @borg.on(events.NewMessage(pattern=r"\.(.*)", outgoing=True)) 11 | async def _(event): 12 | input_str = event.pattern_match.group(1) 13 | if input_str == "kk": 14 | r = random.randint(0, 3) 15 | logger.debug(r) 16 | if r == 0: 17 | await event.edit("┏━━━┓\n┃┏━━┛\n┃┗━━┓\n┃┏━━┛\n┃┃\n┗┛") 18 | else: 19 | await event.edit("╭━━━╮\n┃╭━━╯\n┃╰━━╮\n┃╭━━╯\n┃┃\n╰╯") 20 | -------------------------------------------------------------------------------- /userbot/plugins/funtxts.py: -------------------------------------------------------------------------------- 1 | import nekos 2 | 3 | from ..utils import admin_cmd 4 | 5 | 6 | @borg.on(admin_cmd(pattern="tcat$")) 7 | async def hmm(cat): 8 | if cat.fwd_from: 9 | return 10 | reactcat = nekos.textcat() 11 | await cat.edit(reactcat) 12 | 13 | 14 | @borg.on(admin_cmd(pattern="why$")) 15 | async def hmm(cat): 16 | if cat.fwd_from: 17 | return 18 | whycat = nekos.why() 19 | await cat.edit(whycat) 20 | 21 | 22 | @borg.on(admin_cmd(pattern="fact$")) 23 | async def hmm(cat): 24 | if cat.fwd_from: 25 | return 26 | factcat = nekos.fact() 27 | await cat.edit(factcat) 28 | -------------------------------------------------------------------------------- /userbot/plugins/README.md: -------------------------------------------------------------------------------- 1 | ## Mandatory Imports 2 | ```python3 3 | None 4 | ``` 5 | There is None Mandatory Imports. Because Var, bot and command are already automatically imported. 6 | 7 | ## Explanation 8 | The Mandatory Imports are now automatically imported. 9 | 10 | ### Formation 11 | Now I will show a short script to show the formation of the desired script. 12 | ```python3 13 | from userbot.utils import admin_cmd 14 | 15 | @borg.on(admin_cmd(pattern="alive", outgoing=True)) 16 | async def hello_world(event): 17 | if event.fwd_from: 18 | return 19 | await event.edit("**HELLO WORLD**\n\nThe following is controlling me too!\n" + Var.SUDO_USERS) 20 | ``` 21 | -------------------------------------------------------------------------------- /telesetup.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # (c) https://t.me/TelethonChat/37677 3 | # This Source Code Form is subject to the terms of the GNU 4 | # General Public License, v.3.0. If a copy of the GPL was not distributed with this 5 | # file, You can obtain one at https://www.gnu.org/licenses/gpl-3.0.en.html. 6 | 7 | from telethon.sessions import StringSession 8 | from telethon.sync import TelegramClient 9 | 10 | print( 11 | """Please go-to my.telegram.org 12 | Login using your Telegram account 13 | Click on API Development Tools 14 | Create a new application, by entering the required details""" 15 | ) 16 | APP_ID = int(input("Enter APP ID here: ")) 17 | API_HASH = input("Enter API HASH here: ") 18 | 19 | with TelegramClient(StringSession(), APP_ID, API_HASH) as client: 20 | print(client.session.save()) 21 | -------------------------------------------------------------------------------- /userbot/plugins/scramble: -------------------------------------------------------------------------------- 1 | """ 2 | thx to @r4v4n4 3 | """ 4 | 5 | import random 6 | import re 7 | 8 | from userbot.utils import admin_cmd 9 | 10 | 11 | @borg.on(admin_cmd(pattern=r"scramble(\s+[\S\s]+|$)")) 12 | async def scramble_message(e): 13 | reply_message = await e.get_reply_message() 14 | text = e.pattern_match.group(1) or reply_message.text 15 | words = re.split(r"\s", text) 16 | scrambled = map(scramble_word, words) 17 | text = " ".join(scrambled) 18 | await e.edit(text) 19 | 20 | 21 | def scramble_word(word): 22 | if len(word) < 4: 23 | return word 24 | 25 | first_letter = word[0] 26 | last_letter = word[-1] 27 | middle_letters = list(word[1:-1]) 28 | random.shuffle(middle_letters) 29 | 30 | return first_letter + "".join(middle_letters) + last_letter 31 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | from sqlalchemy import create_engine 4 | from sqlalchemy.ext.declarative import declarative_base 5 | from sqlalchemy.orm import scoped_session, sessionmaker 6 | 7 | # the secret configuration specific things 8 | from var import Var 9 | 10 | 11 | def start() -> scoped_session: 12 | engine = create_engine(Var.DB_URI) 13 | BASE.metadata.bind = engine 14 | BASE.metadata.create_all(engine) 15 | return scoped_session(sessionmaker(bind=engine, autoflush=False)) 16 | 17 | 18 | try: 19 | BASE = declarative_base() 20 | SESSION = start() 21 | except AttributeError as e: 22 | # this is a dirty way for the work-around required for #23 23 | print( 24 | "DB_URI is not configured. Features depending on the database might have issues." 25 | ) 26 | print(str(e)) 27 | -------------------------------------------------------------------------------- /userbot/helpers/exceptions.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 | class CancelProcess(Exception): 19 | """ 20 | Cancel Process 21 | """ 22 | -------------------------------------------------------------------------------- /userbot/plugins/schd.py: -------------------------------------------------------------------------------- 1 | """Schedule Plugin for @UniBorg 2 | Syntax: .schd ;=; """ 3 | import asyncio 4 | 5 | from userbot.utils import admin_cmd 6 | 7 | 8 | @borg.on(admin_cmd(pattern="schd ?(.*)")) 9 | async def _(event): 10 | if event.fwd_from: 11 | return 12 | input_str = event.pattern_match.group(1) 13 | ttl = 0 14 | message = "SYNTAX: `.schd = `" 15 | if input_str: 16 | await event.delete() 17 | if "=" in input_str: 18 | ttl, message = input_str.split("=") 19 | elif event.reply_to_msg_id: 20 | await event.delete() 21 | ttl = int(input_str) 22 | message = await event.get_reply_message() 23 | await asyncio.sleep(int(ttl)) 24 | await event.respond(message) 25 | else: 26 | await event.edit(message) 27 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/no_log_pms_sql.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import Column, Numeric 2 | 3 | from userbot.plugins.sql_helper import BASE, SESSION 4 | 5 | 6 | class NOLogPMs(BASE): 7 | __tablename__ = "no_log_pms" 8 | chat_id = Column(Numeric, primary_key=True) 9 | 10 | def __init__(self, chat_id, reason=""): 11 | self.chat_id = chat_id 12 | 13 | 14 | NOLogPMs.__table__.create(checkfirst=True) 15 | 16 | 17 | def is_approved(chat_id): 18 | try: 19 | return SESSION.query(NOLogPMs).filter(NOLogPMs.chat_id == chat_id).one() 20 | except BaseException: 21 | return None 22 | finally: 23 | SESSION.close() 24 | 25 | 26 | def approve(chat_id): 27 | adder = NOLogPMs(chat_id) 28 | SESSION.add(adder) 29 | SESSION.commit() 30 | 31 | 32 | def disapprove(chat_id): 33 | rem = SESSION.query(NOLogPMs).get(chat_id) 34 | if rem: 35 | SESSION.delete(rem) 36 | SESSION.commit() 37 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/gmute_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.plugins.sql_helper import BASE, SESSION 3 | except ImportError: 4 | raise Exception("Hello!") 5 | 6 | from sqlalchemy import Column, String 7 | 8 | 9 | class GMute(BASE): 10 | __tablename__ = "gmute" 11 | sender = Column(String(14), primary_key=True) 12 | 13 | def __init__(self, sender): 14 | self.sender = str(sender) 15 | 16 | 17 | GMute.__table__.create(checkfirst=True) 18 | 19 | 20 | def is_gmuted(sender_id): 21 | try: 22 | return SESSION.query(GMute).all() 23 | except BaseException: 24 | return None 25 | finally: 26 | SESSION.close() 27 | 28 | 29 | def gmute(sender): 30 | adder = GMute(str(sender)) 31 | SESSION.add(adder) 32 | SESSION.commit() 33 | 34 | 35 | def ungmute(sender): 36 | rem = SESSION.query(GMute).get((str(sender))) 37 | if rem: 38 | SESSION.delete(rem) 39 | SESSION.commit() 40 | -------------------------------------------------------------------------------- /userbot/plugins/pin_message.py: -------------------------------------------------------------------------------- 1 | """Pins the replied message 2 | Syntax: .cpin [LOUD]""" 3 | from telethon.tl import functions 4 | 5 | from userbot.utils import admin_cmd 6 | 7 | 8 | @borg.on(admin_cmd(pattern="cpin(?: |$)(.*)")) 9 | async def _(event): 10 | if event.fwd_from: 11 | return 12 | silent = True 13 | input_str = event.pattern_match.group(1) 14 | if input_str: 15 | silent = False 16 | if event.message.reply_to_msg_id is not None: 17 | message_id = event.message.reply_to_msg_id 18 | try: 19 | await borg( 20 | functions.messages.UpdatePinnedMessageRequest( 21 | event.chat_id, message_id, silent 22 | ) 23 | ) 24 | except Exception as e: 25 | await event.edit(str(e)) 26 | else: 27 | await event.delete() 28 | else: 29 | await event.edit("Reply to a message to pin the message in this Channel.") 30 | -------------------------------------------------------------------------------- /userbot/plugins/frwd.py: -------------------------------------------------------------------------------- 1 | """Enable Seen Counter in any message, 2 | to know how many users have seen your message 3 | Syntax: .frwd as reply to any message""" 4 | from ..utils import admin_cmd 5 | 6 | 7 | @borg.on(admin_cmd(pattern="frwd")) 8 | async def _(event): 9 | if event.fwd_from: 10 | return 11 | if Config.PRIVATE_CHANNEL_BOT_API_ID is None: 12 | await event.edit( 13 | "Please set the required environment variable `PRIVATE_CHANNEL_BOT_API_ID` for this plugin to work" 14 | ) 15 | return 16 | try: 17 | e = await borg.get_entity(Config.PRIVATE_CHANNEL_BOT_API_ID) 18 | except Exception as e: 19 | await event.edit(str(e)) 20 | else: 21 | re_message = await event.get_reply_message() 22 | # https://t.me/telethonofftopic/78166 23 | fwd_message = await borg.forward_messages(e, re_message, silent=True) 24 | await borg.forward_messages(event.chat_id, fwd_message) 25 | await event.delete() 26 | -------------------------------------------------------------------------------- /userbot/plugins/fpost.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 | """ Command: .fpost word 5 | credit: @r4v4n4""" 6 | 7 | import string 8 | 9 | from userbot.utils import admin_cmd 10 | 11 | msg_cache = {} 12 | 13 | 14 | @borg.on(admin_cmd(pattern=r"fpost\s+(.*)")) 15 | async def _(event): 16 | await event.delete() 17 | text = event.pattern_match.group(1) 18 | destination = await event.get_input_chat() 19 | 20 | for c in text.lower(): 21 | if c not in string.ascii_lowercase: 22 | continue 23 | if c not in msg_cache: 24 | async for msg in borg.iter_messages(None, search=c): 25 | if msg.raw_text.lower() == c and msg.media is None: 26 | msg_cache[c] = msg 27 | break 28 | await borg.forward_messages(destination, msg_cache[c]) 29 | -------------------------------------------------------------------------------- /userbot/plugins/quotes.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | import requests 4 | 5 | from userbot.utils import admin_cmd 6 | 7 | 8 | @borg.on(admin_cmd(pattern="quote ?(.*)")) 9 | async def quote_search(event): 10 | if event.fwd_from: 11 | return 12 | await event.edit("Processing...") 13 | search_string = event.pattern_match.group(1) 14 | input_url = "https://bots.shrimadhavuk.me/Telegram/GoodReadsQuotesBot/?q={}".format( 15 | search_string 16 | ) 17 | headers = {"USER-AGENT": "UniBorg"} 18 | try: 19 | response = requests.get(input_url, headers=headers).json() 20 | except BaseException: 21 | response = None 22 | if response is not None: 23 | result = ( 24 | random.choice(response).get("input_message_content").get("message_text") 25 | ) 26 | else: 27 | result = None 28 | if result: 29 | await event.edit(result.replace("", "`").replace("", "`")) 30 | else: 31 | await event.edit("Zero results found") 32 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/mute_sql.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.plugins.sql_helper import BASE, SESSION 3 | except ImportError: 4 | raise Exception("Hello!") 5 | from sqlalchemy import Column, String 6 | 7 | 8 | class Mute(BASE): 9 | __tablename__ = "mute" 10 | sender = Column(String(14), primary_key=True) 11 | chat_id = Column(String(14), primary_key=True) 12 | 13 | def __init__(self, sender, chat_id): 14 | self.sender = str(sender) 15 | self.chat_id = str(chat_id) 16 | 17 | 18 | Mute.__table__.create(checkfirst=True) 19 | 20 | 21 | def is_muted(sender, chat_id): 22 | user = SESSION.query(Mute).get((str(sender), str(chat_id))) 23 | if user: 24 | return True 25 | return False 26 | 27 | 28 | def mute(sender, chat_id): 29 | adder = Mute(str(sender), str(chat_id)) 30 | SESSION.add(adder) 31 | SESSION.commit() 32 | 33 | 34 | def unmute(sender, chat_id): 35 | rem = SESSION.query(Mute).get((str(sender), str(chat_id))) 36 | if rem: 37 | SESSION.delete(rem) 38 | SESSION.commit() 39 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | telethon >= 1.16.1 2 | aiofiles 3 | aiohttp 4 | asyncurban 5 | beautifulsoup4 6 | cairosvg 7 | cfscrape 8 | coffeehouse 9 | covid 10 | cowpy 11 | cryptg 12 | csvfaker 13 | DateTime 14 | fontTools 15 | python-dotenv 16 | emoji 17 | fonttools 18 | geopy 19 | gitpython 20 | glitch_this 21 | google-api-python-client 22 | google-auth-httplib2 23 | google-auth-oauthlib 24 | google_images_download 25 | googletrans 26 | gsearch 27 | gtts 28 | hachoir 29 | heroku3 30 | httplib2<0.16.0 31 | humanize 32 | jotquote 33 | justwatch 34 | kwot 35 | lottie 36 | lxml 37 | lyricsgenius 38 | nekos.py 39 | oauth2client 40 | patool 41 | Pillow 42 | programmingquotes 43 | psutil 44 | psycopg2 45 | pybase64 46 | PyDictionary 47 | pyDownload 48 | pyfiglet 49 | PyGithub 50 | pylast 51 | PyLyrics 52 | pySmartDL 53 | python-barcode 54 | python-magic 55 | pytube>=9.5.1 56 | pytuneteller 57 | pytz 58 | qrcode 59 | regex 60 | requests 61 | search-engine-parser 62 | selenium 63 | spamwatch 64 | speedtest-cli 65 | sqlalchemy 66 | telegraph 67 | tswift 68 | validators 69 | wand 70 | wikipedia 71 | youtube-dl 72 | -------------------------------------------------------------------------------- /userbot/plugins/get_id.py: -------------------------------------------------------------------------------- 1 | """Get ID of any Telegram media, or any user 2 | Syntax: .get_id""" 3 | from telethon.utils import pack_bot_file_id 4 | 5 | from userbot.utils import admin_cmd 6 | 7 | 8 | @borg.on(admin_cmd(pattern="get_id")) 9 | async def _(event): 10 | if event.fwd_from: 11 | return 12 | if event.reply_to_msg_id: 13 | await event.get_input_chat() 14 | r_msg = await event.get_reply_message() 15 | if r_msg.media: 16 | bot_api_file_id = pack_bot_file_id(r_msg.media) 17 | await event.edit( 18 | "Current Chat ID: `{}`\nFrom User ID: `{}`\nBot API File ID: `{}`".format( 19 | str(event.chat_id), str(r_msg.from_id), bot_api_file_id 20 | ) 21 | ) 22 | else: 23 | await event.edit( 24 | "Current Chat ID: `{}`\nFrom User ID: `{}`".format( 25 | str(event.chat_id), str(r_msg.from_id) 26 | ) 27 | ) 28 | else: 29 | await event.edit("Current Chat ID: `{}`".format(str(event.chat_id))) 30 | -------------------------------------------------------------------------------- /.github/workflows/pythonapp.yml: -------------------------------------------------------------------------------- 1 | name: catChecker 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | strategy: 10 | max-parallel: 5 11 | matrix: 12 | python-version: [3.8] 13 | 14 | steps: 15 | - uses: actions/checkout@master 16 | - name: Set up Python ${{ matrix.python-version }} 17 | uses: actions/setup-python@master 18 | with: 19 | python-version: ${{ matrix.python-version }} 20 | - name: Install dependencies 21 | run: | 22 | sudo apt-get install libpq-dev 23 | python -m pip install --upgrade pip 24 | pip install -r requirements.txt 25 | pip install flake8 flake8-print flake8-quotes 26 | - name: Check for showstoppers 27 | run: | 28 | # stop the build if there are Python syntax errors 29 | flake8 . --count --select=E999 --show-source --statistics 30 | shellcheck: 31 | 32 | runs-on: ubuntu-latest 33 | 34 | steps: 35 | - uses: actions/checkout@master 36 | - name: Check for install script errors 37 | uses: ludeeus/action-shellcheck@master 38 | -------------------------------------------------------------------------------- /userbot/plugins/json.py: -------------------------------------------------------------------------------- 1 | """Get Detailed info about any message 2 | Syntax: .json""" 3 | import io 4 | 5 | from userbot.utils import admin_cmd 6 | 7 | 8 | @borg.on(admin_cmd(pattern="json")) 9 | async def _(event): 10 | if event.fwd_from: 11 | return 12 | the_real_message = None 13 | reply_to_id = None 14 | if event.reply_to_msg_id: 15 | previous_message = await event.get_reply_message() 16 | the_real_message = previous_message.stringify() 17 | reply_to_id = event.reply_to_msg_id 18 | else: 19 | the_real_message = event.stringify() 20 | reply_to_id = event.message.id 21 | if len(the_real_message) > Config.MAX_MESSAGE_SIZE_LIMIT: 22 | with io.BytesIO(str.encode(the_real_message)) as out_file: 23 | out_file.name = "json.text" 24 | await borg.send_file( 25 | event.chat_id, 26 | out_file, 27 | force_document=True, 28 | allow_cache=False, 29 | reply_to=reply_to_id, 30 | ) 31 | await event.delete() 32 | else: 33 | await event.edit("`{}`".format(the_real_message)) 34 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/pmpermit_sql.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import Column, String 2 | 3 | from userbot.plugins.sql_helper import BASE, SESSION 4 | 5 | 6 | class PMPermit(BASE): 7 | __tablename__ = "pmpermit" 8 | chat_id = Column(String(14), primary_key=True) 9 | reason = Column(String(127)) 10 | 11 | def __init__(self, chat_id, reason=""): 12 | self.chat_id = chat_id 13 | self.reason = reason 14 | 15 | 16 | PMPermit.__table__.create(checkfirst=True) 17 | 18 | 19 | def is_approved(chat_id): 20 | try: 21 | return SESSION.query(PMPermit).filter(PMPermit.chat_id == str(chat_id)).one() 22 | except BaseException: 23 | return None 24 | finally: 25 | SESSION.close() 26 | 27 | 28 | def approve(chat_id, reason): 29 | adder = PMPermit(str(chat_id), str(reason)) 30 | SESSION.add(adder) 31 | SESSION.commit() 32 | 33 | 34 | def disapprove(chat_id): 35 | rem = SESSION.query(PMPermit).get(str(chat_id)) 36 | if rem: 37 | SESSION.delete(rem) 38 | SESSION.commit() 39 | 40 | 41 | def get_all_approved(): 42 | rem = SESSION.query(PMPermit).all() 43 | SESSION.close() 44 | return rem 45 | -------------------------------------------------------------------------------- /userbot/plugins/chain.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 | from telethon.tl.functions.messages import SaveDraftRequest 5 | 6 | from .. import CMD_HELP 7 | from ..utils import admin_cmd, sudo_cmd 8 | 9 | 10 | @borg.on(admin_cmd(pattern="chain$")) 11 | @borg.on(sudo_cmd(pattern="chain$", allow_sudo=True)) 12 | async def _(event): 13 | await event.edit("Counting...") 14 | count = -1 15 | message = event.message 16 | while message: 17 | reply = await message.get_reply_message() 18 | if reply is None: 19 | await borg( 20 | SaveDraftRequest( 21 | await event.get_input_chat(), "", reply_to_msg_id=message.id 22 | ) 23 | ) 24 | message = reply 25 | count += 1 26 | await event.edit(f"Chain length: {count}") 27 | 28 | 29 | CMD_HELP.update( 30 | { 31 | "chain": "**SYNTAX :** `.chain`\ 32 | \n**USAGE : **Reply this command to any converstion where you want to find length of converstion(Only tagged chain will count ) \ 33 | " 34 | } 35 | ) 36 | -------------------------------------------------------------------------------- /userbot/plugins/gizoogle: -------------------------------------------------------------------------------- 1 | import re 2 | import bs4 3 | import requests 4 | from userbot.utils import admin_cmd 5 | 6 | @borg.on(admin_cmd(pattern="giz ?(.*)")) 7 | async def gizoogle(event): 8 | if event.fwd_from: 9 | return 10 | input_str = event.pattern_match.group(1) 11 | await event.edit("Processing...") 12 | if not input_str: 13 | return await event.edit("I can't gizoogle nothing.") 14 | try: 15 | result = text(input_str) 16 | except: 17 | result = "Failed to gizoogle the text." 18 | finally: 19 | return await event.edit(result) 20 | 21 | def text(input_text: str) -> str: 22 | """Taken from https://github.com/chafla/gizoogle-py/blob/master/gizoogle.py""" 23 | params = {"translatetext": input_text} 24 | target_url = "http://www.gizoogle.net/textilizer.php" 25 | resp = requests.post(target_url, data=params) 26 | # the html returned is in poor form normally. 27 | soup_input = re.sub("/name=translatetext[^>]*>/", 'name="translatetext" >', resp.text) 28 | soup = bs4.BeautifulSoup(soup_input, "lxml") 29 | giz = soup.find_all(text=True) 30 | giz_text = giz[37].strip("\r\n") # Hacky, but consistent. 31 | return giz_text 32 | -------------------------------------------------------------------------------- /userbot/plugins/fileext.py: -------------------------------------------------------------------------------- 1 | """Get info about a File Extension 2 | Syntax: .filext EXTENSION""" 3 | 4 | import requests 5 | from bs4 import BeautifulSoup 6 | 7 | from ..utils import admin_cmd, edit_or_reply, sudo_cmd 8 | 9 | 10 | @borg.on(admin_cmd(pattern="filext (.*)")) 11 | @borg.on(sudo_cmd(pattern="filext (.*)", allow_sudo=True)) 12 | async def _(event): 13 | if event.fwd_from: 14 | return 15 | sample_url = "https://www.fileext.com/file-extension/{}.html" 16 | input_str = event.pattern_match.group(1).lower() 17 | response_api = requests.get(sample_url.format(input_str)) 18 | status_code = response_api.status_code 19 | if status_code == 200: 20 | raw_html = response_api.content 21 | soup = BeautifulSoup(raw_html, "html.parser") 22 | ext_details = soup.find_all("td", {"colspan": "3"})[-1].text 23 | await edit_or_reply( 24 | event, 25 | "**File Extension**: `{}`\n**Description**: `{}`".format( 26 | input_str, ext_details 27 | ), 28 | ) 29 | else: 30 | await edit_or_reply( 31 | event, 32 | "https://www.fileext.com/ responded with {} for query: {}".format( 33 | status_code, input_str 34 | ), 35 | ) 36 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/echo_sql.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import Column, String 2 | 3 | from userbot.plugins.sql_helper import BASE, SESSION 4 | 5 | 6 | class ECHOSQL(BASE): 7 | __tablename__ = "echo_sql" 8 | user_id = Column(String(14), primary_key=True) 9 | chat_id = Column(String(14), primary_key=True) 10 | 11 | def __init__(self, user_id, chat_id): 12 | self.user_id = str(user_id) 13 | self.chat_id = str(chat_id) 14 | 15 | 16 | ECHOSQL.__table__.create(checkfirst=True) 17 | 18 | 19 | def is_echo(user_id, chat_id): 20 | try: 21 | return SESSION.query(ECHOSQL).get((str(user_id), str(chat_id))) 22 | except BaseException: 23 | return None 24 | finally: 25 | SESSION.close() 26 | 27 | 28 | def get_all_echos(): 29 | try: 30 | return SESSION.query(ECHOSQL).all() 31 | except BaseException: 32 | return None 33 | finally: 34 | SESSION.close() 35 | 36 | 37 | def addecho(user_id, chat_id): 38 | adder = ECHOSQL(str(user_id), str(chat_id)) 39 | SESSION.add(adder) 40 | SESSION.commit() 41 | 42 | 43 | def remove_echo(user_id, chat_id): 44 | note = SESSION.query(ECHOSQL).get((str(user_id), str(chat_id))) 45 | if note: 46 | SESSION.delete(note) 47 | SESSION.commit() 48 | -------------------------------------------------------------------------------- /.github/workflows/pylint.yml: -------------------------------------------------------------------------------- 1 | name: PyLint 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | PEP8: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | 11 | - name: Setup Python 12 | uses: actions/setup-python@v1 13 | with: 14 | python-version: 3.8 15 | 16 | - name: Install Python lint libraries 17 | run: | 18 | pip install autopep8 autoflake isort black 19 | - name: Check for showstoppers 20 | run: | 21 | autopep8 --verbose --in-place --recursive --aggressive --aggressive --ignore=W605. *.py 22 | - name: Remove unused imports and variables 23 | run: | 24 | autoflake --in-place --recursive --remove-all-unused-imports --remove-unused-variables --ignore-init-module-imports . 25 | - name: lint with isort and black 26 | run: | 27 | isort . 28 | black . 29 | # commit changes 30 | - uses: stefanzweifel/git-auto-commit-action@v4 31 | with: 32 | commit_message: 'pylint: auto fixes' 33 | commit_options: '--no-verify' 34 | repository: . 35 | commit_user_name: sandy1709 36 | commit_user_email: 58665444+sandy1709@users.noreply.github.com 37 | commit_author: sandy1709 <58665444+sandy1709@users.noreply.github.com> 38 | -------------------------------------------------------------------------------- /userbot/plugins/undlt.py: -------------------------------------------------------------------------------- 1 | import asyncio 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="undlt ?(.*)")) 8 | @borg.on(sudo_cmd(pattern="undlt ?(.*)", allow_sudo=True)) 9 | async def _(event): 10 | if event.fwd_from: 11 | return 12 | if event.pattern_match.group(1): 13 | try: 14 | cat = int(event.pattern_match.group(1)) 15 | input_str = cat 16 | except: 17 | input_str = 5 18 | else: 19 | input_str = 5 20 | c = await event.get_chat() 21 | if c.admin_rights or c.creator: 22 | a = await borg.get_admin_log( 23 | event.chat_id, limit=input_str, search="", edit=False, delete=True 24 | ) 25 | for i in a: 26 | await event.reply(i.original.action.message) 27 | else: 28 | event = await edit_or_reply( 29 | event, "`You need administrative permissions in order to do this command`" 30 | ) 31 | await asyncio.sleep(3) 32 | await event.delete() 33 | 34 | 35 | CMD_HELP.update( 36 | { 37 | "undlt": "**Plugin :** `undlt`\ 38 | \n**Syntax : **`.undlt `\ 39 | \n**Usage: **Fetches last number of deleted messages and sends you(you must be admin in that group) \ 40 | " 41 | } 42 | ) 43 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/google_drive_sql.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import Column, String, Text 2 | 3 | from . import BASE, SESSION 4 | 5 | 6 | class GoogleDriveCreds(BASE): 7 | __tablename__ = "gdrive" 8 | user = Column(String, primary_key=True) 9 | credentials = Column(Text, nullable=False) 10 | 11 | def __init__(self, user): 12 | self.user = user 13 | 14 | 15 | GoogleDriveCreds.__table__.create(checkfirst=True) 16 | 17 | 18 | def save_credentials(user, credentials): 19 | saved_credentials = SESSION.query(GoogleDriveCreds).get(user) 20 | if not saved_credentials: 21 | saved_credentials = GoogleDriveCreds(user) 22 | 23 | saved_credentials.credentials = credentials 24 | 25 | SESSION.add(saved_credentials) 26 | SESSION.commit() 27 | return True 28 | 29 | 30 | def get_credentials(user): 31 | try: 32 | saved_credentials = SESSION.query(GoogleDriveCreds).get(user) 33 | creds = None 34 | 35 | if saved_credentials is not None: 36 | creds = saved_credentials.credentials 37 | return creds 38 | finally: 39 | SESSION.close() 40 | 41 | 42 | def clear_credentials(user): 43 | saved_credentials = SESSION.query(GoogleDriveCreds).get(user) 44 | if saved_credentials: 45 | SESSION.delete(saved_credentials) 46 | SESSION.commit() 47 | return True 48 | -------------------------------------------------------------------------------- /userbot/plugins/gali.py: -------------------------------------------------------------------------------- 1 | """Emoji 2 | Available Commands: 3 | .fuk 4 | .sex 5 | .kiss 6 | """ 7 | 8 | import asyncio 9 | 10 | from userbot.utils import admin_cmd 11 | 12 | 13 | @borg.on(admin_cmd(pattern="fuk$")) 14 | async def _(event): 15 | if event.fwd_from: 16 | return 17 | animation_interval = 0.1 18 | animation_ttl = range(0, 101) 19 | animation_chars = ["👉 ✊️", "👉 ✊️", "👉 ✊️", "👉✊️💦"] 20 | for i in animation_ttl: 21 | await asyncio.sleep(animation_interval) 22 | await event.edit(animation_chars[i % 4]) 23 | 24 | 25 | @borg.on(admin_cmd(pattern="sex$")) 26 | async def _(event): 27 | if event.fwd_from: 28 | return 29 | animation_interval = 0.2 30 | animation_ttl = range(0, 101) 31 | animation_chars = ["🤵 👰", "🤵 👰", "🤵 👰", "🤵👼👰"] 32 | for i in animation_ttl: 33 | await asyncio.sleep(animation_interval) 34 | await event.edit(animation_chars[i % 4]) 35 | 36 | 37 | @borg.on(admin_cmd(pattern="kiss$")) 38 | async def _(event): 39 | if event.fwd_from: 40 | return 41 | animation_interval = 0.2 42 | animation_ttl = range(0, 101) 43 | animation_chars = ["🤵 👰", "🤵 👰", "🤵 👰", "🤵💋👰"] 44 | for i in animation_ttl: 45 | await asyncio.sleep(animation_interval) 46 | await event.edit(animation_chars[i % 4]) 47 | -------------------------------------------------------------------------------- /userbot/plugins/linkpreview.py: -------------------------------------------------------------------------------- 1 | from telethon import events 2 | from telethon.errors.rpcerrorlist import YouBlockedUserError 3 | 4 | from userbot.utils import admin_cmd 5 | 6 | 7 | @borg.on(admin_cmd(pattern="ctg ?(.*)")) 8 | async def _(event): 9 | if event.fwd_from: 10 | return 11 | if not event.reply_to_msg_id: 12 | await event.edit("```Reply to a Link.```") 13 | return 14 | reply_message = await event.get_reply_message() 15 | if not reply_message.text: 16 | await event.edit("```Reply to a Link```") 17 | return 18 | chat = "@chotamreaderbot" 19 | reply_message.sender 20 | await event.edit("```Processing```") 21 | async with event.client.conversation(chat) as conv: 22 | try: 23 | response = conv.wait_event( 24 | events.NewMessage(incoming=True, from_users=272572121) 25 | ) 26 | await event.client.forward_messages(chat, reply_message) 27 | response = await response 28 | except YouBlockedUserError: 29 | await event.reply("`RIP Check Your Blacklist Boss`") 30 | return 31 | if response.text.startswith(""): 32 | await event.edit("Am I Dumb Or Am I Dumb?") 33 | else: 34 | await event.delete() 35 | await event.client.send_message(event.chat_id, response.message) 36 | -------------------------------------------------------------------------------- /userbot/plugins/get_bot.py: -------------------------------------------------------------------------------- 1 | """ Get the Bots in any chat* 2 | Syntax: .get_bot""" 3 | from telethon.tl.types import ChannelParticipantAdmin, ChannelParticipantsBots 4 | 5 | from userbot.utils import admin_cmd 6 | 7 | 8 | @borg.on(admin_cmd(pattern="get_bots ?(.*)")) 9 | async def _(event): 10 | if event.fwd_from: 11 | return 12 | mentions = "**Bots in this Channel**: \n" 13 | input_str = event.pattern_match.group(1) 14 | to_write_chat = await event.get_input_chat() 15 | chat = None 16 | if not input_str: 17 | chat = to_write_chat 18 | else: 19 | mentions = "Bots in {} channel: \n".format(input_str) 20 | try: 21 | chat = await borg.get_entity(input_str) 22 | except Exception as e: 23 | await event.edit(str(e)) 24 | return None 25 | try: 26 | async for x in borg.iter_participants(chat, filter=ChannelParticipantsBots): 27 | if isinstance(x.participant, ChannelParticipantAdmin): 28 | mentions += "\n ⚜️ [{}](tg://user?id={}) `{}`".format( 29 | x.first_name, x.id, x.id 30 | ) 31 | else: 32 | mentions += "\n [{}](tg://user?id={}) `{}`".format( 33 | x.first_name, x.id, x.id 34 | ) 35 | except Exception as e: 36 | mentions += " " + str(e) + "\n" 37 | await event.edit(mentions) 38 | -------------------------------------------------------------------------------- /userbot/plugins/yify: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | # (c) Shrimadhav U K 4 | 5 | 6 | import asyncio 7 | 8 | import requests 9 | from bs4 import BeautifulSoup 10 | 11 | from userbot.utils import admin_cmd 12 | 13 | 14 | @borg.on(admin_cmd(pattern=f"yify recents", outgoing=True)) 15 | async def _(event): 16 | if event.fwd_from: 17 | return 18 | uploadbot = await borg.get_entity("@uploadbot") 19 | BASE_URL = "https://yts.pm" 20 | tg_feed_link = BASE_URL + "/browse-movies" 21 | main_page_response = requests.get(tg_feed_link) 22 | main_soup = BeautifulSoup(main_page_response.text, "html.parser") 23 | movies_in_page = main_soup.find_all("div", class_="browse-movie-wrap") 24 | for movie in movies_in_page: 25 | movie_bottom = movie.div 26 | movie_bottom.a.string 27 | movie_bottom.div.string 28 | movie_links = movie.div.find_all("a") 29 | movie_links = movie_links[1:] 30 | for torrent_link in movie_links: 31 | href_link = BASE_URL + torrent_link.get("href") 32 | magnetic_link_response = requests.get( 33 | href_link, allow_redirects=False) 34 | magnetic_link = magnetic_link_response.headers.get("Location") 35 | await borg.send_message( 36 | uploadbot, 37 | magnetic_link 38 | ) 39 | await asyncio.sleep(120) 40 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/globals.py: -------------------------------------------------------------------------------- 1 | try: 2 | from userbot.plugins.sql_helper import BASE, SESSION 3 | except ImportError: 4 | raise AttributeError 5 | from sqlalchemy import Column, String, UnicodeText 6 | 7 | 8 | class Globals(BASE): 9 | __tablename__ = "globals" 10 | variable = Column(String, primary_key=True, nullable=False) 11 | value = Column(UnicodeText, primary_key=True, nullable=False) 12 | 13 | def __init__(self, variable, value): 14 | self.variable = str(variable) 15 | self.value = value 16 | 17 | 18 | Globals.__table__.create(checkfirst=True) 19 | 20 | 21 | def gvarstatus(variable): 22 | try: 23 | return ( 24 | SESSION.query(Globals) 25 | .filter(Globals.variable == str(variable)) 26 | .first() 27 | .value 28 | ) 29 | except BaseException: 30 | return None 31 | finally: 32 | SESSION.close() 33 | 34 | 35 | def addgvar(variable, value): 36 | if SESSION.query(Globals).filter(Globals.variable == str(variable)).one_or_none(): 37 | delgvar(variable) 38 | adder = Globals(str(variable), value) 39 | SESSION.add(adder) 40 | SESSION.commit() 41 | 42 | 43 | def delgvar(variable): 44 | rem = ( 45 | SESSION.query(Globals) 46 | .filter(Globals.variable == str(variable)) 47 | .delete(synchronize_session="fetch") 48 | ) 49 | if rem: 50 | SESSION.commit() 51 | -------------------------------------------------------------------------------- /userbot/plugins/transfer_channel.py: -------------------------------------------------------------------------------- 1 | """Transfer Ownership of Channels 2 | Available Commands: 3 | .otransfer @username""" 4 | 5 | import telethon.password as pwd_mod 6 | 7 | # https://t.me/TelethonChat/140200 8 | from telethon.tl import functions 9 | 10 | from .. import CMD_HELP 11 | from ..utils import admin_cmd 12 | 13 | 14 | @borg.on(admin_cmd(pattern="otransfer (.*)")) # pylint:disable=E0602 15 | async def _(event): 16 | if event.fwd_from: 17 | return 18 | user_name = event.pattern_match.group(1) 19 | current_channel = event.chat_id 20 | # not doing any validations, here FN 21 | # MBL 22 | try: 23 | pwd = await borg(functions.account.GetPasswordRequest()) 24 | my_srp_password = pwd_mod.compute_check(pwd, Config.TELE_GRAM_2FA_CODE) 25 | await borg( 26 | functions.channels.EditCreatorRequest( 27 | channel=current_channel, user_id=user_name, password=my_srp_password 28 | ) 29 | ) 30 | except Exception as e: 31 | await event.edit(str(e)) 32 | else: 33 | await event.edit("Transferred 🌚") 34 | 35 | 36 | CMD_HELP.update( 37 | { 38 | "transfer_channel": "**Plugin :** `transfer_channel`\ 39 | \n**Syntax : **`.otransfer [username to whom you want to transfer]`\ 40 | \n**Usage: **Transfers ownership to the given username for this set this var `TELE_GRAM_2FA_CODE` in heroku with your 2-step verification code \ 41 | " 42 | } 43 | ) 44 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/snip_sql.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import Column, Numeric, UnicodeText 2 | 3 | from . import BASE, SESSION 4 | 5 | 6 | class Note(BASE): 7 | __tablename__ = "catsnip" 8 | keyword = Column(UnicodeText, primary_key=True, nullable=False) 9 | reply = Column(UnicodeText) 10 | f_mesg_id = Column(Numeric) 11 | 12 | def __init__(self, keyword, reply, f_mesg_id): 13 | self.keyword = keyword 14 | self.reply = reply 15 | self.f_mesg_id = f_mesg_id 16 | 17 | 18 | Note.__table__.create(checkfirst=True) 19 | 20 | 21 | def get_note(keyword): 22 | try: 23 | return SESSION.query(Note).get(keyword) 24 | finally: 25 | SESSION.close() 26 | 27 | 28 | def get_notes(): 29 | try: 30 | return SESSION.query(Note).all() 31 | finally: 32 | SESSION.close() 33 | 34 | 35 | def add_note(keyword, reply, f_mesg_id): 36 | to_check = get_note(keyword) 37 | if not to_check: 38 | adder = Note(keyword, reply, f_mesg_id) 39 | SESSION.add(adder) 40 | SESSION.commit() 41 | return True 42 | else: 43 | rem = SESSION.query(Note).get(keyword) 44 | SESSION.delete(rem) 45 | SESSION.commit() 46 | adder = Note(keyword, reply, f_mesg_id) 47 | SESSION.add(adder) 48 | SESSION.commit() 49 | return False 50 | 51 | 52 | def rm_note(keyword): 53 | to_check = get_note(keyword) 54 | if not to_check: 55 | return False 56 | else: 57 | rem = SESSION.query(Note).get(keyword) 58 | SESSION.delete(rem) 59 | SESSION.commit() 60 | return True 61 | -------------------------------------------------------------------------------- /userbot/plugins/spotify_downloader.py: -------------------------------------------------------------------------------- 1 | """ Spotify / Deezer downloader plugin by @anubisxx | Syntax: .sdd link""" 2 | import asyncio 3 | 4 | from telethon.errors.rpcerrorlist import ( 5 | UserAlreadyParticipantError, 6 | YouBlockedUserError, 7 | ) 8 | from telethon.tl.functions.messages import ImportChatInviteRequest 9 | 10 | from userbot.utils import admin_cmd 11 | 12 | 13 | @borg.on(admin_cmd("sdd ?(.*)")) 14 | async def _(event): 15 | if event.fwd_from: 16 | return 17 | d_link = event.pattern_match.group(1) 18 | if ".com" not in d_link: 19 | await event.edit("` I need a link to download something pro.`**(._.)**") 20 | else: 21 | await event.edit("🎶**Initiating Download!**🎶") 22 | 23 | async with borg.conversation("@DeezLoadBot") as conv: 24 | try: 25 | await conv.send_message("/start") 26 | await conv.get_response() 27 | try: 28 | await borg(ImportChatInviteRequest("AAAAAFZPuYvdW1A8mrT8Pg")) 29 | except UserAlreadyParticipantError: 30 | await asyncio.sleep(0.00000069420) 31 | await conv.send_message(d_link) 32 | details = await conv.get_response() 33 | await borg.send_message(event.chat_id, details) 34 | await conv.get_response() 35 | songh = await conv.get_response() 36 | await borg.send_file( 37 | event.chat_id, songh, caption="🔆**Here's the requested song!**🔆" 38 | ) 39 | await event.delete() 40 | except YouBlockedUserError: 41 | await event.edit("**Error:** `unblock` @DeezLoadBot `and retry!`") 42 | -------------------------------------------------------------------------------- /userbot/plugins/sql_helper/lydia_ai_sql.py: -------------------------------------------------------------------------------- 1 | from sqlalchemy import Column, Numeric, UnicodeText 2 | 3 | from userbot.plugins.sql_helper import BASE, SESSION 4 | 5 | 6 | class LydiaAI(BASE): 7 | __tablename__ = "lydia_ai" 8 | user_id = Column(Numeric, primary_key=True) 9 | chat_id = Column(Numeric, primary_key=True) 10 | session_id = Column(UnicodeText) 11 | session_expires = Column(Numeric) 12 | 13 | def __init__(self, user_id, chat_id, session_id, session_expires): 14 | self.user_id = user_id 15 | self.chat_id = chat_id 16 | self.session_id = session_id 17 | self.session_expires = session_expires 18 | 19 | 20 | LydiaAI.__table__.create(checkfirst=True) 21 | 22 | 23 | def get_s(user_id, chat_id): 24 | try: 25 | return SESSION.query(LydiaAI).get((user_id, chat_id)) 26 | except BaseException: 27 | return None 28 | finally: 29 | SESSION.close() 30 | 31 | 32 | def get_all_s(): 33 | try: 34 | return SESSION.query(LydiaAI).all() 35 | except BaseException: 36 | return None 37 | finally: 38 | SESSION.close() 39 | 40 | 41 | def add_s(user_id, chat_id, session_id, session_expires): 42 | adder = SESSION.query(LydiaAI).get((user_id, chat_id)) 43 | if adder: 44 | adder.session_id = session_id 45 | adder.session_expires = session_expires 46 | else: 47 | adder = LydiaAI(user_id, chat_id, session_id, session_expires) 48 | SESSION.add(adder) 49 | SESSION.commit() 50 | 51 | 52 | def remove_s(user_id, chat_id): 53 | note = SESSION.query(LydiaAI).get((user_id, chat_id)) 54 | if note: 55 | SESSION.delete(note) 56 | SESSION.commit() 57 | -------------------------------------------------------------------------------- /userbot/plugins/selfdestruct.py: -------------------------------------------------------------------------------- 1 | # For @UniBorg 2 | # courtesy Yasir siddiqui 3 | """Self Destruct Plugin 4 | .sd