<s> from droned . models . team import Team , SupportAgent <EOL> from droned . models . issue import Issue <EOL> from droned . responders import responder <EOL> @ responder ( pattern = "<STR_LIT>" , form = "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def teams ( conversation ) : <EOL> teamlist = '<STR_LIT:\n>' . join ( "<STR_LIT>" % ( team . name , len ( team . agents ) ) for team in Team . objects ) <EOL> conversation . say ( '<STR_LIT:\n>' + teamlist , useHTML = False ) <EOL> @ responder ( pattern = "<STR_LIT>" , form = "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def members ( conversation , name ) : <EOL> if not Team . exists ( name ) : <EOL> conversation . say ( "<STR_LIT>" % name ) <EOL> else : <EOL> team = Team ( name ) <EOL> if team . agents : <EOL> members = '<STR_LIT:U+002C>' . join ( agent . jid for agent in team . agents ) <EOL> heading = "<STR_LIT>" % name <EOL> conversation . say ( heading + members , useHTML = False ) <EOL> else : <EOL> conversation . say ( "<STR_LIT>" ) <EOL> @ responder ( pattern = "<STR_LIT>" , form = "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def join ( conversation , name ) : <EOL> if not Team . exists ( name ) : <EOL> conversation . say ( "<STR_LIT>" % name ) <EOL> else : <EOL> team = Team ( name ) <EOL> team . addMember ( conversation . buddy ) <EOL> conversation . say ( "<STR_LIT>" % name ) <EOL> @ responder ( pattern = "<STR_LIT>" , form = "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def leave ( conversation , name ) : <EOL> if not Team . exists ( name ) : <EOL> conversation . say ( "<STR_LIT>" % name ) <EOL> else : <EOL> team = Team ( name ) <EOL> team . removeMember ( conversation . buddy ) <EOL> conversation . say ( "<STR_LIT>" % name ) <EOL> @ responder ( pattern = "<STR_LIT>" , form = "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def busy ( conversation ) : <EOL> agent = SupportAgent ( conversation . buddy ) <EOL> agent . ready = False <EOL> conversation . say ( "<STR_LIT>" ) <EOL> @ responder ( pattern = "<STR_LIT>" , form = "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def free ( conversation ) : <EOL> agent = SupportAgent ( conversation . buddy ) <EOL> agent . ready = True <EOL> conversation . say ( "<STR_LIT>" ) <EOL> @ responder ( pattern = "<STR_LIT>" , form = "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def announce ( conversation , message ) : <EOL> agent = SupportAgent ( conversation . buddy ) <EOL> message = "<STR_LIT>" % ( agent . name , message ) <EOL> told = <NUM_LIT:0> <EOL> for team in agent . teams : <EOL> for otherAgent in team . agents : <EOL> if otherAgent is agent : continue <EOL> otherAgent . tell ( message ) <EOL> told += <NUM_LIT:1> <EOL> if told : <EOL> agent . tell ( '<STR_LIT>' % told ) <EOL> else : <EOL> agent . tell ( '<STR_LIT>' ) <EOL> @ responder ( pattern = "<STR_LIT>" , form = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> def issues ( conversation ) : <EOL> issues = sorted ( [ i for i in Issue . objects if not i . resolved ] , key = lambda i : i . id ) <EOL> summaries = [ ] <EOL> for issue in issues : <EOL> summary = "<STR_LIT>" % ( issue . id , issue . description ) <EOL> if issue . context [ '<STR_LIT>' ] : <EOL> summary += "<STR_LIT>" % issue . context [ '<STR_LIT>' ] . name <EOL> elif isinstance ( issue . context [ '<STR_LIT>' ] , SupportAgent ) : <EOL> summary += "<STR_LIT>" % issue . context [ '<STR_LIT>' ] . name <EOL> elif issue . context [ '<STR_LIT>' ] is None : <EOL> summary += "<STR_LIT>" <EOL> summaries . append ( summary ) <EOL> heading = '<STR_LIT>' % len ( issues ) <EOL> listing = '<STR_LIT:\n>' . join ( summaries ) <EOL> conversation . say ( heading + listing , useHTML = False ) <EOL> @ responder ( pattern = "<STR_LIT>" , form = "<STR_LIT>" , help = "<STR_LIT>" ) <EOL> def grab ( conversation , id ) : <EOL> id = int ( id ) <EOL> issue = Issue . byID ( id ) <EOL> if not issue : <EOL> conversation . say ( "<STR_LIT>" % id ) <EOL> elif not issue . hasSOP : <EOL> conversation . say ( "<STR_LIT>" <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> conversation . say ( issue . description ) <EOL> contextSummary = '<STR_LIT:\n>' . join ( "<STR_LIT>" % info for info in issue . context . data . items ( ) ) <EOL> conversation . say ( contextSummary , useHTML = False ) <EOL> else : <EOL> existingAgent = issue . context [ '<STR_LIT>' ] <EOL> if existingAgent : <EOL> if existingAgent . conversation is conversation : <EOL> conversation . say ( "<STR_LIT>" ) <EOL> return <EOL> existingAgent . conversation . say ( "<STR_LIT>" % conversation . buddyName ) <EOL> existingAgent . currentIssue = None <EOL> existingAgent . conversation . nevermind ( ) <EOL> conversation . say ( "<STR_LIT>" % id ) <EOL> agent = SupportAgent ( conversation . buddy ) <EOL> agent . ready = True <EOL> agent . currentIssue = None <EOL> agent . conversation . nevermind ( ) <EOL> agent . engage ( issue ) <EOL> @ responder ( pattern = '<STR_LIT>' , form = '<STR_LIT>' , <EOL> help = '<STR_LIT>' ) <EOL> def resolve ( conversation , id , resolution ) : <EOL> id = int ( id ) <EOL> issue = Issue . byID ( id ) <EOL> if not issue : <EOL> conversation . say ( "<STR_LIT>" % id ) <EOL> elif issue . hasSOP : <EOL> conversation . say ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> else : <EOL> conversation . say ( "<STR_LIT>" % id ) <EOL> issue . resolve ( resolution ) </s>
