def login(self, pers_no, password, client_name, client_version): self.client_name = client_name self.client_version = client_version kom.ReqLogin(self.conn, pers_no, password).response() kom.ReqSetClientVersion(self.conn, self.client_name, self.client_version) self.conn.set_user(pers_no)
t = encodings.codecs.latin_1_decode( "Asså, ba, jag förstår inte vad du snackar om" )[0] if not replyed: try: kom.ReqSendMessage(conn, msg.sender, encodings.codecs.latin_1_encode(t)[0] ).response() except: print traceback.print_exc() #print orgsearch conn = kom.CachedConnection(KOMSERVER, 4894, "telefonisten") persons = conn.lookup_name(AGENT_PERSON, want_pers = 1, want_confs = 0) if len(persons) != 1: print "Not just one match" else: person = persons[0][0] kom.ReqLogin(conn, person, AGENT_PASSWORD, invisible = 1).response() conn.add_async_handler(kom.ASYNC_SEND_MESSAGE, async_message) kom.ReqAcceptAsync(conn, [kom.ASYNC_SEND_MESSAGE,]).response() kom.ReqSetClientVersion(conn, "telefonist.py", VERSION) while 1: conn.parse_present_data() time.sleep(0.5)
kom.ReqCreateText(conn, subject + "\n" + reformat_text(text), misc_info, aux_items).response() def async_message(msg, c): if msg.recipient: # Not alarm message return subject = SUBJECT % get_pers_name(msg.sender) print "Creating article with subject:" print subject write_article(msg.sender, subject, msg.message) def setup_asyncs(conn): conn.add_async_handler(kom.ASYNC_SEND_MESSAGE, async_message) kom.ReqAcceptAsync(conn, [ kom.ASYNC_SEND_MESSAGE, ]).response() conn = kom.CachedConnection(KOMSERVER, 4894, "alarm_archiver") kom.ReqLogin(conn, AGENT_PERSON, AGENT_PASSWORD, invisible=1).response() setup_asyncs(conn) kom.ReqSetClientVersion(conn, "alarm_archiver.py", VERSION) while 1: select.select([conn.socket], [], []) conn.parse_present_data()
conn = kom.CachedConnection(KOMSERVER, 4894, "invite-all") # Lookup agent user lookup_result = kom.ReqLookupZName(conn, AGENT_PERSON, want_pers = 1).response() if len(lookup_result) < 1: print "Agent user not found" sys.exit(1) elif len(lookup_result) > 2: print "Agent username ambigious" sys.exit(1) agent_person_no = lookup_result[0].conf_no # Login kom.ReqLogin(conn, agent_person_no, AGENT_PASSWORD, invisible = 1).response() kom.ReqSetClientVersion(conn, "invite-all", VERSION) # Lookup conference number lookup_result = kom.ReqLookupZName(conn, INVITE_CONF, want_confs = 1).response() if len(lookup_result) < 1: print "Conference not found" sys.exit(1) elif len(lookup_result) > 2: print "Conference name ambigious" sys.exit(1) invite_conf_no = lookup_result[0].conf_no # Get all persons all_persons = kom.ReqLookupZName(conn, "", want_pers = 1).response()
conn.add_async_handler(kom.ASYNC_SEND_MESSAGE, async_message) conn.add_async_handler(kom.ASYNC_LOGOUT, async_logout) conn.add_async_handler(kom.ASYNC_LOGIN, async_login) conn.add_async_handler(kom.ASYNC_NEW_TEXT, async_new_text) conn.add_async_handler(kom.ASYNC_NEW_RECIPIENT, async_new_recipient) kom.ReqAcceptAsync(conn, [kom.ASYNC_SEND_MESSAGE,]).response() kom.ReqAcceptAsync(conn, [kom.ASYNC_LOGOUT, kom.ASYNC_SEND_MESSAGE, kom.ASYNC_NEW_RECIPIENT, kom.ASYNC_NEW_TEXT, kom.ASYNC_LOGIN ]).response() kom.ReqSetClientVersion(conn, "Canidius %s", VERSION) lastkeys=[] onnow = kom.ReqWhoIsOnDynamic(conn).response() persons = map( lambda x:x.person, onnow ) persons.sort() # Remove duplicates persons = [persons[0]] + [persons[i] for i in range(1, len(persons)) if persons[i] != persons[i - 1]]
def main(): conn = kom.CachedConnection(KOMSERVER, 4894, "snobben") # lookup_name thinks # in the first position means numerical conn.bot = {} conn.authors = {} conn.confs = {} conn.ignoreconfs = [] conn.rlock = threading.RLock() conn.channels = {} bot = 0 for p in CHANNELS.keys(): nick = AGENT_PERSON confs = conn.lookup_name(" "+CHANNELS[p], want_pers = 0, want_confs = 1) if len(confs) != 1: print "Conferences: not just one match" raise SystemExit if not bot: bot = listenBot(conn, [p], nick, ircserver(), IRCPORT ) conn.authors[nick] = bot conn.bot[nick] = bot threading.Thread( None, bot.start, nick ).start() else: bot.join( p ) conn.channels[ confs[0][0] ] = p conn.confs[ p.lower() ] = confs[0][0] conn.ignoreconfs.append([ confs[0][0] ]) print "Connected to %s" % p conn.rlock.acquire() persons = conn.lookup_name(AGENT_PERSON, want_pers = 1, want_confs = 0) conn.rlock.release() print conn.channels if len(persons) != 1: print "Persons: not just one match" raise SystemExit person = persons[0][0] conn.ignoreconfs.append( person ) conn.rlock.acquire() kom.ReqLogin(conn, person, AGENT_PASSWORD, invisible = 1).response() conn.add_async_handler(kom.ASYNC_SEND_MESSAGE, async_message) conn.add_async_handler(kom.ASYNC_NEW_TEXT, async_text) kom.ReqAcceptAsync(conn, [kom.ASYNC_SEND_MESSAGE,kom.ASYNC_NEW_TEXT,]).response() kom.ReqSetClientVersion(conn, "snobben.py", KOMVERSION) conn.rlock.release() print "Starting main kom-loop" while 1: conn.rlock.acquire() conn.parse_present_data() conn.rlock.release() time.sleep(0.5)