def join(conversation, name): if not Team.exists(name): conversation.say("No team named \"%s\" exists." % name) else: team = Team(name) team.addMember(conversation.buddy) conversation.say("You are now on the %s team." % name)
def leave(conversation, name): if not Team.exists(name): conversation.say("No team named \"%s\" exists." % name) else: team = Team(name) team.removeMember(conversation.buddy) conversation.say("You are no longer on the %s team." % name)
def leave(conversation, name): if not Team.exists(name): conversation.say("No team named \"%s\" exists." % name) else: team = Team(name) team.removeMember( conversation.buddy ) conversation.say("You are no longer on the %s team." % name)
def join(conversation, name): if not Team.exists(name): conversation.say("No team named \"%s\" exists." % name) else: team = Team(name) team.addMember( conversation.buddy ) conversation.say("You are now on the %s team." % name)
def members(conversation, name): if not Team.exists(name): conversation.say("No team named \"%s\" exists." % name) else: team = Team(name) if team.agents: members = ','.join(agent.jid for agent in team.agents) heading = "%s members:\n" % name conversation.say(heading + members, useHTML=False) else: conversation.say("That team has no members.")
def start(self): """interface requirement""" if self.running(): return self.factory = XMPPClientFactory( self.jid, decrypt(self.SERVICECONFIG.JABBER_PASSWORD)) self.factory.addBootstrap(STREAM_CONNECTED_EVENT, self.connectionMade) self.factory.addBootstrap(STREAM_END_EVENT, self.connectionLost) self.factory.addBootstrap(STREAM_AUTHD_EVENT, self.connectionAuthenticated) self.factory.addBootstrap(STREAM_ERROR_EVENT, self.receivedError) self.factory.addBootstrap(INIT_FAILED_EVENT, self.initFailed) self.service = TCPClient(self.SERVICECONFIG.JABBER_SERVER, self.SERVICECONFIG.JABBER_PORT, self.factory) self.service.setServiceParent(self.parentService) #build/rebuild jabber teams if not os.path.exists(self.SERVICECONFIG.JABBER_TEAM_ROSTER): try: os.makedirs(self.SERVICECONFIG.JABBER_TEAM_ROSTER) except: log('Cannot load team rosters because %s does not exits' % \ self.SERVICECONFIG.JABBER_TEAM_ROSTER) return for name in os.listdir(self.SERVICECONFIG.JABBER_TEAM_ROSTER): f = (self.SERVICECONFIG.JABBER_TEAM_ROSTER, name) if os.path.isfile('%s/%s' % f): Team(name) #preload team rosters
def assign(self, who): if isinstance(who, str): if Team.exists(who): who = Team(who) elif Conversation.byName(who): #byName handles short usernames as well as full JIDs who = SupportAgent( Conversation.byName(who).buddy ) else: raise ValueError("I don't know any teams or people named \"%s\"" % who) if not isinstance(who, (Team,SupportAgent)): raise TypeError("You can only assign issues to Teams or SupportAgents") self.assignedTo = who if isinstance(who, SupportAgent) and who.available: who.engage(self)
def assign(self, who): if isinstance(who, str): if Team.exists(who): who = Team(who) elif Conversation.byName( who): #byName handles short usernames as well as full JIDs who = SupportAgent(Conversation.byName(who).buddy) else: raise ValueError( "I don't know any teams or people named \"%s\"" % who) if not isinstance(who, (Team, SupportAgent)): raise TypeError( "You can only assign issues to Teams or SupportAgents") self.assignedTo = who if isinstance(who, SupportAgent) and who.available: who.engage(self)
def notify_online(event): ready = env.ready for agent in Team('support').agents: agent.tell("%s droned reporting for duty." % config.ROMEO_ENV_NAME) if not ready: agent.tell( "The environment is still being scanned, please wait...") def check(): if env.ready: for agent in Team('support').agents: agent.tell("The environment is fully scanned and ready.") if checker.running: checker.stop() checker = task.LoopingCall(check) checker.start(1.0)
def joinEnvironmentalChatRoom(event): """determine if we should join a chatroom""" chat = ChatRoom(config.ROMEO_ENV_NAME) #make sure the drone can be managed by the room username = config.ROMEO_ENV_NAME jbserver = jconfig.JABBER_CHAT_SERVICE jid = "%(username)s@%(jbserver)s" % locals() Team('support').addMember(jid) #get the conversation context set to some sane defaults conversation = Conversation(jid) #grant the room access to the server if jconfig.JABBER_TRUST_ROOM: conversation.grantAuthorization(notify=False) #be vain assume all conversations revolve around ourself context = { 'server': Server(config.HOSTNAME), 'subject': Server(config.HOSTNAME), } conversation.context.update(context) #finally join the room chat.join()
def check(): if env.ready: for agent in Team('support').agents: agent.tell("The environment is fully scanned and ready.") if checker.running: checker.stop()