chromecow
Visitor
|
seeing server variables in modules - 2008/03/26 00:05
I'm writing a simple (I hope) module to allow the user to query whether a specific room or users exists.
So far, I can send:
<exists nickName="nameToTest" /> or <exists room="roomToTest" />
And get it to echo to the client:
<existst>What I Sent</exists>
But what I can't seem to grasp is how get the information I need to make the comparison. It looks like (for the name part, anyway) what I want to look at is:
allNickNames.values
But, I can't seem to access that from my module.
| Code: | from palabre import logger,logging
class existsQueries:
def __init__(self,server):
self.server = server
self.name = "existsQueries"
# Registering the EXISTS node
self.server.registerNode('exists',self.name)
return
def doNode(self,nodeName,node,client):
if nodeName == 'exists':
# Check to see if Nickname exists
# Did user send nickName?
if node["attrs"].has_key('nickName'):
# Filter out user requesting room and nick info at the same time
if node["attrs"].has_key('room'):
logger.info("Cannot ask for nickName and Room in same request")
return
else:
client.clientSendMessage(self.server.formatMessage('exists',[],node["attrs"].get('nickName')))
# Check to see if a Room exists
# Did user send Room?
if node["attrs"].has_key('room'):
client.clientSendMessage(self.server.formatMessage('exists',[],node["attrs"].get('room')))
return
|
|