示例#1
0
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)
示例#2
0
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)
示例#3
0
文件: support.py 项目: DroneD/droned
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)
示例#4
0
文件: support.py 项目: DroneD/droned
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)
示例#5
0
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.")
示例#6
0
 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
示例#7
0
文件: issue.py 项目: DroneD/droned
  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)
示例#8
0
    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)
示例#9
0
文件: support.py 项目: DroneD/droned
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.")
示例#10
0
文件: jabber.py 项目: c0ns0le/droned
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)
示例#11
0
文件: jabber.py 项目: c0ns0le/droned
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()
示例#12
0
文件: jabber.py 项目: c0ns0le/droned
 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()