Exemplo n.º 1
0
  def callback(self, handle, arg):
    """Standard callback function. Defines default commands to be used by typing them into chat."""

    host = arg.source()
    user = irclib.nm_to_n(host)
    args = arg.arguments()[0]
    chan = arg.target()
    
    for f****t in faggots:
        if re.search(f****t, host):
          return

    if "!help" in args:
      self.server.privmsg(user, self.help(user))

      """ Useless faggotry
    elif "!checkem" in args:
      output = checkem.checkem( user )

      if output:
        self.server.notice(user, output )

    elif "!tlnote" in args:
      tlnote._open()
      tlnote._create()

      note = tlnote.tlnote()

      if note:
        self.server.notice(chan, note)

      tlnote._close()

    elif ".tlnote" in args:

      arguments = args.split(" ")

      if len(arguments) < 2:
        return

      note = " ".join( arguments[1:] )

      tlnote._open()
      tlnote._create()

      tlnote.add( user, note )
      self.server.privmsg( user, "Added: {}".format( note ) )

      tlnote._close()
      """

    elif "!thread" in args:
      if chan == "#infinite-stratos":
        thread = "http://boards.4chan.org/a/res/%s" % self.thread
        self.server.notice(chan, "Current thread: %s" % thread)

    elif re.search("^(!eightball|!8ball)", args):       # To have the ^ wildcard working in regexp we need to strip args from ['] first.
      self.server.notice( user, eightball.eightball( user ) )

    elif re.search( "^!loli", args):

      #Open db and create if needed
      loli.open()
      loli.create()

      #Execute command and return output
      output = loli.loli( user )

      if output:
        self.server.notice(user, output )

      #Close db
      loli.save()

    elif re.search( "^!steal", args):

      arguments = args.split(" ")

      #Only wrote !steal
      if len( arguments ) < 2:
        return;

      target = arguments[1]

      logging.debug("%s is attempting to steal lolis from %s" % ( user, target ))

      if user == target:
        return

      #Little protection for gangrape
      if target == self.steal_lastperson:
        return

      self.steal_lastperson = target
      
      """
      if target in mods: #Because I can
        self.server.privmsg(chan, "NOPE.exe")
        return
      """

      #Open db
      loli.open()
      loli.create()

      #Execute command and return output
      output = loli.steal( user, target )

      if output:
        self.server.notice( "%s,%s" % (user, target), output )

      #Close db
      loli.save()

    elif re.search( "^!top5", args):
      print args
      print user

      loli.open()
      loli.create()

      data = loli.top5()
      
      print data

      if data:
        _i = 1

        for user in data:
          print user
          out = "%s. - %s with %s lolis" % ( _i, user[0], user[1], ) 
          print out
          self.server.privmsg(chan, out)
          _i += 1

      loli.save()

    elif re.search( "^!google", args ):

      arguments = args.split(" ")

      if len(arguments) < 2:
        return

      _query = arguments[1:]

      self.server.notice( user, google.search( user, " ".join( _query ) ) )

    elif re.search( "^!moon", args ):

      arguments = args.split(" ")

      if len(arguments) < 2:
        return

      text = " ".join( arguments[1:] )
      tl   = gtranslate._translate( text.decode('utf8') )

      self.server.notice( user, "%s, moon >> engrish :: %s" % ( user, tl.encode('utf8') ) )

    elif re.search("^!gelbooru", args):

      arguments = args.split(" ")

      if len(arguments) < 2:
        return

      _query = arguments[1:]

      self.server.notice( user, gelbooru.open( " ".join( _query ) ) )

    elif re.search( "^!timeleft", args ):
      if chan == "#infinite-stratos":
        self.server.privmsg(chan, timeleft.timeleft( user ))

    elif re.search("^POMF =3", args):

      #Stop spamming that shit
      if ( int(time.time()) - self.pomfdown ) > 5:
        self.server.privmsg(chan, "Wah!")

        self.pomfdown = int(time.time())

    elif re.search("^Wah!", args):

      #Stop spamming that shit
      if ( int(time.time()) - self.pomfdown ) > 5:
        self.server.privmsg(chan, "What are we gonna do on the bed?")

        self.pomfdown = int(time.time())

    elif re.search("^;_;", args):

      if ( int(time.time()) - self.baww ) > 5:
        self.server.privmsg(chan, ";_;")

        self.baww = int(time.time())

    elif re.search("UNTZ", args):

      if ( int(time.time()) - self.untz ) > 5:
        self.server.privmsg(chan, "UNTZ UNTZ UNTZ UTNZ UTNZ UNTZ")

        self.untz = int(time.time())

    # NOW I'VE LOST IT
    elif re.search("A NIGHT SKY FULL OF CRIES", args, re.IGNORECASE):
      self.server.privmsg(chan, "HEARTS FILLED WITH LIES")
    elif re.search("HEARTS FILLED WITH LIES", args, re.IGNORECASE):
      self.server.privmsg(chan, "THE CONTRACT, IS IT WORTH THE PRICE?")
    elif re.search("THE CONTRACT. IS IT WORTH THE PRICE.", args, re.IGNORECASE):
      self.server.privmsg(chan, "A SOUL PLEDGED TO THE DARKNESS")
    elif re.search("A SOUL PLEDGED TO THE DARKNESS", args, re.IGNORECASE):
      self.server.privmsg(chan, "NOW I'VE LOST IT")
    elif re.search("NOW I'VE LOST IT", args, re.IGNORECASE):
      self.server.privmsg(chan, "I KNOW I CAN KILL")
    elif re.search("I KNOW I CAN KILL", args, re.IGNORECASE):
      self.server.privmsg(chan, "THE TRUTH EXISTS BEYOND THE GATE")
    elif re.search("THE TRUTH (EXISTS|LIES|IS) BEYOND THE GATE", args, re.IGNORECASE):
      self.server.privmsg(chan, "*guitar riff*")

    elif re.search("(X|x|:|;|=)(P|D|\)|\(|\/|\\\)|((>|<|\*|O|o|\^)(\.*|_*|-*)(>|<|\*|O|o|\^))", args) and not self.gaia:

      if chan == "#madoka": #Derp
        return

      if not random.randint(0,4): #25%
        self.server.notice(user, "{}, gb2 >>>/gaia/".format(user))

    elif re.search("^!gsearch", args):
      arguments = args.split(" ")

      if len(arguments) < 2:
        return

      _query = arguments[1:]

      self.server.notice( user, str(gelboorus.search( " ".join( _query ) ) ) )

    else:
      mentioned = 0
      public    = self.public
      nickname  = self.server.nickname

      output = chat.parse( user, args, nickname, public )

      if output != None:
        self.server.privmsg( chan, output )

      return
