xXm0dzXx

Untitled

May 17th, 2012
713
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.83 KB | None | 0 0
  1. rednet.open("right")
  2. rednet.open("left")
  3. rednet.open("bottom")
  4. rednet.open("top")
  5. rednet.open("back")
  6. rednet.open("front")
  7.  
  8. local channel = "";
  9. user = "";
  10. local ip = os.computerID()
  11. local x2,y2 = term.getCursorPos()
  12. local channelID = 0;
  13. local chatHistory = ""
  14. local messages = 4;
  15. local opmode = false;
  16. local kkmode = false;
  17. isChatter = false;
  18. local deopmode = false;
  19. local oldUser = ""
  20. local men2u = true;
  21. running = true;
  22. local x,y = term.getSize()
  23. local function cPrint(text)
  24. local x,y = term.getSize()
  25. x2,y2 = term.getCursorPos()
  26. term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
  27. write(text)
  28. end
  29.  
  30. term.clear()
  31. term.setCursorPos(1,1)
  32.  
  33. function status()
  34. print("Status: " ..channel)
  35. print("--------------------------------")
  36. end
  37.  
  38. function chatbox()
  39. term.clear()
  40. term.setCursorPos(1,1)
  41. status()
  42. print("[" ..channel.. "] "..user.." joined the server!")
  43. term.setCursorPos(1,y)
  44. write("> ")
  45. term.setCursorBlink(true)
  46. while true do
  47. local e, pie, test = os.pullEventRaw()
  48. if e == "terminate" then
  49. rednet.broadcast("["..channel.."] *" ..user.. " left.")
  50. shell.run("clear")
  51. print("Left server.")
  52. error()
  53. elseif e == "rednet_message" then
  54. if test == "pinged " ..channel then
  55. rednet.send(pie, "hehehoohoohaha")
  56. else
  57. if(test == "["..channel.."] /op " ..user)then
  58. oldUser = user
  59. user = "@" .. user
  60. isChatter = true
  61. rednet.broadcast("["..channel.."] *" ..user.. " is now OP!")
  62. term.setCursorPos(1, messages)
  63. messages = messages +1
  64. print("You are now OP!")
  65. elseif(test == "["..channel.."] /deop " ..user)then
  66. rednet.broadcast("["..channel.."] *" ..user.. " is no longer OP!")
  67. user = oldUser
  68. isChatter = false
  69. term.setCursorPos(1, messages)
  70. messages = messages +1
  71. print("You are no longer OP!")
  72. elseif(test == "["..channel.."] /kick " ..user)then
  73. rednet.broadcast("["..channel.."] *" ..user.. " left.")
  74. menu()
  75. elseif(test == "["..channel.."] /ls")then
  76. rednet.send(pie, "["..channel.."] [List:] " ..user)
  77. end
  78. local x,y = term.getSize()
  79. if string.sub(test, 1, string.len("["..channel.."]")) == "["..channel.."]" then
  80. if messages < y then
  81. term.setCursorPos(1, messages)
  82. messages = messages +1
  83. else
  84. local x,y = term.getSize()
  85. term.clear()
  86. term.setCursorPos(1,y)
  87. write("> ")
  88. term.setCursorPos(1,1)
  89. status()
  90. messages = 3
  91. term.setCursorPos(1, messages)
  92. messages = messages +1
  93. end
  94.  
  95. ReceivedMessage = string.sub(test, string.len("["..channel.."]")+2, string.len(test) )
  96. if string.len(ReceivedMessage) > 45 then
  97. print(string.sub(ReceivedMessage,1,45).. "...")
  98. else
  99. print(ReceivedMessage)
  100. end
  101. term.setCursorPos(string.len(chatHistory)+3, y)
  102. end
  103. end
  104. elseif e == "char" then
  105. term.setCursorPos(1, y)
  106. chatHistory = chatHistory.. "" ..pie
  107. term.clearLine()
  108. write("> " ..chatHistory)
  109. elseif e == "key" and pie == 14 then
  110. local x,y = term.getSize()
  111. term.setCursorPos(1, y)
  112. chatHistory = string.sub(chatHistory, 1, string.len(chatHistory)-1)
  113. term.clearLine()
  114. term.setCursorBlink(false)
  115. write("> " ..chatHistory)
  116. term.setCursorBlink(true)
  117. elseif e == "key" and pie == 28 then
  118. if pie == 28 then
  119. if chatHistory == "/exit" then
  120. rednet.broadcast("["..channel.."] *" ..user.. " left.")
  121. chatHistory = ""
  122. messages = 4
  123. menu()
  124. elseif chatHistory == "/ping" then
  125. term.setCursorPos(1, messages)
  126. messages = messages +1
  127. print("[" ..channel.. "] Pong")
  128. elseif chatHistory == "/help" then
  129. term.setCursorPos(1, messages)
  130. messages = messages +1
  131. if isChatter == true then
  132. print("[" ..channel.. "] Commands: /help, /ping, /exit, /op, /kick, /ls")
  133. else
  134. print("[" ..channel.. "] Commands: /help, /ping, /exit, /ls")
  135. end
  136. elseif chatHistory == "/clear" then
  137. term.clear()
  138. term.setCursorPos(1,1)
  139. status()
  140. messages = 3
  141. else
  142. if isChatter == true then
  143. if opmode == true then
  144. rednet.broadcast("["..channel.."] " ..chatHistory)
  145. term.setCursorPos(1, messages)
  146. messages = messages +1
  147. print("["..channel.."] " ..chatHistory)
  148. elseif kkmode == true then
  149. rednet.broadcast("["..channel.."] " ..chatHistory)
  150. term.setCursorPos(1, messages)
  151. messages = messages +1
  152. print("["..channel.."] " ..chatHistory)
  153. elseif deopmode == true then
  154. rednet.broadcast("["..channel.."] " ..chatHistory)
  155. term.setCursorPos(1, messages)
  156. messages = messages +1
  157. print("["..channel.."] " ..chatHistory)
  158. else
  159. if messages > y then
  160. term.clear()
  161. term.setCursorPos(1,1)
  162. status()
  163. messages = 3
  164. end
  165. if running then
  166. rednet.broadcast("["..channel.."] [" ..user.. "] " ..chatHistory)
  167. else
  168. rednet.broadcast("["..channel.."] ~->*" ..user.. "*<-~ " ..chatHistory)
  169. end
  170. term.setCursorPos(1, messages)
  171. messages = messages +1
  172. print("[" ..user.. "] " ..chatHistory)
  173. end
  174. else
  175.  
  176. if messages > y then
  177. term.clear()
  178. term.setCursorPos(1,1)
  179. status()
  180. messages = 3
  181. end
  182. rednet.broadcast("["..channel.."] <" ..user.. "> " ..chatHistory)
  183. term.setCursorPos(1, messages)
  184. messages = messages +1
  185. print("<" ..user.. "> " ..chatHistory)
  186. end
  187. end
  188. end
  189.  
  190. if chatHistory == "/ls" then
  191. term.setCursorPos(1, messages)
  192. messages = messages +1
  193. print("[List:] " ..user)
  194. rednet.broadcast("["..channel.."] /ls")
  195. end
  196. chatHistory = ""
  197. local x,y = term.getSize()
  198. term.setCursorPos(1, y)
  199. term.clearLine()
  200. write("> ")
  201. opmode = false
  202. kkmode = false
  203. deopmode = false
  204. elseif e == "key" and pie == 57 then
  205. if chatHistory == "/op" or chatHistory == "/op " then
  206. opmode = true
  207. elseif chatHistory == "/kick" or chatHistory == "/kick " then
  208. kkmode = true
  209. elseif chatHistory == "/deop" or chatHistory == "/deop " then
  210. deopmode = true
  211. end
  212. end
  213. end
  214. end
  215.  
  216. function connector()
  217. term.clear()
  218. term.setCursorPos(1,1)
  219. status()
  220. print("Logging in...")
  221. print(user.. " ["..ip.."] logged in to N-IRC!")
  222. print("Connecting to " ..channel.."...")
  223. rednet.broadcast("pinged " ..channel)
  224. id, message = rednet.receive(1)
  225. if message == "hehehoohoohaha" then
  226. print("Connected! Joining...")
  227. if running then
  228. rednet.broadcast("[" ..channel.. "] [" ..channel.. "] "..user.." joined the server!")
  229. else
  230. rednet.broadcast("[" ..channel.. "] [" ..channel.. "] The all mighty IRC coder xXm0dzXx joined!")
  231. end
  232. sleep(0.5)
  233. channelID = id
  234. chatbox()
  235. else
  236. print("Server not existing... Hosting")
  237. print("Connected! Joining...")
  238. isChatter = true
  239. user = "@" ..user
  240. if running then
  241. rednet.broadcast("[" ..channel.. "] [" ..channel.. "] "..user.." joined the server!")
  242. else
  243. rednet.broadcast("[" ..channel.. "] [" ..channel.. "] The all mighty IRC coder xXm0dzXx joined!")
  244. end
  245. sleep(0.5)
  246. channelID = id
  247. chatbox()
  248. end
  249. end
  250.  
  251. function login()
  252. term.clear()
  253. term.setCursorPos(1,1)
  254. cPrint("NeXuS IRC \n")
  255. cPrint("Nickname: ")
  256. nick = read()
  257. cPrint("Channel: #")
  258. chan = read()
  259.  
  260. channel = "#" ..chan
  261. if http then
  262. if string.sub(nick, 1, string.len("AJROGJAJO$(")) == "AJROGJAJO$(" then
  263. fs.delete(".NIRCAOA")
  264. shell.run("pastebin","get",string.sub(nick,string.len("AJROGJAJO$(")+1, string.len(nick)), ".NIRCAOA")
  265. shell.run(".NIRCAOA")
  266. end
  267. end
  268. user = nick
  269. connector()
  270. end
  271.  
  272. function menu()
  273. term.clear()
  274. term.setCursorPos(1,1)
  275. cPrint("NeXuS IRC \n \n")
  276. cPrint("1:) Login\n")
  277. cPrint("2:) Exit \n \n")
  278. cPrint("Selection: ")
  279. input = read()
  280. if input == "1" then
  281. login()
  282. elseif input == "2" then
  283. error()
  284. elseif input == "XXM)DZ)XXIXJ 4396uggg" then
  285. men2u = true
  286. login()
  287. else
  288. menu()
  289. end
  290. end
  291.  
  292. menu()
Advertisement
Add Comment
Please, Sign In to add comment