예제 #1
0
파일: tags.py 프로젝트: SergeTFM/phen-cogs
 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)
예제 #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())
예제 #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)
예제 #4
0
 def __init__(self, bot):
     self.bot = bot
     blocks = [
         block.MathBlock(),
         block.RandomBlock(),
         block.RangeBlock(),
     ]
     self.engine = Interpreter(blocks)
예제 #5
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()
예제 #6
0
 def __init__(self, bot):
     self.logger = logging.getLogger("discord")
     self.bot = bot
     self.bot.c.execute(
         """CREATE TABLE IF NOT EXISTS tags
             (id text, name text, content text, created int, updated int, uses real, author text)"""
     )
     self.blocks = [
         RandomBlock(),
         block.StrictVariableGetterBlock(),
         block.MathBlock(),
         block.RangeBlock(),
     ]
예제 #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])