Message handlers implemented, await used in the send_xt method.

This commit is contained in:
rsakeys 2019-08-05 21:42:49 +03:00
parent a7932dd837
commit 25cb12df08
3 changed files with 22 additions and 2 deletions

View File

@ -0,0 +1,19 @@
from houdini import handlers
from houdini.handlers import XTPacket
from houdini.commands import invoke_command_string
@handlers.handler(XTPacket('m', 'sm'))
@handlers.cooldown(.5)
async def handle_send_message(p, penguin_id: int, message):
if penguin_id != p.data.id:
return await p.close()
if p.muted:
for room_player in p.room.penguins:
if room_player.data.moderator:
await room_player.sendXt("mm", message, penguin_id)
return
await p.room.send_xt('sm', p.data.id, message)
await invoke_command_string(p.server.commands, p, message)

View File

@ -5,7 +5,7 @@ from houdini.spheniscidae import Spheniscidae
class Penguin(Spheniscidae):
__slots__ = ['x', 'y', 'frame', 'room', 'waddle', 'table', 'data',
__slots__ = ['x', 'y', 'frame', 'room', 'waddle', 'table', 'data', 'muted'
'login_key', 'member', 'membership_days', 'avatar',
'walking_puffle', 'permissions', 'active_quests']
@ -17,6 +17,7 @@ class Penguin(Spheniscidae):
self.room = None
self.waddle = None
self.table = None
self.muted = False
self.data = None
self.login_key = None

View File

@ -30,4 +30,4 @@ class Example(IPlugin):
@commands.command('ping')
@permissions.has('houdini.ping')
async def ping(self, p):
p.send_xt('cprompt', 'Pong')
await p.send_xt('cprompt', 'Pong')