Example #1
0
import json

try:
    from Sibyl_System import HEROKU_API_KEY, HEROKU_APP_NAME

    heroku_conn = heroku3.from_key(HEROKU_API_KEY)
    app = heroku_conn.app(HEROKU_APP_NAME)
    config = app.config()
    HEROKU = True
except BaseException:
    HEROKU = False

json_file = os.path.join(os.getcwd(), "Sibyl_System\\elevated_users.json")


@System.on(system_cmd(pattern=r"addsbm", allow_developers=True))
async def addsbm(event) -> None:
    if event.message.reply_to_msg_id:
        replied = await event.get_reply_message()
        if replied:
            u_id = replied.sender.id
        else:
            return
    else:
        u_id = event.text.split(" ", 2)[1]
        try:
            u_id = (await System.get_entity(u_id)).id
        except BaseException:
            await event.reply(
                "I haven't interacted with that user! Meh, Will add them anyway"
            )
Example #2
0
            imported.__plugin_name__ = imported.__name__

        if not imported.__plugin_name__.lower() in IMPORTED:
            IMPORTED[imported.__plugin_name__.lower()] = imported

        if hasattr(imported, "help_plus") and imported.help_plus:
            HELP[imported.__plugin_name__.lower()] = imported
    except Exception as e:
        print(f"Error while loading plugin: {load}")
        print("------------------------------------")
        print(e)
        FAILED_TO_LOAD[load] = e
        print("------------------------------------")


@System.on(system_cmd(pattern=r"status", allow_managers=True))
async def status(event):
    msg = await event.reply("CONNECTING TO THE CORE FOR DIAGNOSIS VERIFICATION.")
    time.sleep(1)
    await msg.edit("Initialising ■□□□□□")
    time.sleep(1)
    await msg.edit("Initialising ■■□□□□")
    time.sleep(1)
    await msg.edit("Initialising ■■■□□□")
    time.sleep(1)
    await msg.edit("Initialising ■■■■□□")
    time.sleep(1)
    await msg.edit("Initialising ■■■■■□")
    time.sleep(1)
    await msg.edit("Initialising ■■■■■■")
    time.sleep(1)
Example #3
0
import json

try:
    from Sibyl_System import HEROKU_API_KEY, HEROKU_APP_NAME

    heroku_conn = heroku3.from_key(HEROKU_API_KEY)
    app = heroku_conn.app(HEROKU_APP_NAME)
    config = app.config()
    HEROKU = True
except BaseException:
    HEROKU = False

json_file = os.path.join(os.getcwd(), "Sibyl_System\\elevated_users.json")


@System.on(system_cmd(pattern=r"addenf", allow_inspectors=True))
async def addenf(event) -> None:
    if event.message.reply_to_msg_id:
        replied = await event.get_reply_message()
        if replied:
            u_id = replied.sender.id
        else:
            return
    else:
        u_id = event.text.split(" ", 2)[1]
        try:
            u_id = (await System.get_entity(u_id)).id
        except BaseException:
            await event.reply(
                "I haven't interacted with that user! Meh, Will add them anyway"
            )
Example #4
0
from Sibyl_System import system_cmd, System
import asyncio
import io

@System.on(system_cmd("(term|terminal|sh|shell) "))
async def shell(event):
  if event.fwd_from: return
  cmd = event.text.split(" ", 1)
  if len(cmd) == 1: return
  else: cmd = cmd[1]
  async_process =  await asyncio.create_subprocess_shell(cmd, 
  stdout=asyncio.subprocess.PIPE, 
  stderr=asyncio.subprocess.PIPE
  )
  stdout, stderr = await async_process.communicate()
  msg = ""
  if stderr.decode(): msg += f"**Stderr:**\n`{stderr.decode()}`"
  if stdout.decode(): msg += f"**Stdout:**\n`{stdout.decode()}`"
  if len(msg) > 4096:
    with io.BytesIO(msg) as file:
      file.name = "shell.txt"
      await System.send_file(
        event.chat.id,
        file,
        force_document = True,
        caption = "Output was too long, Sending as file",
        reply_to = event.message.id
      )
      return
  await event.reply(msg)
