def _seen(self,nick,what): who = what.split(' ')[1] print (who) if self.user.get(who, None) is not None: defaultlib.send("#autistenchat", nick + ":" + who + " sah ich zuletzt vor "+ str((self._current_milli_time()-self.user[who])/60000)+ " Minuten") else: defaultlib.send("#autistenchat", nick + ":" + who +" hab ich noch nicht gesehen, tut mir leid")
def _cite(self): return p = (Connection.Connection.time() - self.communicator.last_activity) / self.min_citation_interval if p > 0: p = math.log(p) else: p = 0 if Connection.debug: print(p) if len(self.communicator.user) > 0: p = (Connection.Connection.time() - self.communicator.last_activity) / self.min_citation_interval if p > 0: p = math.log(p) else: p = 0 if Connection.debug: print(p) if random.random() < p: defaultlib.send(random.choice(self.citations).encode("utf-8") + "\r\n") if Connection.debug: print( str((Connection.Connection.time() - self.communicator.last_activity) / 60000) + "Minuten seit letzter Aktivity beim Random-Spruch-aufsagen" ) self.communicator.last_activity = Connection.Connection.time()
def _seen(self,nick,what): who = what.split(' ')[1] print (who) if self.user.get(who, None) is not None: defaultlib.send(nick + ":" + who + " sah ich zuletzt vor " + str( (Connection.Connection.time() - self.user[who]) / 60000) + " Minuten", Connection.channel) else: defaultlib.send(nick + ":" + who + " hab ich noch nicht gesehen, tut mir leid", Connection.channel)
def _idle_old(self, nick): cnt = 0 for name, activity in sorted(self.user.iteritems(), key = lambda (k,v): (v,k), reverse=True): if self.user.get(name, None) is not None: if name not in self.communicator.user: continue cnt += 1 defaultlib.send(name + "<-" + str((Connection.Connection.time() - activity) / 60000) + " Minuten", Connection.channel) if cnt > 2: break
def _mods(self, nick): fobj_in = open("mods.txt") mods = [] for mod in fobj_in: mods.append(mod.rstrip()) current_mods = [] outstring = "Aktuell sind folgende Moderatoren online: " for usr in self.communicator.user: if usr in mods: current_mods.append(usr) outstring += usr + " " if current_mods.__len__() != 0: defaultlib.send(outstring, nick) else: defaultlib.send("Leider scheint momentan kein Moderator online zu sein.", nick)
def _activity(self, nick): cnt = [0,0,0] # zwanzig, sechs, zwei minuten for name, activity in sorted(self.user.iteritems(), key = lambda (k,v): (v,k), reverse=True): if self.user.get(name, None) is not None: if name not in self.communicator.user: continue idle = (Connection.Connection.time()-activity)/60000 if idle <= 20: cnt[0] += 1 if idle <= 6: cnt[1] += 1 if idle <= 2: cnt[2] += 1 defaultlib.send('User in den letzten 20 Minuten: ' + str(cnt[0]) + ', 6 Minuten: ' + str(cnt[1]) + ', gerade eben: ' + str(cnt[2]))
def _wiki(self, nick, what): # jo, hier wird wikipedia durchsucht if not self.communicator.counter.user_authorized(nick): defaultlib.send("Wikipedia soll ich durchsuchen? Schau doch lieber in ein richtiges Lexikon!", Connection.channel) return w = wikipedia.set_lang('de') q = what.split(' ') query = '' for word in q: if word != '.w': query += word + ' ' w = wikipedia.search(query) if w.__len__() == 0: defaultlib.send(nick + ', in Wikipedia finde ich dazu nichts. Magst du einen Artikel dazu schreiben?', Connection.channel) return page = wikipedia.WikipediaPage(w.pop(0)) defaultlib.send(nick + ' ' + page.url, Connection.channel) defaultlib.send(page.summary, Connection.channel)
def _wiki(self, nick, what): # jo, hier wird wikipedia durchsucht w = wikipedia.set_lang('de') q = what.split(' ') query = '' for word in q: if word != '.w': query += word + ' ' w = wikipedia.search(query) if w.__len__() == 0: defaultlib.send(nick + ', leider hat die Suche auf Wikipedia kein Ergebnis gebracht, vielleicht hast du dich vertippt?', Connection.channel) return page = wikipedia.WikipediaPage(w.pop(0)) defaultlib.send(nick + ' ' + page.url, Connection.channel) defaultlib.send(page.summary, Connection.channel)
def _seen(self, nick, what): if not self.communicator.counter.user_authorized(nick, 25): defaultlib.send(nick + ": tut mir leid ich darf dir hierrauf noch nicht antworten", Connection.channel) return who = what.split(" ")[1] print (who) if self.user.get(who, None) is not None: defaultlib.send( nick + ":" + who + " sah ich zuletzt vor " + str((Connection.Connection.time() - self.user[who]) / 60000) + " Minuten", Connection.channel, ) else: defaultlib.send(nick + ":" + who + " hab ich noch nicht gesehen, tut mir leid", Connection.channel)
def _idle(self, nick): for usr in self.communicator.user: if self.user.get(usr, None) is not None: defaultlib.send("#autistenchat",usr +"<-"+str((self._current_milli_time()-self.user[usr])/60000)+" Minuten")