diff --git a/docs/bot_tutorial/building_block_commands.md b/docs/bot_tutorial/building_block_commands.md index 36861b7..2e327b7 100644 --- a/docs/bot_tutorial/building_block_commands.md +++ b/docs/bot_tutorial/building_block_commands.md @@ -70,4 +70,34 @@ def on_add_command(self, event, args): All combined commands in 1 large codeblock: ```py class myPlugin(Plugin): - + @Plugin.command('ping') + def on_ping_command(self, event): + event.msg.reply('Pong!') + + @Plugin.command('echo', '') + def on_echo_command(self, event, content): + event.msg.reply(content) + + @Plugin.command('add', ' ', group='math') + def on_add_command(self, event, a, b): + event.msg.reply('{}'.format(a+b)) + + @Plugin.command('tag', ' [value:str...]') + def on_tag_command(self, event, name, value=None): + tags = self.storage.guild.ensure('tags') + + if value: + tags[name] = value + event.msg.reply(':ok_hand: created tag `{}`'.format(name)) + else: + if name in tags: + return event.msg.reply(tags[name]) + else: + return event.msg.reply('Unknown tag: `{}`'.format(name)) + + @Plugin.command('add', parser=True, group='math') + @Plugin.parser.add_argument('a', type=int) + @Plugin.parser.add_argument('b', type=int) + def on_add_command(self, event, args): + event.msg.reply('{}'.format(args.a + args.b) +```