Guest User

ircjoin

a guest
Nov 2nd, 2016
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. local login = {}
  2. local c = {}
  3. local loop = true
  4.  
  5. local function msg(m)
  6. return string.gsub(m,"%$(%w+)",login)
  7. end
  8.  
  9. term.write("channel name: ")
  10. login.host = read()
  11. term.write("channel password: ")
  12. login.pass = read("*")
  13. term.write("channel nickname: ")
  14. login.user = read()
  15. rednet.broadcast(msg("from:"..os.computerLabel()..", join:$host"))
  16. i = 0
  17.  
  18. while true do
  19.   while loop do
  20.   e,s,m = os.pullEvent("rednet_message")
  21.   print("s: "..s.."  m: "..m)
  22.     for i,j,k,l in string.gmatch(m,"(%w+):(%w+), (%w+):(%w+)") do
  23.       if i == "from" and k == "host" then
  24.         c[1] = {i,j}
  25.         c[2] = {k,l}
  26.         loop = false
  27.       end
  28.     end
  29.   end
  30.   if c[1][1] == "from" then
  31.     if c[1][2] == login.host and c[2][1]..":"..c[2][2] == "host:ok" then
  32.        rednet.send(s,msg("from:"..os.computerLabel()..", pass:$pass"))
  33.        loop = true
  34.       while loop do
  35.         e,s,m = os.pullEvent("rednet_message")
  36.         print("e: "..e.."  s: "..s.."  m: "..m)
  37.         for i,j,k,l in string.gmatch(m,"(%w+):(%w+), (%w+):(%w+)") do
  38.           if i == "from" and k == "access" then
  39.             c[1] = {i,j}
  40.             c[2] = {k,l}
  41.             loop = false
  42.           end      
  43.         end
  44.       until o == 1
  45.       if c[1][1] == "from" and c[1][2] == login.host and c[2][1] == "access" then
  46.         if c[2][2] == "granted" then
  47.         login.access = true
  48.         elseif c[2][2] == "denied" then  
  49.         login.access = false
  50.         break
  51.         end
  52.         if login.access then
  53.         else
  54.         end
  55.         print(login.access)
  56.       end
  57.     end
  58.   end
  59. end
Add Comment
Please, Sign In to add comment