Skip to content

Instantly share code, notes, and snippets.

Created July 24, 2008 16:40
Show Gist options
  • Select an option

  • Save anonymous/2215 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/2215 to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Jul 24, 2008.
    51 changes: 51 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,51 @@
    def parse(x)

    $joined = 0
    $counter = 0

    # INITIALIZE VARIABLES
    upmynick = $irc_nick
    mynick = upmynick.downcase
    nick = ""
    chan = ""
    fullmsg = ""
    upfullmsg = ""
    msg = ""
    upmsg = ""

    # SPLIT CODE UP
    s = x.split("\:",3)
    if s[1] =~ /!/ then
    nick = s[1].split("!")[0]
    end
    if s[1] =~ /\ / then
    chan = s[1].split("\ ")[2]
    end
    if s[2] != nil then
    puts s[2]
    fullmsg = s[2].downcase
    upfullmsg = s[2]
    end
    if s[3] != nil then
    puts s[3]
    fullmsg = fullmsg + s[3].downcase
    upfullmsg = upfullmsg + s[3]
    end

    fullmsg = fullmsg.strip
    upfullmsg = upfullmsg.strip

    # CHECK IF MESSAGE IS DIRECTED AT BOT
    if upfullmsg =~ /^(#{upmynick}\:|#{$irc_prefix})(\ )*/ then
    direct = true
    upmsg = upfullmsg.split(/^(#{upmynick}\:|#{$irc_prefix})*/, 2)
    upmsg = upmsg[2].strip
    msg = upmsg.downcase.strip
    else
    upmsg = upfullmsg.strip
    msg = fullmsg.strip
    end
    if direct == true && msg =~ /^(msg)/ then
    place("PRIVMSG #{chan} test1 test2 test3")
    end
    end