def on_chat(self, t, f, msg): knowers = self.adapter.get_users() knowers.remove(self.adapter.nickname) context = {'author': f, 'recipient': t, 'msg': msg, 'knowers': knowers} State.forceState(FindGossip, context)
def on_user_exit(self, nick, timestamp): print "##### EXIT #####" knowers = self.adapter.get_users() knowers.remove(self.adapter.nickname) timestamp = time.strftime("%X", time.localtime()) msg = "left at " + timestamp context = {'author': nick, 'recipient': "", 'msg': msg, 'knowers': knowers} State.forceState(FindGossip, context)
def on_user_inactive(self, nick): State.users = self.adapter.get_users() if State.userState[nick] is not SolicitResponse: self.resumeState[nick] = State.userState[nick] res = State.forceState(SolicitResponse, {'_nick': nick}) #res = State.forceState(SolicitUser,{'_nick': nick}) self.idle[nick] = Timer(GustafoBot.TIMEOUT, self.on_user_inactive, [nick]) self.idle[nick].start() else: res = State.forceState(GiveUpState, {'_nick': nick}) del(State.userState[nick]) del(self.idle[nick]) if len(State.userState) == 0: self.idle[GustafoBot.CHAT] = Timer(10.0, self.on_chat_inactive) self.idle[GustafoBot.CHAT].start() if res is not None: self.send_message(nick, res)
def on_chat_inactive(self): State.users = self.adapter.get_users() users = self.adapter.get_users() users.remove(self.adapter.nickname) if "foaad" in users: user = "******" elif len(users) > 0: random.shuffle(users) user = users[0] else: self.idle[GustafoBot.CHAT] = Timer(GustafoBot.TIMEOUT, self.on_chat_inactive) res = State.forceState(InitialOutreach, {'_nick': user}) if res is not None: self.send_message(user, res) self.idle[user] = Timer(GustafoBot.TIMEOUT, self.on_user_inactive, [user]) self.idle[user].start()