def valid_commands(self):
return ['random']
- def handle_command(self, message, command, raw):
+ async def handle_command(self, message, command, raw):
if command not in self.valid_commands():
return PluginCommand.ignored
- yield from self.rng(message.channel, shlex.split(raw)[1:])
+ await self.rng(message.channel, shlex.split(raw)[1:])
return PluginCommand.exclusive
- @asyncio.coroutine
- def handle_help(self, message, command, *args):
- yield from self.show_help(message.channel)
+ async def handle_help(self, message, command, *args):
+ await self.show_help(message.channel)
def generate(self, n):
return int(round((random.random() * (n - 1))))
- @asyncio.coroutine
- def show_help(self, destination):
+ async def show_help(self, destination):
lines = [
'Generate random numbers or pick an entry from a list.',
'```random N```',
'Example: `random 42`',
'Example: `random one two three four five six`'
]
- yield from bot.say_many(destination, lines)
+ await bot.say_many(destination, lines)
- @asyncio.coroutine
- def rng(self, destination, args):
+ async def rng(self, destination, args):
if not len(args):
- yield from bot.say(destination, 'How many?')
+ await bot.say(destination, 'How many?')
elif len(args) == 1:
if args[0] == 'help':
- yield from self.show_help(destination)
+ await self.show_help(destination)
elif args[0] != '1' and re.match(r'^\d+$', args[0]):
- yield from bot.say(destination, str(1 + self.generate(int(args[0]))))
+ await bot.say(destination, str(1 + self.generate(int(args[0]))))
else:
- yield from bot.say(destination, 'Only one?')
+ await bot.say(destination, 'Only one?')
else:
- yield from bot.say(destination, args[self.generate(len(args))])
+ await bot.say(destination, args[self.generate(len(args))])