async def run_shard(shard_id, shard_count): assert (0 <= shard_id < shard_count) while True: manager = core.manager.Manager(TOKEN, shard_id=shard_id, shard_count=shard_count, master_filter=event_filter) manager.add_modules( modules.help.HelpModule(), modules.wolfram.WolframModule(), modules.settings.SettingsModule(), modules.blame.BlameModule(), modules.about.AboutModule(), modules.latex.LatexModule(), modules.calcmod.CalculatorModule( RELEASE in ['development', 'beta']), modules.purge.PurgeModule(), # Will only trigger stats if supplied with tokens modules.analytics.AnalyticsModule(), modules.reporter.ReporterModule()) if RELEASE == 'development': manager.add_modules(modules.throws.ThrowsModule(), modules.echo.EchoModule()) await manager.run_async()
async def test_secure_function(manager): manager.add_modules(SecurityModule()) manager.setup() await manager.handle_message(MockMessage('=test', author=MockUser(perms=discord.Permissions.all()))) assert manager.output_messages.pop() == 'Permission granted' await manager.handle_message(MockMessage('=test', author=MockUser(perms=discord.Permissions.none()))) assert manager.output_messages.pop() != 'Permission granted'
def create_manager(shard_id, shard_count): assert (0 <= shard_id < shard_count) manager = core.manager.Manager(TOKEN, shard_id=shard_id, shard_count=shard_count, master_filter=event_filter) # New modules go here manager.add_modules( modules.help.HelpModule(), modules.wolfram.WolframModule(), modules.settings.SettingsModule(), modules.blame.BlameModule(), modules.about.AboutModule(), modules.latex.LatexModule(), modules.calcmod.CalculatorModule(RELEASE in ['development', 'beta']), modules.purge.PurgeModule()) if RELEASE == 'development': manager.add_modules(modules.throws.ThrowsModule(), modules.echo.EchoModule()) if RELEASE == 'production': manager.add_modules(modules.analytics.AnalyticsModule()) return manager
def create_shard_manager(shard_id, shard_count): # Imports happen in here because importing some of these modules # causes state changes that could interfere with tests if they're # executed too early. import modules.wolfram import modules.about import modules.blame import modules.calcmod import modules.help import modules.throws import modules.settings import modules.latex import modules.purge import modules.echo import modules.analytics import modules.reporter import modules.greeter import modules.dice import modules.heartbeat assert (0 <= shard_id < shard_count) manager = core.manager.Manager(TOKEN, shard_id=shard_id, shard_count=shard_count, master_filter=event_filter) manager.add_modules( modules.help.HelpModule(), modules.wolfram.WolframModule(), modules.settings.SettingsModule(), modules.blame.BlameModule(), modules.about.AboutModule(), modules.latex.LatexModule(), modules.calcmod.CalculatorModule(), modules.dice.DiceModule(), modules.purge.PurgeModule(), # Will only trigger stats if supplied with tokens modules.analytics.AnalyticsModule(), modules.reporter.ReporterModule(), modules.heartbeat.Heartbeat()) if RELEASE == 'production': manager.add_modules(modules.greeter.GreeterModule()) if RELEASE == 'development': manager.add_modules(modules.throws.ThrowsModule(), modules.echo.EchoModule()) return manager
async def test_message_handler(manager): manager.add_modules(ExampleModule()) manager.setup() await manager.handle_message(MockMessage('=echo'))
def test_duplicate_command(manager): manager.add_modules(ExampleModule()) manager.add_modules(ConflictingModule()) with pytest.raises(core.manager.CommandConflictError): manager.setup()
def test_command_collection(manager): manager.add_modules(ExampleModule(), AnotherModule()) manager.setup() assert manager.commands['echo'] == ExampleModule.echo assert manager.commands['hello'] == AnotherModule.hello
async def test_message_handler(manager): # pylint: disable=redefined-outer-name manager.add_modules(ExampleModule()) manager.setup() await manager.handle_message(MockMessage('=echo'))