Esempio n. 1
0
    async def on_ready(self):
        async with self._init_lock:
            if self._initialized.is_set():
                log.info('DdmBot connection to discord was restored')
                self._loop.create_task(self.connect_voice())
                return

            log.info('DdmBot connected as {0} (ID: {0.id})'.format(self._client.user))
            self._setup_discord_objects()
            self._initialized.set()

        await self.connect_voice()

        # populate initial listeners
        for member in self._voice_channel.voice_members:
            if member == self._client.user:
                continue
            with suppress(database.bot.IgnoredUserError):
                if await self._database.interaction_check(int(member.id)):
                    await self._send_welcome_message(member)
                await self._users.add_listener(int(member.id), direct=False)

        # enable commands by creating a command_handler object
        self._command_handler = commandhandler.CommandHandler(self)
        # at this point, bot should be ready
        log.info('Initialization done')
Esempio n. 2
0
	def __init__(self):
		 self.running = False
		 self.command_checker = commandhandler.CommandHandler()
		 self.client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		 self.clock_running = False
		 self.beginning_time = time.time()
		 self.eh = EncryptionHandler()
		 try:
		 	self.client.connect(('127.0.0.1',50222))
		 except:
		 	self.running = False
		 	print(colored("Issue Connecting to Proxy Server!!" , "red"))
Esempio n. 3
0
async def reload_function(message=None, client=client, args=[]):
    global config
    global conn
    global sid
    global versioninfo
    global doissetep_omega
    now = datetime.utcnow()
    try:
        await client.change_presence(activity=discord.Game(name="Reloading: The Game"))
        if config["discord"].get("profile"):
            global pr
            if pr:
                pr.disable()
                pr.print_stats()
        importlib.reload(load_config)
        config = load_config.FletcherConfig()
        load_config.client = client
        config.client = client
        await animate_startup("πŸ“", message)
        conn = psycopg2.connect(
            host=config["database"]["host"],
            database=config["database"]["tablespace"],
            user=config["database"]["user"],
            password=config["database"]["password"],
        )
        await animate_startup("πŸ’Ύ", message)
        # Command Handler (loaded twice to bootstrap)
        await autoload(commandhandler, None, config)
        await animate_startup("⌨", message)
        ch = commandhandler.CommandHandler(client)
        commandhandler.ch = ch
        ch.config = config
        await autoload(versionutils, ch)
        versioninfo = versionutils.VersionInfo()
        ch.add_command(
            {
                "trigger": [f"!reload <@!{ch.client.user.id}>"],
                "function": reload_function,
                "async": True,
                "admin": "global",
                "args_num": 0,
                "args_name": [],
                "description": "Reload config (admin only)",
            }
        )
        ch.webhook_sync_registry = webhook_sync_registry
        # Utility text manipulators Module
        await autoload(text_manipulators, ch)
        await animate_startup("πŸ”§", message)
        # Schedule Module
        await autoload(schedule, ch)
        await animate_startup("πŸ“…", message)
        # Greeting module
        await autoload(greeting, ch)
        await animate_startup("πŸ‘‹", message)
        # Sentinel Module
        await autoload(sentinel, ch)
        await animate_startup("🎏", message)
        # Messages Module
        await autoload(messagefuncs, ch)
        await animate_startup("πŸ”­", message)
        # Math Module
        await autoload(mathemagical, ch)
        await animate_startup("βž•", message)
        await autoload(janissary, ch)
        # Super Waifu Animated Girlfriend (SWAG)
        await autoload(swag, ch)
        await animate_startup("πŸ™‰", message)
        # Photos Connectors (for !twilestia et al)
        await autoload(pinterest, ch)
        await autoload(googlephotos, ch)
        await autoload(danbooru, ch)
        await animate_startup("πŸ“·", message)
        # GitHub Connector
        await autoload(github, ch)
        await animate_startup("πŸ™", message)
        # Time Module
        await autoload(chronos, ch)
        await animate_startup("πŸ•°οΈ", message)
        # Play it again, Sam
        await doissetep_omega_autoconnect()
        # Trigger reload handlers
        await ch.reload_handler()
        # FIXME there should be some way to defer this, or maybe autoload another time
        await autoload(commandhandler, ch)
        await animate_startup("πŸ”", message)
        globals()["ch"] = ch
        await load_webhooks(ch)
        if message:
            await message.add_reaction("↔")
        await animate_startup("βœ…", message)
        await client.change_presence(
            activity=discord.Game(name="fletcher.fun | !help", start=now)
        )
    except Exception as e:
        exc_type, exc_obj, exc_tb = exc_info()
        logger.critical(f"RM[{exc_tb.tb_lineno}]: {type(e).__name__} {e}")
        logger.debug(traceback.format_exc())
        await animate_startup("🚫", message)
        await client.change_presence(
            activity=discord.Game(
                name=f"Error Reloading: RM[{exc_tb.tb_lineno}]: {e}", start=now
            )
        )
Esempio n. 4
0
"""
Created by Epic at 9/24/20
"""
from speedcord import Client
from os import environ as env
import commands
import commandhandler

bot = Client(640)
bot.command_handler = commandhandler.CommandHandler(bot, env["PREFIX"])

# Register commands
bot.command_handler.command_handlers["help"] = commands.help_command


@bot.listen("MESSAGE_CREATE")
async def on_message(data, shard):
    print("Got message")
    await bot.command_handler.handle_message(data)


bot.token = env["TOKEN"]

bot.run()
Esempio n. 5
0
 def test_valid_len(self):
     handler = commandhandler.CommandHandler("test")
     result = handler.command_is_valid_len("move 2")
     self.assertTrue(result)
     result = handler.command_is_valid_len("move 2 fwfds")
     self.assertFalse(result)
Esempio n. 6
0
 def test_level_is_len(self):
     handler = commandhandler.CommandHandler("test")
     result = handler.command_is_valid_len("move 2")
     self.assertTrue(handler.level_is_int())
     handler2 = handler.command_is_valid_len("move t")
     self.assertFalse(handler.level_is_int())