Exemplo n.º 2
0
  def modcmd(self, handle, arg):
    """Callback function for moderator commands (quit etc.)"""

    user = irclib.nm_to_n(arg.source())
    args = arg.arguments()[0]

    if user in mods or re.search( "desu\.wa", user) or re.search("is\.my\.husbando", user ):

      if ".quit" in args:
        self.server.close()
        sys.exit()

      elif re.search(".say", args):
        arg = args.split()

        if len(arg) < 2:
          return

        if arg[1] in channels:
          if re.search("/me", arg[2]):
            if len(arg) < 4:
              return

            self.server.ctcp('action', arg[1], " ".join( arg[3:] ) )

          else:
            if len(arg) < 3:
              return

            self.server.privmsg(arg[1], " ".join( arg[2:] ))

        else:
          if re.search("/me", arg[1]):

            if len(arg) < 3:
              return

            self.action( " ".join( arg[2:] ) )

          else:
            self.server.privmsg(channels[0], " ".join( arg[1:] ))

      elif "!help" in args:
        self.help(user)

      elif re.search(".nick", args):
        arg = args.split()

        if len(arg) < 2:
          return

        print "Changed nick to", arg[1]
        self.server.nick(arg[1])

      elif ".pubchat" in args:
        if self.public == 0: self.public = 1
        else: self.public = 0

        self.server.privmsg(user, "Public conversation mode is now {}.".format( self.public == 0 and "OFF" or "ON" ))

      elif re.search(".join", str(args)):
          arg = args.split()

          if len(arg) < 2:
            return

          for chan in arg[1:]:
            print "Joing channel", chan
            self.server.join( chan )
            
            if not chan in channels:
              channels.append(chan)

      elif re.search(".part", args):
          arg = args.split()

          if len(arg) < 2:
            return

          for chan in arg[1:]:
            print "Leaving channel", chan
            self.server.part( chan )

            if chan in channels:
              channels.remove(chan)
      elif re.search(".channels", args):
        self.server.privmsg(user, "Channels: %s" % " ".join(channels) )

	    
      elif re.search(".settopic", args):
        """".settopic #chan thread episode"""
        
        arg = args.split()
        print arg
        
        if len(arg) < 3:
          return
        
        chan   = arg[1]
        thread = arg[2]
        ep     = None

        if len(arg) > 3:
          ep = arg[3]

        print chan
        print thread
        print ep
		    
        self.server.topic(chan, settopic.set_topic(thread, ep))
      
      elif ".thread" in args:
        arg = args.split()

        if len(arg) < 1:
          return
        
        self.server.privmsg(user, "Current thread is now: %s" % arg[1])
        self.thread = arg[1]

        
      else:
        
        output = chat.parse( user, args, self.server.nickname, True, False )

        if output != None:
          self.server.privmsg( user, output )

    else:
      print "PRIVMSG from", arg.source(), ":", args
      output = chat.parse( user, args, self.server.nickname, True, False )

      if output != None:
        print "->> REPLY:", output
        self.server.privmsg( user, output )
Exemplo n.º 3
0
def update_loop(chat_i, emote_cache, messages):
    while True:
        msg = chat.parse(chat_i.recv())
        fetch_and_persist_emotes(msg, emote_cache, messages)