Example #5
0
import re
from telethon.utils import resolve_invite_link
import heroku3
import os

try:
    from Sibyl_System import HEROKU_API_KEY, HEROKU_APP_NAME
    heroku_conn = heroku3.from_key(HEROKU_API_KEY)
    app = heroku_conn.app(HEROKU_APP_NAME)
    config = app.config()
    HEROKU = True
except BaseException:
    HEROKU = False


@System.on(system_cmd(pattern=r'addenf', allow_inspectors=True))
async def addenf(event) -> None:
    if event.message.reply_to_msg_id:
        replied = await event.get_reply_message()
        if replied: u_id = replied.sender.id
        else: return
    else:
        u_id = event.text.split(" ", 2)[1]
        try:
            u_id = (await System.get_entity(u_id)).id
        except BaseException:
            await event.reply(
                "I haven't interacted with that user! Meh, Will add them anyway"
            )
    if u_id in ENFORCERS:
        await System.send_message(event.chat_id,
Example #6
0
            imported.__plugin_name__ = imported.__name__

        if not imported.__plugin_name__.lower() in IMPORTED:
            IMPORTED[imported.__plugin_name__.lower()] = imported

        if hasattr(imported, "help_plus") and imported.help_plus:
            HELP[imported.__plugin_name__.lower()] = imported
    except Exception as e:
        print(f"Error while loading plugin: {load}")
        print("------------------------------------")
        print(e)
        FAILED_TO_LOAD[load] = e
        print("------------------------------------")


@System.on(system_cmd(pattern=r"sysinfo", allow_enforcer=True))
async def status(event):
    msg = await event.reply("Conecting to Syliviorus System Core.")
    time.sleep(1)
    await msg.edit("Initialising â– â–¡â–¡â–¡â–¡â–¡")
    time.sleep(1)
    await msg.edit("Initialising â– â– â–¡â–¡â–¡â–¡")
    time.sleep(1)
    await msg.edit("Initialising â– â– â– â–¡â–¡â–¡")
    time.sleep(1)
    await msg.edit("Initialising â– â– â– â– â–¡â–¡")
    time.sleep(1)
    await msg.edit("Initialising â– â– â– â– â– â–¡")
    time.sleep(1)
    await msg.edit("Initialising â– â– â– â– â– â– ")
    time.sleep(1)
Example #7
0
import pymongo 
from Sibyl_System import System, SIBYL, ENFORCERS, Sibyl_logs, system_cmd
from telethon import events 
import asyncio 
import re 
from Sibyl_System.plugins.Mongo_DB.message_blacklist import get_blacklist, update_blacklist
from Sibyl_System.plugins.Mongo_DB.name_blacklist import get_wlc_bl, update_wlc_blacklist

@System.on(system_cmd(pattern = r'addbl'))
async def addbl(event):
     flag = re.match(".addbl -e (.*)", event.text, re.DOTALL)
     if flag:
        text = re.escape(flag.group(1))
     else:
       try:
         text = event.text.split(" ", 1)[1]
       except:
         return 
     a = update_blacklist(text, add = True)
     if a:
        await System.send_message(event.chat_id, f"Added {text} to blacklist") 
     else:
        await System.send_message(event.chat_id, f" {text} is already blacklisted") 

@System.on(system_cmd(pattern=r'addwlcbl'))
async def wlcbl(event):
     flag = re.match(".addbl -e (.*)", event.text, re.DOTALL)
     if flag:
        text = re.escape(flag.group(1))
     else:
       try:
HELP = {}
IMPORTED = {}
for load in to_load:
    imported = importlib.import_module("Sibyl_System.plugins." + load)
    if not hasattr(imported, "__plugin_name__"):
        imported.__plugin_name__ = imported.__name__

    if not imported.__plugin_name__.lower() in IMPORTED:
        IMPORTED[imported.__plugin_name__.lower()] = imported

    if hasattr(imported, "help_plus") and imported.help_plus:
        HELP[imported.__plugin_name__.lower()] = imported


@System.on(system_cmd(pattern=r'status'))
async def status(event):
    await System.send_message(event.chat_id, on_string)


@System.on(system_cmd(pattern=r'help', allow_slash=False))
async def send_help(event):
    try:
        help_for = event.text.split(" ", 1)[1].lower()
    except IndexError:
        msg = "Here is the list of plugins with Help text:\n"
        for x in HELP.keys():
            msg += f"`{x}`\n"
        await System.send_message(event.chat_id, msg)
        return
    if help_for in HELP:
Example #9
0
from telethon.tl.functions.users import GetFullUserRequest
from Sibyl_System import System, system_cmd


@System.on(system_cmd(pattern=r'whois'))
async def whois(event):
    try:
        to_get = event.pattern_match.group(1)
    except Exception:
        if event.reply:
            replied = await event.get_reply_message()
            to_get = int(replied.sender.id)
        else:
            return
    try:
        to_get = int(to_get)
    except Exception:
        pass
    data = await System(GetFullUserRequest(to_get))
    await System.send_message(
        event.chat_id,
        f"Perma Link: [{data.user.first_name}](tg://user?id={data.user.id})\nUser ID: `{data.user.id}`\nAbout: {data.about}"
    )


help_plus = """ Here is Help for **Whois** -
`whois` - get data of the user
**Notes:**
`/` `?` `.` `!` are supported prefixes.
**Example:** `/addenf` or `?addenf` or `.addenf`
"""
Example #10
0
from Sibyl_System import System, system_cmd
import os
import sys


@System.on(system_cmd(pattern=r"scan restart"))
async def reboot(event):
    if event.fwd_from:
        return
    await event.reply('Restarting.....')
    await System.disconnect()
    os.execl(sys.executable, sys.executable, *sys.argv)
    quit()


@System.on(system_cmd(pattern=r"scan shutdown"))
async def shutdown(event):
    if event.fwd_from:
        return
    await event.reply("Shutting Down... ")
    await System.disconnect()
Example #11
0
import re
from telethon.utils import resolve_invite_link
import heroku3
import os

try:
    from Sibyl_System import HEROKU_API_KEY, HEROKU_APP_NAME
    heroku_conn = heroku3.from_key(HEROKU_API_KEY)
    app = heroku_conn.app(HEROKU_APP_NAME)
    config = app.config()
    HEROKU = True
except BaseException:
    HEROKU = False


@System.on(system_cmd(pattern=r'addenf'))
async def addenf(event) -> None:
    if event.reply:
        replied = await event.get_reply_message()
        u_id = replied.sender.id
    else:
        u_id = event.text.split(" ", 2)[1]
    if u_id in ENFORCERS:
        await System.send_message(event.chat_id,
                                  'That person is already Enforcer!')
        return
    if HEROKU:
        config['ENFORCERS'] = os.environ.get('ENFORCERS') + ' ' + str(u_id)
    else:
        ENFORCERS.append(u_id)
    await System.send_message(
            imported.__plugin_name__ = imported.__name__

        if not imported.__plugin_name__.lower() in IMPORTED:
            IMPORTED[imported.__plugin_name__.lower()] = imported

        if hasattr(imported, "help_plus") and imported.help_plus:
            HELP[imported.__plugin_name__.lower()] = imported
    except Exception as e:
        print(f"Error while loading plugin: {load}")
        print("------------------------------------")
        print(e)
        FAILED_TO_LOAD[load] = e
        print("------------------------------------")


@System.on(system_cmd(pattern=r"status", allow_enforcer=True))
async def status(event):
    msg = await event.reply(
        'Portable Psychological Diagnosis and Suppression System.')
    time.sleep(1)
    await msg.edit('Initialising ▫️◾️▫️')
    time.sleep(1)
    await msg.edit('Initialising ◾️▫️◾️')
    time.sleep(1)
    await msg.edit('Initialising ▫️◾️▫️')
    time.sleep(1)
    await msg.edit('Initialising ◾️▫️◾️')
    time.sleep(1)
    await msg.edit('Initialising ▫️◾️▫️')
    time.sleep(1)
    await msg.edit('Initialising ◾️▫️◾️')
Example #13
0
from Sibyl_System import System, system_cmd
import os
import sys
import subprocess


@System.on(system_cmd(pattern=r"GbanWatch Gitpull"))
async def gitpull(event):
    subprocess.Popen("git pull", stdout=subprocess.PIPE, shell=True)
    await event.reply("Git pulled probably.")
    os.system("restart.bat")
    os.execv("start.bat", sys.argv)


@System.on(system_cmd(pattern=r"GbanWatch Restart"))
async def reboot(event):
    if event.fwd_from:
        return
    await event.reply("Restarting.....")
    await System.disconnect()
    os.execl(sys.executable, sys.executable, *sys.argv)
    quit()


@System.on(system_cmd(pattern=r"GbanWatch Shutdown"))
async def shutdown(event):
    if event.fwd_from:
        return
    await event.reply("Shutting Down... ")
    await System.disconnect()
Example #14
0
from telethon import events
import asyncio
import sys
import re
from Sibyl_System import system_cmd, System
from io import StringIO
import traceback

#Thanks to stackoverflow for existing https://stackoverflow.com/questions/3906232/python-get-the-print-output-in-an-exec-statement


@System.on(system_cmd(pattern=r"sibyl (exec|execute|x|ex)"))
async def run(event):
    code = event.text.split(" ", 2)
    if len(code) == 2: return
    stderr, output, wizardry = None, None, None
    code = code[2]
    old_stdout = sys.stdout
    old_stderr = sys.stderr
    redirected_output = sys.stdout = StringIO()
    redirected_error = sys.stderr = StringIO()
    try:
        await async_exec(code, event)
    except Exception:
        wizardry = traceback.format_exc()
    output = redirected_output.getvalue()
    stderr = redirected_error.getvalue()
    sys.stdout = old_stdout
    sys.stderr = old_stderr
    if wizardry: final = "**Output**:\n`" + wizardry
    elif output: final = "**Output**:\n`" + output
Example #15
0
from Sibyl_System import System, system_cmd
import os
import sys
import subprocess


@System.on(system_cmd(pattern=r"cardinal gitpull"))
async def gitpull(event):
    subprocess.Popen("git pull", stdout=subprocess.PIPE, shell=True)
    await event.reply("Git pulled probably.")
    os.system("restart.bat")
    os.execv("start.bat", sys.argv)


@System.on(system_cmd(pattern=r"cardinal restart"))
async def reboot(event):
    if event.fwd_from:
        return
    await event.reply("Restarting.....")
    await System.disconnect()
    os.execl(sys.executable, sys.executable, *sys.argv)
    sys.exit()


@System.on(system_cmd(pattern=r"cardinal shutdown"))
async def shutdown(event):
    if event.fwd_from:
        return
    await event.reply("Shutting Down... ")
    await System.disconnect()
Example #16
0
import json

try:
    from Sibyl_System import HEROKU_API_KEY, HEROKU_APP_NAME

    heroku_conn = heroku3.from_key(HEROKU_API_KEY)
    app = heroku_conn.app(HEROKU_APP_NAME)
    config = app.config()
    HEROKU = True
except BaseException:
    HEROKU = False

json_file = os.path.join(os.getcwd(), "Sibyl_System\\elevated_users.json")


@System.on(system_cmd(pattern=r"addmng", allow_developers=True))
async def addmng(event) -> None:
    if event.message.reply_to_msg_id:
        replied = await event.get_reply_message()
        if replied:
            u_id = replied.sender.id
        else:
            return
    else:
        u_id = event.text.split(" ", 2)[1]
        try:
            u_id = (await System.get_entity(u_id)).id
        except BaseException:
            await event.reply(
                "I haven't interacted with that user! Meh, Will add them anyway"
            )
Example #17
0
from Sibyl_System import System, system_cmd
from Sibyl_System.strings import repoMetadata

@System.on(system_cmd("repo"))
async def pullRepoMeta(event):
    await event.reply(repoMetadata)

__plugin_name__ = "about"

help_plus = """
**Help for About Userbot**

_Getting repo info__
`repo` -  Get information about the repository.

**Notes:**
`/` `?` `.` `!` are supported prefixes.
**Example:** `/repo` or `?repo` or `.repo`
"""
Example #18
0
from Sibyl_System import Sibyl_logs, ENFORCERS, SIBYL, INSPECTORS, GBAN_MSG_LOGS
from Sibyl_System.strings import scan_request_string, scan_approved_string, bot_gban_string, reject_string, proof_string, forced_scan_string
from Sibyl_System import System, system_cmd
import re
from Sibyl_System import session
import Sibyl_System.plugins.Mongo_DB.gbans as db
import logging

logging.basicConfig(
    format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s',
    level=logging.ERROR)


@System.on(system_cmd(pattern=r'scan ', allow_enforcer=True, force_reply=True))
async def scan(event):
    trim = None
    replied = await event.get_reply_message()
    if re.match('.scan -f -o .*', event.text) or re.match(
            ".scan -o .*", event.text):
        if replied.fwd_from:
            if re.match('.scan -o .*', event.text): trim = 2
            else: trim = 3
            reply = replied.fwd_from
            target = reply.from_id
            if reply.from_id in ENFORCERS or reply.from_id in SIBYL:
                return
            if reply.from_name:
                sender = f"[{reply.from_name}](tg://user?id={reply.from_id})"
            else:
                sender = f"[{reply.from_id}](tg://user?id={reply.from_id})"
    else:
Example #19
0
url_regex = re.compile("(http(s)?://)?t.me/(c/)?(\w+)/(\d+)")


def get_data_from_url(url: str) -> tuple:
    """
    >>> get_data_from_url("https://t.me/c/1476401326/36963")
    (1476401326, 36963)
    """

    match = url_regex.match(url)
    if not match:
        return False
    return (match.group(4), match.group(5))


@System.on(system_cmd(pattern=r"judge ", allow_managers=True))
async def scan(event):
    replied = await event.get_reply_message()
    flags, reason = seprate_flags(event.text)
    if len(reason.split(" ", 1)) == 1:
        return
    split = reason.strip().split(" ", 1)
    reason = reason.strip().split(" ", 1)[1].strip()
    if "u" in flags.keys():
        url = reason
        data = get_data_from_url(url)
        if not data:
            await event.reply("Invalid url")
            return
        try:
            message = await System.get_messages(
Example #20
0
from Sibyl_System import system_cmd, System
from PIL import Image, ImageDraw, ImageFont
import os


@System.on(system_cmd(pattern=r'get_id'))
async def image_maker(event) -> None:
    replied_user = await event.get_reply_message()
    #Download profile photo
    await System.download_profile_photo(replied_user.from_id,
                                        file='user.png',
                                        download_big=True)
    user_photo = Image.open('user.png')
    #open id photo
    id_template = Image.open('ID.png')
    #resize user photo to fit box in id template
    user_photo = user_photo.resize((989, 1073))
    #put image in position
    id_template.paste(user_photo, (1229, 573))
    #postion on where to draw text
    position = (2473, 481)
    draw = ImageDraw.Draw(id_template)
    color = 'rgb(23, 43, 226)'  #blue-ish color
    font = ImageFont.truetype('font.ttf', size=200)
    #put text in image
    draw.text(position,
              replied_user.sender.first_name.replace('\u2060', ''),
              fill=color,
              font=font)
    id_template.save('user_id.png')
    await System.send_message(event.chat_id,
Example #21
0
import Sibyl_System.plugins.Mongo_DB.name_blacklist as wlc_collection
from telethon import events


async def extract(flag, event):
    if flag:
        return re.escape(flag.group(1))
    else:
        try:
            text = event.text.split(" ", 1)[1]
            return text
        except BaseException:
            return False


@System.on(system_cmd(pattern=r'addbl ', allow_slash=False))
async def addbl(event) -> None:
    flag = re.match(".addbl -e (.*)", event.text, re.DOTALL)
    text = await extract(flag, event)
    if not text: return
    a = await db.update_blacklist(text, add=True)
    if a:
        await System.send_message(event.chat_id, f"Added {text} to blacklist")
    else:
        await System.send_message(event.chat_id,
                                  f" {text} is already blacklisted")


@System.on(system_cmd(pattern=r'addwlcbl '))
async def wlcbl(event) -> None:
    flag = re.match(".addwlcbl -e (.*)", event.text, re.DOTALL)
Example #22
0
from Sibyl_System import System, system_cmd
import os
import sys


@System.on(system_cmd(pattern=r"sibyl restart"))
async def reboot(event):
    if event.fwd_from:
        return
    await event.reply('Restarting.....')
    await System.disconnect()
    os.execl(sys.executable, sys.executable, *sys.argv)
    quit()


@System.on(system_cmd(pattern=r"sibyl shutdown"))
async def shutdown(event):
    if event.fwd_from:
        return
    await event.reply("Shutting Down... ")
    await System.disconnect()
Example #23
0
from telethon.tl.functions.users import GetFullUserRequest
from Sibyl_System import System, system_cmd


@System.on(system_cmd(pattern=r"whois"))
async def whois(event):
    try:
        to_get = event.pattern_match.group(1)
    except Exception:
        if event.reply:
            replied = await event.get_reply_message()
            to_get = int(replied.sender.id)
        else:
            return
    try:
        to_get = int(to_get)
    except Exception:
        pass
    try:
        data = await System(GetFullUserRequest(to_get))
    except Exception:
        await event.reply("Failed to get data of the user")
        return
    await System.send_message(
        event.chat_id,
        f"Perma Link: [{data.user.first_name}](tg://user?id={data.user.id})\nUser ID: `{data.user.id}`\nAbout: {data.about}",
    )


help_plus = """
**Help for User Lookup**
Example #24
0
url_regex = re.compile("(http(s)?://)?t.me/(c/)?(\w+)/(\d+)")


def get_data_from_url(url: str) -> tuple:
    """
    >>> get_data_from_url("https://t.me/c/1476401326/36963")
    (1476401326, 36963)
    """

    match = url_regex.match(url)
    if not match:
        return False
    return (match.group(4), match.group(5))


@System.on(system_cmd(pattern=r"scan ", allow_enforcer=True))
async def scan(event):
    replied = await event.get_reply_message()
    flags, reason = seprate_flags(event.text)
    if len(reason.split(" ", 1)) == 1:
        return
    split = reason.strip().split(" ", 1)
    reason = reason.strip().split(" ", 1)[1].strip()
    if "u" in flags.keys():
        url = reason
        data = get_data_from_url(url)
        if not data:
            await event.reply("Invalid url")
            return
        try:
            message = await System.get_messages(
Example #25
0
HELP = {}
IMPORTED = {}

for load in to_load:
    imported = importlib.import_module("Sibyl_System.plugins." + load)
    if not hasattr(imported, "__plugin_name__"):
        imported.__plugin_name__ = imported.__name__

    if not imported.__plugin_name__.lower() in IMPORTED:
        IMPORTED[imported.__plugin_name__.lower()] = imported

    if hasattr(imported, "help_plus") and imported.help_plus:
        HELP[imported.__plugin_name__.lower()] = imported


@System.on(system_cmd(pattern=r'status', allow_enforcer=True))
async def status(event):
    await event.reply(on_string)


@System.on(
    system_cmd(pattern=r'help', allow_slash=False, allow_inspectors=True))
async def send_help(event):
    try:
        help_for = event.text.split(" ", 1)[1].lower()
    except IndexError:
        msg = "List of plugins with help text:\n"
        for x in HELP.keys():
            msg += f"`{x.capitalize()}`\n"
        await event.reply(msg)
        return
Example #26
0
import sys
from Sibyl_System import system_cmd, System
from io import StringIO
import traceback
import inspect

# Thanks to stackoverflow for existing https://stackoverflow.com/questions/3906232/python-get-the-print-output-in-an-exec-statement


@System.on(system_cmd(pattern=r"sibyl (exec|execute|x|ex)"))
async def run(event):
    code = event.text.split(" ", 2)
    if len(code) == 2:
        return
    stderr, output, wizardry = None, None, None
    code = code[2]
    old_stdout = sys.stdout
    old_stderr = sys.stderr
    redirected_output = sys.stdout = StringIO()
    redirected_error = sys.stderr = StringIO()
    try:
        await async_exec(code, event)
    except Exception:
        wizardry = traceback.format_exc()
    output = redirected_output.getvalue()
    stderr = redirected_error.getvalue()
    sys.stdout = old_stdout
    sys.stderr = old_stderr
    if wizardry:
        final = "**Output**:\n`" + wizardry
    elif output:
Example #27
0
import Sibyl_System.plugins.Mongo_DB.name_blacklist as wlc_collection
from telethon import events


async def extract(flag, event):
    if flag:
        return re.escape(flag.group(1))
    else:
        try:
            text = event.text.split(" ", 1)[1]
            return text
        except BaseException:
            return False


@System.on(system_cmd(pattern=r"addbl ", allow_slash=False))
async def addbl(event) -> None:
    flag = re.match(".addbl -e (.*)", event.text, re.DOTALL)
    text = await extract(flag, event)
    if not text:
        return
    a = await db.update_blacklist(text, add=True)
    if a:
        await System.send_message(event.chat_id, f"Added {text} to blacklist")
    else:
        await System.send_message(event.chat_id, f" {text} is already blacklisted")


@System.on(system_cmd(pattern=r"addwlcbl "))
async def wlcbl(event) -> None:
    flag = re.match(".addwlcbl -e (.*)", event.text, re.DOTALL)
Example #28
0
for load in to_load:
    try:
        imported = importlib.import_module(Subaru_Akehoshi_bot"" + load)
        if not hasattr(imported, "__plugin_name__"):
            imported.__plugin_name__ = imported.__name__

        if not imported.__plugin_name__.lower() in IMPORTED:
            IMPORTED[imported.__plugin_name__.lower()] = imported

        if hasattr(imported, "help_plus") and imported.help_plus:
            HELP[imported.__plugin_name__.lower()] = imported
    except Exception as e:
        print(f"Error while loading plugin: {load}")
        print("------------------------------------")
        print(e)
        FAILED_TO_LOAD[load] = e
        print("------------------------------------")


@System.on(system_cmd(pattern=r"status", allow_enforcer=True))
async def status(event):
    msg = await event.reply("Portable Psychological Diagnosis and Suppression System.")
    time.sleep(1)
    await msg.edit("Initialising ▫️◾️▫️")
    time.sleep(1)
    await msg.edit("Initialising ◾️▫️◾️")
    time.sleep(1)
    await msg.edit("Initialising ▫️◾️▫️")
   
Example #29
0
from Sibyl_System import system_cmd, System
from PIL import Image, ImageDraw, ImageFont
import os


@System.on(system_cmd(pattern=r"get_id"))
async def image_maker(event) -> None:
    replied_user = await event.get_reply_message()
    # Download profile photo
    await System.download_profile_photo(
        replied_user.from_id.user_id, file="user.png", download_big=True
    )
    user_photo = Image.open("user.png")
    # open id photo
    id_template = Image.open("ID.png")
    # resize user photo to fit box in id template
    user_photo = user_photo.resize((1159, 1241))
    # put image in position
    id_template.paste(user_photo, (1003, 641))
    # postion on where to draw text
    draw = ImageDraw.Draw(id_template)
    color = "rgb(0, 0, 0)"  # black
    font = ImageFont.truetype("font.ttf", size=80)
    font2 = ImageFont.truetype("font2.ttf", size=100)
    # put text in image
    draw.text(
        (1000, 460),
        replied_user.sender.first_name.replace("\u2060", ""),
        fill=color,
        font=font2,
    )
Example #30
0
from Sibyl_System import System, system_cmd
import os
import sys
import subprocess


@System.on(system_cmd(pattern=r"ssc update"))
async def gitpull(event):
    subprocess.Popen("git pull", stdout=subprocess.PIPE, shell=True)
    await event.reply("Source code probably updated, restarting...")
    os.system("restart.bat")
    os.execv("start.bat", sys.argv)


@System.on(system_cmd(pattern=r"ssc reboot"))
async def reboot(event):
    if event.fwd_from:
        return
    await event.reply("Restarting.....")
    await System.disconnect()
    os.execl(sys.executable, sys.executable, *sys.argv)


@System.on(system_cmd(pattern=r"ssc shutdown"))
async def shutdown(event):
    if event.fwd_from:
        return
    await event.reply(
        "Shutting down... (Please manually start me if you need me.)")
    await System.disconnect()