Python3
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8
|
||||
|
||||
# Copyright (C) 2010-2011 Stefan Hacker <dd0t@users.sourceforge.net>
|
||||
@@ -35,24 +35,25 @@
|
||||
# they connect regardless of which channel they were in when they left.
|
||||
#
|
||||
|
||||
from mumo_module import (commaSeperatedIntegers,
|
||||
MumoModule)
|
||||
import re
|
||||
|
||||
from config import commaSeperatedIntegers
|
||||
from mumo_module import MumoModule
|
||||
|
||||
|
||||
class onjoin(MumoModule):
|
||||
default_config = {'onjoin':(
|
||||
('servers', commaSeperatedIntegers, []),
|
||||
),
|
||||
'all':(
|
||||
('channel', int, 1),
|
||||
),
|
||||
lambda x: re.match('server_\d+', x):(
|
||||
('channel', int, 1),
|
||||
)
|
||||
}
|
||||
|
||||
def __init__(self, name, manager, configuration = None):
|
||||
default_config = {'onjoin': (
|
||||
('servers', commaSeperatedIntegers, []),
|
||||
),
|
||||
'all': (
|
||||
('channel', int, 1),
|
||||
),
|
||||
lambda x: re.match('server_\d+', x): (
|
||||
('channel', int, 1),
|
||||
)
|
||||
}
|
||||
|
||||
def __init__(self, name, manager, configuration=None):
|
||||
MumoModule.__init__(self, name, manager, configuration)
|
||||
self.murmur = manager.getMurmurModule()
|
||||
|
||||
@@ -60,39 +61,53 @@ class onjoin(MumoModule):
|
||||
manager = self.manager()
|
||||
log = self.log()
|
||||
log.debug("Register for Server callbacks")
|
||||
|
||||
|
||||
servers = self.cfg().onjoin.servers
|
||||
if not servers:
|
||||
servers = manager.SERVERS_ALL
|
||||
|
||||
|
||||
manager.subscribeServerCallbacks(self, servers)
|
||||
|
||||
def disconnected(self): pass
|
||||
|
||||
|
||||
def disconnected(self):
|
||||
pass
|
||||
|
||||
#
|
||||
#--- Server callback functions
|
||||
# --- Server callback functions
|
||||
#
|
||||
|
||||
def userConnected(self, server, state, context = None):
|
||||
|
||||
def userConnected(self, server, state, context=None):
|
||||
log = self.log()
|
||||
sid = server.id()
|
||||
try:
|
||||
scfg = getattr(self.cfg(), 'server_%d' % sid)
|
||||
except AttributeError:
|
||||
scfg = self.cfg().all
|
||||
|
||||
|
||||
if state.channel != scfg.channel:
|
||||
log.debug("Moving user '%s' from channel %d to %d on server %d", state.name, state.channel, scfg.channel, sid)
|
||||
log.debug("Moving user '%s' from channel %d to %d on server %d", state.name, state.channel, scfg.channel,
|
||||
sid)
|
||||
state.channel = scfg.channel
|
||||
|
||||
|
||||
try:
|
||||
server.setState(state)
|
||||
except self.murmur.InvalidChannelException:
|
||||
log.error("Moving user '%s' failed, target channel %d does not exist on server %d", state.name, scfg.channel, sid)
|
||||
|
||||
def userDisconnected(self, server, state, context = None): pass
|
||||
def userStateChanged(self, server, state, context = None): pass
|
||||
def userTextMessage(self, server, user, message, current=None): pass
|
||||
def channelCreated(self, server, state, context = None): pass
|
||||
def channelRemoved(self, server, state, context = None): pass
|
||||
def channelStateChanged(self, server, state, context = None): pass
|
||||
log.error("Moving user '%s' failed, target channel %d does not exist on server %d", state.name,
|
||||
scfg.channel, sid)
|
||||
|
||||
def userDisconnected(self, server, state, context=None):
|
||||
pass
|
||||
|
||||
def userStateChanged(self, server, state, context=None):
|
||||
pass
|
||||
|
||||
def userTextMessage(self, server, user, message, current=None):
|
||||
pass
|
||||
|
||||
def channelCreated(self, server, state, context=None):
|
||||
pass
|
||||
|
||||
def channelRemoved(self, server, state, context=None):
|
||||
pass
|
||||
|
||||
def channelStateChanged(self, server, state, context=None):
|
||||
pass
|
||||
|
||||
Reference in New Issue
Block a user