Browse Source

Removed storage related examples (#59)

* Remove storage.py

* Removed storage related comands
pull/70/head
Jari (LotU) 7 years ago
committed by Andrei Zbikowski
parent
commit
bc3228da93
  1. 24
      examples/basic_plugin.py
  2. 33
      examples/storage.py

24
examples/basic_plugin.py

@ -64,20 +64,6 @@ class BasicPlugin(Plugin):
def on_math_sub_command(self, event, a, b):
event.msg.reply('{}'.format(a - b))
@Plugin.command('tag', '<name:str> [value:str...]')
def on_tag(self, event, name, value=None):
# Plugins can easily store data locally using Disco's built in storage
tags = self.storage.guild.ensure('tags')
if value:
tags[name] = value
event.msg.reply(u':ok_hand: created tag `{}`'.format(S(name)))
else:
if name in tags:
return event.msg.reply(tags[name])
else:
return event.msg.reply(u'Unknown tag: `{}`'.format(S(name)))
@Plugin.command('test', parser=True)
@Plugin.parser.add_argument('-a', '--asdf', help='wow')
@Plugin.parser.add_argument('--help', action='store_true')
@ -87,13 +73,3 @@ class BasicPlugin(Plugin):
if args.help:
return event.msg.reply(event.parser.format_help())
event.msg.reply(args.asdf)
"""
@Plugin.route('/test')
def on_test_route(self):
# Disco has built-in support for Flask (if installed and enabled) which
# allows plugins to create HTTP routes.
from flask import request
print dict(request.headers)
return 'Hi!'
"""

33
examples/storage.py

@ -1,33 +0,0 @@
from disco.bot import Plugin
class BasicPlugin(Plugin):
def load(self, ctx):
super(BasicPlugin, self).load(ctx)
self.tags = self.storage.guild('tags')
@Plugin.command('add', '<name:str> <value:str...>', group='tags')
def on_tags_add(self, event, name, value):
if name in self.tags:
return event.msg.reply('That tag already exists!')
self.tags[name] = value
return event.msg.reply(u':ok_hand: created the tag {}'.format(name), sanitize=True)
@Plugin.command('get', '<name:str>', group='tags')
def on_tags_get(self, event, name):
if name not in self.tags:
return event.msg.reply('That tag does not exist!')
return event.msg.reply(self.tags[name], sanitize=True)
@Plugin.command('delete', '<name:str>', group='tags', aliases=['del', 'rmv', 'remove'])
def on_tags_delete(self, event, name):
if name not in self.tags:
return event.msg.reply('That tag does not exist!')
del self.tags[name]
return event.msg.reply(u':ok_hand: I deleted the {} tag for you'.format(
name
), sanitize=True)
Loading…
Cancel
Save