Add new text message callback stub to mumo and modules. Add seen module to query for last time a given user was active.
This commit is contained in:
10
modules-available/seen.ini
Normal file
10
modules-available/seen.ini
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
;
|
||||||
|
; This module allows asking the server for the last time it saw a specific
|
||||||
|
; player
|
||||||
|
;
|
||||||
|
|
||||||
|
[seen]
|
||||||
|
; Comma seperated list of servers to operate on, leave empty for all
|
||||||
|
servers =
|
||||||
|
; Keyword to which the server reacts
|
||||||
|
keyword = !seen
|
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8
|
# -*- coding: utf-8
|
||||||
|
|
||||||
# Copyright (C) 2010 Stefan Hacker <dd0t@users.sourceforge.net>
|
# Copyright (C) 2010-2011 Stefan Hacker <dd0t@users.sourceforge.net>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@@ -359,7 +359,8 @@ class bf2(MumoModule):
|
|||||||
|
|
||||||
def userConnected(self, server, state, context = None):
|
def userConnected(self, server, state, context = None):
|
||||||
self.handle(server, state)
|
self.handle(server, state)
|
||||||
|
|
||||||
|
def userTextMessage(self, server, user, message, current=None): pass
|
||||||
def channelCreated(self, server, state, context = None): pass
|
def channelCreated(self, server, state, context = None): pass
|
||||||
def channelRemoved(self, server, state, context = None): pass
|
def channelRemoved(self, server, state, context = None): pass
|
||||||
def channelStateChanged(self, server, state, context = None): pass
|
def channelStateChanged(self, server, state, context = None): pass
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8
|
# -*- coding: utf-8
|
||||||
|
|
||||||
# Copyright (C) 2010 Stefan Hacker <dd0t@users.sourceforge.net>
|
# Copyright (C) 2010-2011 Stefan Hacker <dd0t@users.sourceforge.net>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@@ -37,11 +37,9 @@
|
|||||||
# once they become active again
|
# once they become active again
|
||||||
#
|
#
|
||||||
|
|
||||||
from mumo_module import (x2bool,
|
from mumo_module import (commaSeperatedIntegers,
|
||||||
commaSeperatedIntegers,
|
|
||||||
commaSeperatedBool,
|
commaSeperatedBool,
|
||||||
MumoModule,
|
MumoModule)
|
||||||
Config)
|
|
||||||
|
|
||||||
from threading import Timer
|
from threading import Timer
|
||||||
import re
|
import re
|
||||||
@@ -204,6 +202,7 @@ class idlemove(MumoModule):
|
|||||||
self.UpdateUserAutoAway(server, state)
|
self.UpdateUserAutoAway(server, state)
|
||||||
|
|
||||||
def userConnected(self, server, state, context=None): pass # Unused callbacks
|
def userConnected(self, server, state, context=None): pass # Unused callbacks
|
||||||
|
def userTextMessage(self, server, user, message, current=None): pass
|
||||||
def channelCreated(self, server, state, context=None): pass
|
def channelCreated(self, server, state, context=None): pass
|
||||||
def channelRemoved(self, server, state, context=None): pass
|
def channelRemoved(self, server, state, context=None): pass
|
||||||
def channelStateChanged(self, server, state, context=None): pass
|
def channelStateChanged(self, server, state, context=None): pass
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8
|
# -*- coding: utf-8
|
||||||
|
|
||||||
# Copyright (C) 2010 Stefan Hacker <dd0t@users.sourceforge.net>
|
# Copyright (C) 2010-2011 Stefan Hacker <dd0t@users.sourceforge.net>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@@ -35,10 +35,8 @@
|
|||||||
# they connect regardless of which channel they were in when they left.
|
# they connect regardless of which channel they were in when they left.
|
||||||
#
|
#
|
||||||
|
|
||||||
from mumo_module import (x2bool,
|
from mumo_module import (commaSeperatedIntegers,
|
||||||
commaSeperatedIntegers,
|
MumoModule)
|
||||||
MumoModule,
|
|
||||||
Config)
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
@@ -94,6 +92,7 @@ class onjoin(MumoModule):
|
|||||||
|
|
||||||
def userDisconnected(self, server, state, context = None): pass
|
def userDisconnected(self, server, state, context = None): pass
|
||||||
def userStateChanged(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 channelCreated(self, server, state, context = None): pass
|
||||||
def channelRemoved(self, server, state, context = None): pass
|
def channelRemoved(self, server, state, context = None): pass
|
||||||
def channelStateChanged(self, server, state, context = None): pass
|
def channelStateChanged(self, server, state, context = None): pass
|
||||||
|
93
modules/seen.py
Normal file
93
modules/seen.py
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8
|
||||||
|
|
||||||
|
# Copyright (C) 2011 Stefan Hacker <dd0t@users.sourceforge.net>
|
||||||
|
# All rights reserved.
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
|
||||||
|
# - Redistributions of source code must retain the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer.
|
||||||
|
# - Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
# this list of conditions and the following disclaimer in the documentation
|
||||||
|
# and/or other materials provided with the distribution.
|
||||||
|
# - Neither the name of the Mumble Developers nor the names of its
|
||||||
|
# contributors may be used to endorse or promote products derived from this
|
||||||
|
# software without specific prior written permission.
|
||||||
|
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# `AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||||
|
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||||
|
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||||
|
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
#
|
||||||
|
# seen.py
|
||||||
|
# This module allows asking the server for the last time it saw a specific player
|
||||||
|
#
|
||||||
|
|
||||||
|
from mumo_module import (commaSeperatedIntegers,
|
||||||
|
MumoModule)
|
||||||
|
|
||||||
|
class seen(MumoModule):
|
||||||
|
default_config = {'seen':(
|
||||||
|
('servers', commaSeperatedIntegers, []),
|
||||||
|
('keyword', str, '!seen'),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, name, manager, configuration = None):
|
||||||
|
MumoModule.__init__(self, name, manager, configuration)
|
||||||
|
self.murmur = manager.getMurmurModule()
|
||||||
|
self.keyword = self.cfg().seen.keyword
|
||||||
|
|
||||||
|
def connected(self):
|
||||||
|
manager = self.manager()
|
||||||
|
log = self.log()
|
||||||
|
log.debug("Register for Server callbacks")
|
||||||
|
|
||||||
|
servers = self.cfg().seen.servers
|
||||||
|
if not servers:
|
||||||
|
servers = manager.SERVERS_ALL
|
||||||
|
|
||||||
|
manager.subscribeServerCallbacks(self, servers)
|
||||||
|
|
||||||
|
def disconnected(self): pass
|
||||||
|
|
||||||
|
#
|
||||||
|
#--- Server callback functions
|
||||||
|
#
|
||||||
|
|
||||||
|
def userTextMessage(self, server, user, message, current=None):
|
||||||
|
if message.text.startswith(self.keyword):
|
||||||
|
tuname = message.text[len(self.keyword):].strip()
|
||||||
|
self.log().debug("User %s (%d|%d) on server %d asking for '%s'",
|
||||||
|
user.name, user.session, user.userid, server.id(), tuname)
|
||||||
|
|
||||||
|
for cuid, cuname in server.getRegisteredUsers(tuname).iteritems():
|
||||||
|
if cuname == tuname:
|
||||||
|
ureg = server.getRegistration(cuid)
|
||||||
|
if ureg:
|
||||||
|
server.sendMessage(user.session,
|
||||||
|
"User '%s' was last active %s UTC" % (tuname,
|
||||||
|
ureg[self.murmur.UserInfo.UserLastActive]))
|
||||||
|
return
|
||||||
|
|
||||||
|
server.sendMessage(user.session,
|
||||||
|
"I don't know who user '%s' is" % tuname)
|
||||||
|
|
||||||
|
def userConnected(self, server, state, context = None): pass
|
||||||
|
def userDisconnected(self, server, state, context = None): pass
|
||||||
|
def userStateChanged(self, server, state, context = 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
|
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8
|
# -*- coding: utf-8
|
||||||
|
|
||||||
# Copyright (C) 2010 Stefan Hacker <dd0t@users.sourceforge.net>
|
# Copyright (C) 2010-2011 Stefan Hacker <dd0t@users.sourceforge.net>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@@ -91,6 +91,10 @@ class test(MumoModule):
|
|||||||
def userStateChanged(self, server, state, context = None):
|
def userStateChanged(self, server, state, context = None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@logModFu
|
||||||
|
def userTextMessage(self, server, user, message, current=None):
|
||||||
|
pass
|
||||||
|
|
||||||
@logModFu
|
@logModFu
|
||||||
def channelCreated(self, server, state, context = None):
|
def channelCreated(self, server, state, context = None):
|
||||||
pass
|
pass
|
||||||
|
5
mumo.py
5
mumo.py
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8
|
# -*- coding: utf-8
|
||||||
|
|
||||||
# Copyright (C) 2010 Stefan Hacker <dd0t@users.sourceforge.net>
|
# Copyright (C) 2010-2011 Stefan Hacker <dd0t@users.sourceforge.net>
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@@ -342,6 +342,9 @@ def do_main_program():
|
|||||||
@checkSecret
|
@checkSecret
|
||||||
@forwardServer
|
@forwardServer
|
||||||
def channelStateChanged(self, c, current=None): pass
|
def channelStateChanged(self, c, current=None): pass
|
||||||
|
@checkSecret
|
||||||
|
@forwardServer
|
||||||
|
def userTextMessage(self, u, m, current=None) : pass
|
||||||
|
|
||||||
class contextCallback(Murmur.ServerContextCallback):
|
class contextCallback(Murmur.ServerContextCallback):
|
||||||
def __init__(self, manager, server, sid):
|
def __init__(self, manager, server, sid):
|
||||||
|
Reference in New Issue
Block a user