def checkTell(self, bot, nick): tells = self.seenmanager.getTells(nick) tosend = [] for tell in tells: time = datetime.datetime.strftime(tell.time, '%c') text = "{0} in {1} asked to tell you the following: {2} ({3})".format( tell.sender, tell.channel, tell.text.encode('UTF-8'), time) tosend.append(text) if tosend: if not len(tosend) > 4: for text in tosend: bot.msg(nick, text) else: tosend = ["Things people wanted you to know:", ] + tosend + \ ['(It is currently %s)' % datetime.datetime.strftime(datetime.datetime.now(), '%c')] url = pastie.pastie("\n".join(tosend)) def sendmsg(result): bot.msg(nick, "Please check out %s for a list of things people wanted to tell you." % result) url.addCallback(sendmsg) self.seenmanager.clearTells(nick)
def update(self, channel, type, extra): channel = channel.lower() self.channels[channel]["type"] = type self.channels[channel]["extra"] = extra self.channels[channel]["timestamp"] = datetime.datetime.now() if not type in ["QUIT", "JOIN", "RPL_NAMREPLY"]: tosend = list() for data in self.tellconfig[self.nick]: msgdata = eval(data) time = datetime.datetime.strftime(msgdata['date'], '%c') text = "{0} in {1} asked to tell you the following: {2} ({3})".format( msgdata['from'], msgdata['channel'], msgdata['text'], time) tosend.append(text) if tosend: if not len(tosend) > 4: for text in tosend: self.bot.msg(self.nick, text) else: tosend = ["Things people wanted you to know:", ] + tosend + \ ['(It is currently %s)' % datetime.datetime.strftime(datetime.datetime.now(), '%c')] url = pastie.pastie("\n".join(tosend)) self.bot.msg(self.nick, "Please check out %s for a list of things people wanted to tell you." % url) self.tellconfig.reload() self.tellconfig[self.nick] = list() self.tellconfig.write()
def doPaste(data): stdout, stderr, exitcode = data if exitcode == 0: tag = "Success!" else: tag = "Error!" bot.msg(details['channel'], tag + " Sending update results to pastebin...") dat = """SocBot Update Report (%s) STDOUT: %s STDERR: %s Exit code: %d""" % (tag, stdout, stderr, exitcode) return pastie.pastie(dat, prefix="Update results: ")
def on_seen(self, bot, user, details): """SEEN <nick> [channel] [count] - report on when <nick> was last seen in <channel>. <channel> defaults to the current channel""" match = pattern.match(" ".join(details['splitmsg'])) if not match: raise BadParams nick = match.group('nick').lower() channel = match.group('channel') if not channel: if details["wasprivate"]: return "You need to specify a channel!" else: channel = details["channel"] channel = channel.lower() if not channel in bot.connection.channels: return "I am not in {0}".format(channel) count = match.group('count') if not count: data = self.seenmanager.getLastSeen(nick, channel) return self.seenLine(data) else: data = self.seenmanager.getRangedSeen(nick, channel, int(count)) tosend = [] for item in data: tosend.append(self.seenLine(item)) if len(tosend) > 4: url = pastie.pastie("\n".join(tosend), prefix="Please check out ", postfix=" for the seen listing. (it was greater than 4 lines)") return url else: for item in tosend: bot.msg(details['channel'], item)