Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Simple Read-Only IRC Bot by expert700
- local component = require("component")
- local computer = require("computer")
- local event = require("event")
- local internet = require("internet")
- local shell = require("shell")
- local term = require("term")
- local nick = "Gandalf"
- local host = "na.irc.esper.net:6667"
- local pass = "imnotabot"
- local chan = "#beyondreality"
- local nametop = 2400
- local ver_maj = 0
- local ver_min = 1
- local ver_rev = 1
- local ver = ver_maj.."."..ver_min.."."..ver_rev
- local nametab = {"Edward_Elric", "Alphonse_Elric", "Albus_Dumbledore", "Harry_Potter", "Lelouch_Vi_Britannia", "Hatsune_Miku", "Spike_Spiegel", "Kamina", "Light_Yagami", "Kirito", "Asuna", "Eren_Yeager", "Tasumi", "Akame", "Mine", "Leone", "Sheele", "Inaho", "Slaine", "Asseylum",
- "Alucard", "Seras_Victoria", "Rin_Okumura", "Yukio_Okumura", "Monkey_D._Luffy", "Saber", "Lancer", "Archer", "Gilgamesh", "Caster", "Berserker", "Assassin", "Natsu_Dragneel", "Happy", "Lucy", "Gray", "Erza", "Wendy", "Gajeel", "Meliodas", "Naruto", "Sakura", "Sasuke", "Kakashi",
- "Kakashi", "Madara", "Obito", "Sage_of_Six_Paths", "Mustang", "Lt. Hawkeye", "Envy", "Greed", "Lust", "Wrath", "Pride", "Gluttony", "Celty", "Vash_the_Stampede", "Shiroe", "Naotsugu", "Akatsuki", "Nyanta", "Crusty", "Yuno_Gasai", "Akane_Tsunemori", "Shinya_Kogami", "Nobuchika_Ginoza",
- "Rintaro_Okabe", "Kurisu_Makise", "Suzaku_Kururugi", "Ryuk", "L", "C.C", "Yusuke_Urameshi", "Kazuma_Kuwabara", "Kurama", "Hiei", "Genkai", "Hakurei_Reimu", "Kirisame_Marisa", "Patchoulu_Knowledge", "Flandre_Scarlet", "Remilia_Scarlet", "Birdy_Cephon", "Tsutomu_Senkawa", "Soul", "Death_the_Kid",
- "Rikka_Takanashi", "Gundam"}
- if not component.isAvailable("internet") then
- io.stderr:write("You forgot the internet card you dumbfuck")
- return
- end
- local sock, err = internet.open(host)
- if not sock then
- io.stderr:write(err .. "\n")
- return
- end
- sock:setTimeout(0.05)
- sock:write(string.format("PASS %s\r\n", pass))
- sock:write(string.format("NICK %s\r\n", nick))
- sock:write(string.format("USER %s 0 * :%s [OpenComputers]\r\n", nick:lower(), nick))
- sock:flush()
- function changename()
- local newname = nametab[math.random(#nametab)]
- computer.beep()
- sock:write(string.format("NICK %s\r\n", newname))
- sock:flush()
- end
- timer = event.timer(0.5, function()
- local okrep = 0
- if not sock then return false end
- repeat
- local ok, line = pcall(sock.read, sock)
- if not ok then okrep = okrep + 1 end
- if ok and line then
- print(line)
- if line:find("PING") then
- print("Received PING")
- local pongnum = line:sub(6)
- resp = "PONG "..pongnum
- print(resp)
- sock:write(resp)
- sock:flush()
- end
- end
- until okrep == 75
- end)
- os.sleep(10)
- print("Attempting to join")
- sock:write(string.format("JOIN %s\r\n", chan))
- sock:flush()
- os.sleep(2)
- sock:write("PRIVMSG expert700 :Exbot ["..ver.."] is online\r\n")
- sock:flush()
- timer = event.timer(0.5, function()
- local namerep = 2375
- if not sock then return false end
- while true do
- namerep = namerep + 1
- local ok, line = pcall(sock.read, sock)
- if ok and line then
- print(line)
- if line:find("PING") then
- print("Received PING")
- local pongnum = line:sub(6)
- resp = "PONG "..pongnum
- print(resp)
- sock:write(resp)
- sock:flush()
- end
- if line:find("␁") then
- print("CTCP")
- elseif line:find("!newname") then
- changename()
- elseif line:find("!setint") then
- local valmsg = nil
- for half in string.gmatch(line, '([^:]+)') do
- if half:find("!setint") then
- valmsg = half
- end
- end
- for v in string.gmatch(valmsg, "%S+") do
- if not v:find("!setint") then
- nametop = tonumber(v)
- computer.beep()
- end
- end
- end
- end
- if namerep >= nametop then
- computer.beep()
- os.sleep(0.25)
- computer.beep()
- namerep = 0
- changename()
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement