mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 03:05:30 -04:00
Merge pull request #240 from Techokami/master
Further improved irc.lua, better display for actions, computer.beep() when nick is mentioned.
This commit is contained in:
commit
bbff237d9d
@ -2,6 +2,7 @@
|
|||||||
-- http://tools.ietf.org/html/rfc2812
|
-- http://tools.ietf.org/html/rfc2812
|
||||||
|
|
||||||
local component = require("component")
|
local component = require("component")
|
||||||
|
local computer = require("computer")
|
||||||
|
|
||||||
if not component.isAvailable("internet") then
|
if not component.isAvailable("internet") then
|
||||||
io.stderr:write("OpenIRC requires an Internet Card to run!\n")
|
io.stderr:write("OpenIRC requires an Internet Card to run!\n")
|
||||||
@ -164,16 +165,23 @@ local function handleCommand(prefix, command, args, message)
|
|||||||
print("[" .. args[1] .. "] " .. name(prefix) .. " kicked " .. args[2])
|
print("[" .. args[1] .. "] " .. name(prefix) .. " kicked " .. args[2])
|
||||||
elseif command == "PRIVMSG" then
|
elseif command == "PRIVMSG" then
|
||||||
if string.find(message, "\001TIME\001") then
|
if string.find(message, "\001TIME\001") then
|
||||||
sock:write("NOTICE " .. name(prefix) .. " :\001TIME " .. os.date() .. "\001\r\n")
|
sock:write("NOTICE " .. name(prefix) .. " :\001TIME " .. os.date() .. "\001\r\n")
|
||||||
sock:flush()
|
sock:flush()
|
||||||
elseif string.find(message, "\001VERSION\001") then
|
elseif string.find(message, "\001VERSION\001") then
|
||||||
sock:write("NOTICE " .. name(prefix) .. " :\001VERSION Minecraft/OpenComputers Lua 5.2\001\r\n")
|
sock:write("NOTICE " .. name(prefix) .. " :\001VERSION Minecraft/OpenComputers Lua 5.2\001\r\n")
|
||||||
sock:flush()
|
sock:flush()
|
||||||
elseif string.find(message, "\001PING") then
|
elseif string.find(message, "\001PING") then
|
||||||
sock:write("NOTICE " .. name(prefix) .. " :" .. message .. "\001\r\n")
|
sock:write("NOTICE " .. name(prefix) .. " :" .. message .. "\001\r\n")
|
||||||
sock:flush()
|
sock:flush()
|
||||||
end
|
end
|
||||||
print("[" .. args[1] .. "] " .. name(prefix) .. ": " .. message)
|
if string.find(message, nick) then
|
||||||
|
computer.beep()
|
||||||
|
end
|
||||||
|
if string.find(message, "\001ACTION") then
|
||||||
|
print("[" .. args[1] .. "] " .. name(prefix) .. string.gsub(string.gsub(message, "\001ACTION", ""), "\001", ""))
|
||||||
|
else
|
||||||
|
print("[" .. args[1] .. "] " .. name(prefix) .. ": " .. message)
|
||||||
|
end
|
||||||
elseif command == "NOTICE" then
|
elseif command == "NOTICE" then
|
||||||
print("[NOTICE] " .. message)
|
print("[NOTICE] " .. message)
|
||||||
elseif command == "ERROR" then
|
elseif command == "ERROR" then
|
||||||
@ -234,7 +242,7 @@ local function handleCommand(prefix, command, args, message)
|
|||||||
if info.realName then print("Real name: " .. info.realName) end
|
if info.realName then print("Real name: " .. info.realName) end
|
||||||
if info.host then print("Host: " .. info.host) end
|
if info.host then print("Host: " .. info.host) end
|
||||||
if info.server then print("Server: " .. info.server .. (info.serverInfo and (" (" .. info.serverInfo .. ")") or "")) end
|
if info.server then print("Server: " .. info.server .. (info.serverInfo and (" (" .. info.serverInfo .. ")") or "")) end
|
||||||
if info.secureconn then print(info.secureconn) end
|
if info.secureconn then print(info.secureconn) end
|
||||||
if info.channels then print("Channels: " .. info.channels) end
|
if info.channels then print("Channels: " .. info.channels) end
|
||||||
if info.idle then print("Idle for: " .. info.idle) end
|
if info.idle then print("Idle for: " .. info.idle) end
|
||||||
whois[nick] = nil
|
whois[nick] = nil
|
||||||
@ -266,7 +274,7 @@ local function handleCommand(prefix, command, args, message)
|
|||||||
elseif command == commands.RPL_HELPSTART or
|
elseif command == commands.RPL_HELPSTART or
|
||||||
command == commands.RPL_HELPTXT or
|
command == commands.RPL_HELPTXT or
|
||||||
command == commands.RPL_ENDOFHELP then
|
command == commands.RPL_ENDOFHELP then
|
||||||
print(message)
|
print(message)
|
||||||
elseif command == commands.ERR_BANLISTFULL or
|
elseif command == commands.ERR_BANLISTFULL or
|
||||||
command == commands.ERR_BANNEDFROMCHAN or
|
command == commands.ERR_BANNEDFROMCHAN or
|
||||||
command == commands.ERR_CANNOTSENDTOCHAN or
|
command == commands.ERR_CANNOTSENDTOCHAN or
|
||||||
@ -282,7 +290,7 @@ local function handleCommand(prefix, command, args, message)
|
|||||||
command == commands.ERR_USERNOTINCHANNEL or
|
command == commands.ERR_USERNOTINCHANNEL or
|
||||||
command == commands.ERR_WASNOSUCHNICK or
|
command == commands.ERR_WASNOSUCHNICK or
|
||||||
command == commands.ERR_MODELOCK then
|
command == commands.ERR_MODELOCK then
|
||||||
print("[ERROR]: " .. message)
|
print("[ERROR]: " .. message)
|
||||||
elseif tonumber(command) and (tonumber(command) >= 200 and tonumber(command) < 400) then
|
elseif tonumber(command) and (tonumber(command) >= 200 and tonumber(command) < 400) then
|
||||||
print("[Response " .. command .. "] " .. table.concat(args, ", ") .. ": " .. message)
|
print("[Response " .. command .. "] " .. table.concat(args, ", ") .. ": " .. message)
|
||||||
|
|
||||||
@ -368,7 +376,11 @@ local result, reason = pcall(function()
|
|||||||
local line = term.read(history)
|
local line = term.read(history)
|
||||||
if sock and line and line ~= "" then
|
if sock and line and line ~= "" then
|
||||||
line = text.trim(line)
|
line = text.trim(line)
|
||||||
print("[" .. (target or "?") .. "] me: " .. line, true)
|
if line:lower():sub(1,4) == "/me " then
|
||||||
|
print("[" .. (target or "?") .. "] You " .. string.gsub(line, "/me ", ""), true)
|
||||||
|
else
|
||||||
|
print("[" .. (target or "?") .. "] me: " .. line, true)
|
||||||
|
end
|
||||||
if line:lower():sub(1, 5) == "/msg " then
|
if line:lower():sub(1, 5) == "/msg " then
|
||||||
local user, message = line:sub(6):match("^(%S+) (.+)$")
|
local user, message = line:sub(6):match("^(%S+) (.+)$")
|
||||||
if message then
|
if message then
|
||||||
@ -445,4 +457,4 @@ end
|
|||||||
if not result then
|
if not result then
|
||||||
error(reason, 0)
|
error(reason, 0)
|
||||||
end
|
end
|
||||||
return reason
|
return reason
|
Loading…
x
Reference in New Issue
Block a user