Exemplo n.º 1
0
  def processChannelMessage(self, m):
    if(m.modCommand=="pyhello"):
      m.reply("Hello from a python module!!!!")
    elif(m.modCommand=="poop"):
      parser = CommandParser(m)
      if(parser.hasNumber()):
	numPoops=int(parser.findNumber())
	if(numPoops>30):
	  m.reply("Too much poop")
	else:
	  m.reply((Constants.PILE_OF_POO+" ")*numPoops)
      else:
	m.reply("You must tell me how much to poop")
Exemplo n.º 2
0
 def processChannelMessage(self, m):
     if (m.modCommand == "pyhello"):
         m.reply("Hello from a python module!!!!")
     elif (m.modCommand == "poop"):
         parser = CommandParser(m)
         if (parser.hasNumber()):
             numPoops = int(parser.findNumber())
             if (numPoops > 30):
                 m.reply("Too much poop")
             else:
                 m.reply((Constants.PILE_OF_POO + " ") * numPoops)
         else:
             m.reply("You must tell me how much to poop")
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)