Advertisement
killer64

Untitled

Dec 4th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.49 KB | None | 0 0
  1. local name = "moo.lua"
  2. local desc = "mooooooooooooooo"
  3. local version = "0.2"
  4.  
  5. function xchat_register()
  6.     return name, desc, version
  7. end
  8. function process_crackbot(word)
  9.     if word[1]==":Crackbot!~Meow@unaffiliated/jacob1/bot/jacobot" and word[2]=="PRIVMSG" and word[3]=="^v" and word[4]==":-^v:" then
  10.         local txt=table.concat({unpack(word,5)}," ")
  11.         if txt:match("%(%+(.-) moos%)") then
  12.             xchat.command("msg CrackBot sell moo $inv[moo] moo")
  13.         end
  14.         local cows=txt:match("%((.-) cows%)") or txt:match("%((.-) cow%)")
  15.         if not cows then
  16.             cows=txt:match("(%S+) baby cows are born")
  17.             if cows then
  18.                 cows="+"..cows
  19.             end
  20.         end
  21.         if cows then
  22.             if cows:sub(1,1)=="+" then
  23.                 xchat.command("msg CrackBot sell cow "..cows:sub(2).." moo")
  24.             else
  25.                 xchat.command("msg CrackBot buy cow "..cows:sub(2).." moo")
  26.             end
  27.         end
  28.     end
  29.     return xchat.EAT_NONE
  30. end
  31. function xchat_init()
  32.     xchat.hook_command("MOO","cmd_moo",xchat.PRI_NORM,"MOO: Usage: moo on,off")
  33.     xchat.hook_server("PRIVMSG","process_crackbot")
  34. end
  35. local running=false
  36. function moo()
  37.     if not running then
  38.         return false
  39.     end
  40.     xchat.command("msg CrackBot use cow moo")
  41.     return true
  42. end
  43. function cmd_moo(word,eol,data)
  44.     if running and word[2]=="off" then
  45.         xchat.print("stopped mooing")
  46.         running=false
  47.     elseif not running and word[2]=="on" then
  48.         xchat.print("started mooing")
  49.         xchat.hook_timer(4000,"moo")
  50.         running=true
  51.     else
  52.         xchat.print("Usage: moo [on,off]")
  53.     end
  54.     xchat.print("end")
  55.     return xchat.EAT_XCHAT
  56. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement