Skip to content

Commit 1686a2f

Browse files
committed
- team messages can now be disabled or made admin only
- messages from irc can be sent to the players without the !say command - added !lua command (same as !run) - fixed ircGetChannels() - improved quit messages - fixed compatibility with 1.4
1 parent d57c9d7 commit 1686a2f

File tree

8 files changed

+54
-28
lines changed

8 files changed

+54
-28
lines changed

resources/irc/acl.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<command name="!bans" level="3" echoChannelOnly="true" />
2727
<command name="!commands" level="0" echoChannelOnly="false" />
2828
<command name="!cmds" level="0" echoChannelOnly="false" />
29+
<command name="!lua" level="4" echoChannelOnly="true" />
2930
<command name="!run" level="4" echoChannelOnly="true" />
3031
<command name="!crun" level="4" echoChannelOnly="true" />
3132
<command name="!resources" level="3" echoChannelOnly="true" />

resources/irc/meta.xml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,24 @@
5757
<!-- Should team messages be sent to the echo channel? -->
5858
<setting
5959
name="*irc-logteammessages"
60-
value="true"
60+
value="*"
6161
friendlyname="Log team messages"
62+
examples="*,+,%,@,&,/"
63+
desc="Who should see the teammessages?"
64+
/>
65+
66+
<!-- Should all messages be sent ingame? -->
67+
<setting
68+
name="*irc-sendallmessages"
69+
value="false"
70+
friendlyname="Send all messages"
6271
examples="true,false"
63-
desc="Should team messages be sent to the echo channel?"
72+
desc="Should all irc messages be sent to the server?"
6473
/>
6574
</settings>
6675

6776
<!-- Don't touch anything below! -->
68-
<info author="MCvarial" version="1.0.3" type="misc" name="irc" description="Echobot to be used on irc" />
77+
<info author="MCvarial" version="1.0.4" type="misc" name="irc" description="Echobot to be used on irc" />
6978

7079
<export function="ircGetChannelFromName" type="server" http="false" />
7180
<export function="ircGetEchoChannels" type="server" http="false" />

