def processChannelMessage(self, m): commands = { "gis": goatpy.tumblr.gis_search, "bis": goatpy.tumblr.bis_search, "yis": goatpy.tumblr.bis_search, # TODO } msg = StringUtil.removeFormattingAndColors(m.getTrailing()) img_match = URL_RX.search(msg) video_match = VIDEO_RX.search(msg) response = None tags = [m.sender] if img_match: url = img_match.group() if is_obsessed(m) or random.random() < 0.60: goatpy.tumblr.cache_url(url) # saves as seen else: tags.append("picture") response = goatpy.tumblr.safe_post(url, tags=tags) elif video_match: url = video_match.group() if is_obsessed(m) or random.random() < 0.60: goatpy.tumblr.cache_url(url) # saves as seen else: tags.append("video") response = goatpy.tumblr.safe_post(url, post_type="video", tags=tags) elif m.modCommand in commands: msg = unicode(StringUtil.removeFormattingAndColors(m.getTrailing())) tokens = msg.split() if len(tokens) > 1: search = " ".join(tokens[1:]) if is_obsessed(m): goatpy.tumblr.cache_search(search) # saves as seen else: provider = "bis" parser = CommandParser(m) if parser.hasVar("provider"): provider = parser.get("provider") if provider == "my mommy": provider = "gis" elif provider not in commands: print "Unknown provider: %s" % provider return tags = [m.sender] tags.extend(tokens[1:]) response = commands[provider](search, tags=tags) if response is not None: m.reply(response)
def processChannelMessage(self, m): if m.sender in BOT_NAMES: return commands = { "stats": self.gen_stats_reply, "purity": self.gen_purity_reply, "sexstats": self.gen_sex_reply, } if m.modCommand in commands: reply = "I'm afraid I just don't know." parser = CommandParser(m) if parser.hasVar("user"): user = parser.get("user") if KVStore.hasUserStore(user): user_store = KVStore.getUserStore(user) reply = commands[m.modCommand](user, user_store) else: chan_store = KVStore.getChanStore(m) reply = commands[m.modCommand](m.getChanname(), chan_store) m.reply("%s: %s" % (m.sender, reply)) else: self.updateStats(m)