Update example plugin

This commit is contained in:
Ben 2019-05-29 23:07:43 +01:00
parent ef2902e644
commit 8155cfa25a

View File

@ -1,7 +1,10 @@
from Houdini import Handlers from houdini import handlers
from Houdini.Handlers import XTPacket from houdini.handlers import XTPacket
from Houdini.Plugins import IPlugin from houdini.plugins import IPlugin
from houdini import commands
from houdini import permissions
class Example(IPlugin): class Example(IPlugin):
@ -10,28 +13,21 @@ class Example(IPlugin):
version = "1.0.0" version = "1.0.0"
def __init__(self, server): def __init__(self, server):
self.server = server super().__init__(server)
async def ready(self): async def ready(self):
self.server.logger.info('Example.ready()') self.server.logger.info('Example.ready()')
await self.server.permissions.register('houdini.ping')
async def message_cooling(self, p): async def message_cooling(self, p):
print("{}, Message was sent during cooldown".format(p)) print("{}, Message was sent during cooldown".format(p))
@Handlers.handler(XTPacket('s', 'sm')) @handlers.handler(XTPacket('m', 'sm'))
@Handlers.cooldown(1, callback=message_cooling) @handlers.cooldown(1, callback=message_cooling)
async def handle_send_message(self, p, message: str): async def handle_send_message(self, p, message: str):
print('Do stuff with {}'.format(message)) print('Do stuff with {}'.format(message))
# @Commands.command('ping') @commands.command('ping')
@permissions.has('houdini.ping')
async def ping(self, p): async def ping(self, p):
p.send_xt('cprompt', 'Pong') p.send_xt('cprompt', 'Pong')
# @Events.on('connected')
async def on_connected(self, client):
print(client)
# @Events.on('disconnected')
async def on_disconnect(self, client):
print(client)