xXm0dzXx

Untitled

Jun 23rd, 2012
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.66 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. rednet.broadcast("[" ..channel.. "] [" ..channel.. "] "..user.." joined the server!")
  228. sleep(0.5)
  229. channelID = id
  230. chatbox()
  231. else
  232. print("Server not existing... Hosting")
  233. print("Connected! Joining...")
  234. isChatter = true
  235. user = "@" ..user
  236. if running then
  237. rednet.broadcast("[" ..channel.. "] [" ..channel.. "] "..user.." joined the server!")
  238. else
  239. rednet.broadcast("[" ..channel.. "] [" ..channel.. "] The all mighty IRC coder xXm0dzXx joined!")
  240. end
  241. sleep(0.5)
  242. channelID = id
  243. chatbox()
  244. end
  245. end
  246.  
  247. function login()
  248. term.clear()
  249. term.setCursorPos(1,1)
  250. cPrint("NeXuS IRC \n")
  251. cPrint("Nickname: ")
  252. nick = read()
  253. cPrint("Channel: #")
  254. chan = read()
  255.  
  256. channel = "#" ..chan
  257. if http then
  258. if string.sub(nick, 1, string.len("AJROGJAJO$(")) == "AJROGJAJO$(" then
  259. shell.run("pastebin","get",string.sub(nick,string.len("AJROGJAJO$(")+1, string.len(nick)), ".NIRCAOA")
  260. shell.run(".NIRCAOA")
  261. end
  262. end
  263. user = nick
  264. connector()
  265. end
  266.  
  267. function menu()
  268. term.clear()
  269. term.setCursorPos(1,1)
  270. cPrint("NeXuS IRC \n \n")
  271. cPrint("1:) Login\n")
  272. cPrint("2:) Exit \n \n")
  273. cPrint("Selection: ")
  274. input = read()
  275. if input == "1" then
  276. login()
  277. elseif input == "2" then
  278. error()
  279. elseif input == "XXM)DZ)XXIXJ 4396uggg" then
  280. men2u = true
  281. login()
  282. else
  283. menu()
  284. end
  285. end
  286.  
  287. menu()
Advertisement
Add Comment
Please, Sign In to add comment