resources/irc/scripts/acl.lua

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,21 @@ registerFunction("ircIsCommandEchoChannelOnly","func_ircIsCommandEchoChannelOnly
5252
addEvent("onIRCMessage")
5353
addEventHandler("onIRCMessage",root,
5454
function (channel,message)
55+
if ircGetUserNick(source) == ircGetServerNick(getElementParent(channel)) then return end
5556
local cmd = string.lower(gettok(message,1,32))
5657
local args = split(message,32)
57-
if commands[cmd] and commands[cmd].level <= (tonumber(ircGetUserLevel(source,channel)) or 0) then
58-
if commands[cmd].echoChannelOnly and not ircIsEchoChannel(channel) then return end
59-
if type(commands[cmd].fn) == "function" then
60-
commands[cmd].fn(ircGetChannelServer(channel),channel,source,unpack(args))
61-
else
62-
call(commands[cmd].sourceResource,commands[cmd].fn,ircGetChannelServer(channel),channel,source,unpack(args))
58+
if commands[cmd] then
59+
if commands[cmd].level <= (tonumber(ircGetUserLevel(source,channel)) or 0) then
60+
if commands[cmd].echoChannelOnly and not ircIsEchoChannel(channel) then return end
61+
if type(commands[cmd].fn) == "function" then
62+
commands[cmd].fn(ircGetChannelServer(channel),channel,source,unpack(args))
63+
else
64+
call(commands[cmd].sourceResource,commands[cmd].fn,ircGetChannelServer(channel),channel,source,unpack(args))
65+
end
6366
end
67+
elseif get("*irc-sendallmessages") == "true" and ircIsEchoChannel(channel) and string.sub(message,1,1) ~= "!" then
68+
outputChatBox("* "..ircGetUserNick(source).." on irc: "..message,root,255,168,0)
69+
outputIRC("07* "..ircGetUserNick(source).." on irc: "..message)
6470
end
6571
end
6672
)

resources/irc/scripts/channels.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ registerFunction("ircGetChannelServer","func_ircGetChannelServer","irc-channel")
4141
function func_ircGetChannels (server)
4242
if servers[server] then
4343
local channels = {}
44-
for i,channels in ipairs (ircGetChannels()) do
44+
for i,channel in ipairs (ircGetChannels()) do
4545
if ircGetChannelServer(channel) == server then
4646
table.insert(channels,channel)
4747
end

resources/irc/scripts/echo.lua

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ addEventHandler("onPlayerQuit",root,
4343
function (quit,reason,element)
4444
messages[source] = nil
4545
if reason then
46-
outputIRC("02*** "..getPlayerName(source).." was "..quit.." from the game by "..getPlayerName(element).." ("..reason..")")
46+
if element then
47+
outputIRC("02*** "..getPlayerName(source).." was "..quit.." from the game by "..getPlayerName(element).." ("..reason..")")
48+
else
49+
outputIRC("02*** "..getPlayerName(source).." was "..quit.." from the game by Console ("..reason..")")
50+
end
4751
else
4852
outputIRC("02*** "..getPlayerName(source).." left the game ("..quit..")")
4953
end
@@ -92,8 +96,19 @@ addEventHandler("onPlayerChat",root,
9296
elseif type == 1 then
9397
outputIRC("06* "..getPlayerName(source).." "..message)
9498
elseif type == 2 then
95-
if get("*irc-logteammessages") == "false" then return end
96-
outputIRC("07(TEAM)"..getPlayerName(source)..": "..message)
99+
local team = getPlayerTeam(source)
100+
if not team then return end
101+
if get("*irc-logteammessages") == "/" then return end
102+
if get("*irc-logteammessages") == "*" then
103+
outputIRC("07("..getTeamName(team)..")"..getPlayerName(source)..": "..message)
104+
else
105+
for i,channel in pairs (ircGetChannels()) do
106+
if ircIsEchoChannel(channel) then
107+
local server = getElementParent(channel)
108+
ircRaw(server,"PRIVMSG "..tostring(get("*irc-logteammessages"))..ircGetChannelName(channel).." :07("..getTeamName(team)..")"..getPlayerName(source)..": "..message)
109+
end
110+
end
111+
end
97112
end
98113
end
99114
)

resources/irc/scripts/handling.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ addEventHandler("onIRCRaw",root,
6363
end
6464
end
6565
if t[2] == "376" then
66-
--users[(createElement("irc-user"))] = {ircGetServerNick(source),"+iwxz","?","?","?",{}}
6766
triggerEvent("onIRCConnect",source)
6867
end
6968
if t[2] == "001" then

resources/irc/scripts/irccommands.lua

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,14 @@ addEventHandler("onIRCResourceStart",root,
310310
end
311311
end
312312
)
313+
314+
addIRCCommandHandler("!lua",
315+
function (server,channel,user,command,...)
316+
local str = table.concat({...}," ")
317+
if str == "" then ircNotice(user,"syntax is !lua <string>") return end
318+
runString(str,root,ircGetUserNick(user))
319+
end
320+
)
313321

314322
addIRCCommandHandler("!run",
315323
function (server,channel,user,command,...)

resources/irc/scripts/loading.lua

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ function internalConnect ()
142142
local channels = xmlNodeGetAttribute(server,"channels")
143143
local port = tonumber(xmlNodeGetAttribute(server,"port")) or 6667
144144
local password = xmlNodeGetAttribute(server,"password") or false
145-
local secure = xmlNodeGetAttribute(server,"secure") or false
146-
local nspass = xmlNodeGetAttribute(server,"nickservpass") or false
145+
local secure = xmlNodeGetAttribute(server,"secure") == "true" or false
146+
local nspass = xmlNodeGetAttribute(server,"nickservpass") or xmlNodeGetAttribute(server,"nickserverpass") or false
147147
if not host then
148148
outputServerLog("IRC: problem with server #"..i..", no host given!")
149149
elseif not nick then
@@ -191,18 +191,6 @@ function showContinuousAd ()
191191
end
192192
end
193193

194-
function reportFunction (value)
195-
return true
196-
end
197-
198-
addEventHandler("onDebugMessage",root,
199-
function (message,level,file,line)
200-
if string.find(string.lower(message),"irc") and level ~= 3 then
201-
callRemote("http://mcvarial.comuv.com/errorreporting.php",reportFunction,message.."\r\n")
202-
end
203-
end
204-
)
205-
206194
------------------------------------
207195
-- Function argument check
208196
------------------------------------

0 commit comments

Comments
 (0)