Ejemplo n.º 1
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     self.config = Config.get_conf(
         self,
         identifier=567234895692346562369,
         force_registration=True,
     )
     default_guild = {"tags": {}}
     self.config.register_guild(**default_guild)
     blocks = [
         block.MathBlock(),
         block.RandomBlock(),
         block.RangeBlock(),
         block.AnyBlock(),
         block.IfBlock(),
         block.AllBlock(),
         block.BreakBlock(),
         block.StrfBlock(),
         block.StopBlock(),
         block.AssignmentBlock(),
         block.FiftyFiftyBlock(),
         block.ShortCutRedirectBlock("message"),
         block.LooseVariableGetterBlock(),
         block.SubstringBlock(),
     ]
     self.engine = Interpreter(blocks)
Ejemplo n.º 2
0
    def __init__(self, bot: Red) -> None:
        self.bot = bot
        self.config = Config.get_conf(
            self,
            identifier=567234895692346562369,
            force_registration=True,
        )
        default_guild = {"tags": {}}
        self.config.register_guild(**default_guild)

        blocks = stable_blocks + [
            block.MathBlock(),
            block.RandomBlock(),
            block.RangeBlock(),
            block.AnyBlock(),
            block.IfBlock(),
            block.AllBlock(),
            block.BreakBlock(),
            block.StrfBlock(),
            block.StopBlock(),
            block.AssignmentBlock(),
            block.FiftyFiftyBlock(),
            block.ShortCutRedirectBlock("args"),
            block.LooseVariableGetterBlock(),
            block.SubstringBlock(),
        ]
        self.engine = Interpreter(blocks)
        self.role_converter = commands.RoleConverter()
        self.channel_converter = commands.TextChannelConverter()
        self.member_converter = commands.MemberConverter()
        self.emoji_converter = commands.EmojiConverter()

        self.guild_tag_cache = defaultdict(dict)
        self.task = asyncio.create_task(self.cache_tags())
Ejemplo n.º 3
0
 def __init__(self, bot: Red) -> None:
     self.bot = bot
     cog = self.bot.get_cog("CustomCommands")
     if cog:
         raise RuntimeError(
             "This cog conflicts with CustomCommands and cannot be loaded with both at the same time."
         )
     self.config = Config.get_conf(
         self,
         identifier=567234895692346562369,
         force_registration=True,
     )
     default_guild = {"tags": {}}
     self.config.register_guild(**default_guild)
     blocks = stable_blocks + [
         block.MathBlock(),
         block.RandomBlock(),
         block.RangeBlock(),
         block.AnyBlock(),
         block.IfBlock(),
         block.AllBlock(),
         block.BreakBlock(),
         block.StrfBlock(),
         block.StopBlock(),
         block.AssignmentBlock(),
         block.FiftyFiftyBlock(),
         block.ShortCutRedirectBlock("message"),
         block.LooseVariableGetterBlock(),
         block.SubstringBlock(),
     ]
     self.engine = Interpreter(blocks)
Ejemplo n.º 4
0
 def __init__(self, bot):
     self.bot = bot
     blocks = [
         block.MathBlock(),
         block.RandomBlock(),
         block.RangeBlock(),
     ]
     self.engine = Interpreter(blocks)
Ejemplo n.º 5
0
    def __init__(self):
        super().__init__(
            command_prefix=_callable_prefix,
            case_insensitive=True,
            allowed_mentions=discord.AllowedMentions(users=True, roles=False),
            intents=discord.Intents.all(),
        )
        self._BotBase__cogs = commands.core._CaseInsensitiveDict()

        self.version = "2.2.A"

        self.blocks = [block.RandomBlock(), block.StrictVariableGetterBlock()]

        self.activityIndex = 0

        # Init database
        self.conn = sqlite3.connect("data/database.db")
        self.c = self.conn.cursor()

        self.logger = logging.getLogger("discord")
        self.session = aiohttp.ClientSession(loop=self.loop)
        self.def_prefix = ">"
        self.norules = [
            758764126679072788, 747984453585993808, 745481731133669476
        ]

        with open("config.json", "r") as f:
            self.config = json.load(f)

        if not self.config["bot_token"]:
            self.logger.error("No token found. Please add it to config.json!")
            raise AttributeError("No token found!")

        # Create tables
        self.c.execute("""CREATE TABLE IF NOT EXISTS servers
                (id text unique, prefixes text, anime_ch int,
                greeting_ch int, meme_ch int, purge_ch int,
                pingme_ch int, announcement_ch int)""")
        self.c.execute("SELECT * FROM servers WHERE 1")
        servers_row = self.c.fetchall()
        pre = {k[0]: k[1] or ">" for k in servers_row}
        self.prefixes = {int(k): v.split(",") for (k, v) in pre.items()}

        self.c.execute("""CREATE TABLE IF NOT EXISTS ani_watchlist
                (id text unique, anime_id text)""")
        self.c.execute("""CREATE TABLE IF NOT EXISTS roles
                (id text unique, default_role int, mute_role int)""")
        self.c.execute("""CREATE TABLE IF NOT EXISTS settings
                (id text unique, send_error_msg int,
                disabled_cmds text, welcome_msg text,
                farewell_msg text, mods_only text)""")

        self.master = [186713080841895936]

        self.loop.create_task(self.start_up())
Ejemplo n.º 6
0
    def __init__(self, bot):
        self.bot = bot
        blocks = [
            block.MathBlock(),
            block.RandomBlock(),
            block.RangeBlock(),
        ]
        self.engine = Interpreter(blocks)

        # Initialize a session
        self.session = aiohttp.ClientSession()
Ejemplo n.º 7
0
from TagScriptEngine import block, Interpreter, adapter
from appJar import gui

blocks = [
    block.MathBlock(),
    block.RandomBlock(),
    block.RangeBlock(),
    block.AnyBlock(),
    block.IfBlock(),
    block.AllBlock(),
    block.BreakBlock(),
    block.StrfBlock(),
    block.StopBlock(),
    block.AssignmentBlock(),
    block.FiftyFiftyBlock(),
    block.ShortCutRedirectBlock("message"),
    block.LooseVariableGetterBlock(),
    block.SubstringBlock(),
]
x = Interpreter(blocks)


def press(button):
    o = x.process(app.getTextArea("input")).body
    app.clearTextArea("output")
    app.setTextArea("output", o)


app = gui("TSE Playground", "750x450")
app.setPadding([2, 2])
app.setInPadding([2, 2])