Skip to content

Commit d7b0892

Browse files
committed
Minor bugfixes
1 parent a4155c6 commit d7b0892

File tree

11 files changed

+164
-65
lines changed

11 files changed

+164
-65
lines changed

resources/irc/scripts/channels.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ function func_ircGetChannelFromName (channel)
2121
return false
2222
end
2323

24+
function func_ircGetEchoChannel ()
25+
for i,channel in ipairs (ircGetChannels()) do
26+
if ircIsEchoChannel(channel) then
27+
return channel
28+
end
29+
end
30+
return false
31+
end
32+
2433
function func_ircGetChannelServer (channel)
2534
if channels[channel] then
2635
return getElementParent(channel)

resources/irc/scripts/commands.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ addCommandHandler("levels",
5959
if source ~= getElementsByType("console")[1] then return end
6060
local users = ircGetUsers()
6161
for i,user in ipairs (users) do
62-
users[i] = ircGetUserNick(user).." ("..(ircGetUserLevel(user) or "?")..")"
62+
users[i] = ircGetUserNick(user).." ("..(ircGetUserLevel(user,ircGetEchoChannel()) or "?")..")"
6363
end
6464
outputServerLog("IRC: users: "..table.concat(users,", "))
6565
end

resources/irc/scripts/core.lua

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -140,45 +140,6 @@ addEventHandler("onSockClosed",root,
140140
end
141141
)
142142

143-
local ignoreraws = {}
144-
ignoreraws["003"] = true
145-
ignoreraws["004"] = true
146-
ignoreraws["005"] = true
147-
ignoreraws["006"] = true
148-
ignoreraws["007"] = true
149-
ignoreraws["008"] = true
150-
151-
ignoreraws["211"] = true
152-
ignoreraws["212"] = true
153-
ignoreraws["213"] = true
154-
ignoreraws["214"] = true
155-
ignoreraws["215"] = true
156-
ignoreraws["216"] = true
157-
ignoreraws["217"] = true -- might be used for ping freq
158-
159-
addEvent("onIRCRaw")
160-
addEventHandler("onIRCRaw",root,
161-
function (data)
162-
local t = split(data,32)
163-
if t[1] == "PING" then
164-
resetTimer(servers[source][12])
165-
if t[2] then
166-
ircRaw(source,"PONG "..string.sub(t[2],2))
167-
else
168-
ircRaw(source,"PONG :REPLY")
169-
end
170-
elseif t[2] == "376" then
171-
triggerEvent("onIRCConnect",source)
172-
elseif t[2] == "001" then
173-
servers[source][2] = t[7]
174-
elseif t[2] == "002" then
175-
servers[source][3] = t[7]
176-
else
177-
outputServerLog("IRC: UKNOWN RAW: '"..data.."'")
178-
end
179-
end
180-
)
181-
182143
addEvent("onIRCConnect")
183144
addEventHandler("onIRCConnect",root,
184145
function ()

resources/irc/scripts/echo.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,22 +173,26 @@ local pollTitle
173173
addEvent("onPollStarting")
174174
addEventHandler("onPollStarting",root,
175175
function (data)
176-
pollTitle = tostring(data.title)
176+
if data.title then
177+
pollTitle = tostring(data.title)
178+
end
177179
end
178180
)
179181

180182
addEvent("onPollModified")
181183
addEventHandler("onPollModified",root,
182184
function (data)
183-
pollTitle = tostring(data.title)
185+
if data.title then
186+
pollTitle = tostring(data.title)
187+
end
184188
end
185189
)
186190

187191
addEvent("onPollStart")
188192
addEventHandler("onPollStart",root,
189193
function ()
190194
if pollTitle then
191-
outputIRC("14* A vote was started ["..pollTitle.."]")
195+
outputIRC("14* A vote was started ["..tostring(pollTitle).."]")
192196
end
193197
end
194198
)

resources/irc/scripts/functions.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ table ircGetChannelUsers userdata,
2929
string ircGetChannelTopic userdata,
3030
userdata ircGetChannelFromName string,
3131
bool ircIsEchoChannel userdata,
32+
bool ircGetEchoChannel,
3233
boolean ircSetUserMode userdata string,
3334
boolean ircIsUserBot userdata,
3435
string ircGetUserMode userdata,

resources/irc/scripts/handling.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ addEventHandler("onIRCRaw",root,
9090
end
9191
if t[2] == "NICK" then
9292
local oldnick = getNickFromRaw(data)
93-
local newnick = getMessageFromRaw(data)
93+
local newnick = string.sub(t[3],1,-2)
9494
local user = ircGetUserFromNick(oldnick)
9595
users[user][1] = newnick
9696
triggerEvent("onIRCUserChangeNick",user,oldnick,newnick)

resources/irc/scripts/irccommands.lua

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,6 @@ addIRCCommandHandler("!changemap",
518518
local map = table.concat({...}," ")
519519
if not map then ircNotice(user,"syntax is !changemap <name>") return end
520520
local maps = {}
521-
local resource = getResourceFromName(map)
522-
if resource then
523-
exports.mapmanager:changeGamemodeMap(resource)
524-
end
525521
for i,resource in ipairs (getResources()) do
526522
if getResourceInfo(resource,"type") == "map" then
527523
if string.find(string.lower(getResourceName(resource)),string.lower(map)) then

resources/irc/scripts/levels.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ function func_ircGetUserLevel (user,channel)
7575
if userlevels[channel] then
7676
return userlevels[channel][user]
7777
end
78-
return false
78+
return 0
7979
end
8080

8181
function isChanMode (mode)

resources/irc/scripts/loading.lua

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ addEventHandler("onResourceStart",resourceRoot,
7777
local args = {...}
7878
for i,arg in ipairs (args) do
7979
local expectedArgType = gettok(line,(2+i),32)
80-
if type(arg) ~= expectedArgType and not string.find(expectedArgType,")") then
80+
if type(arg) ~= expectedArgType and not (expectedArgType or string.find(expectedArgType,")")) then
8181
outputServerLog("IRC: Bad argument #"..i.." @ '"..gettok(line,2,32).."' "..expectedArgType.." expected, got "..type(arg))
8282
return
8383
end
@@ -159,11 +159,15 @@ function internalConnect ()
159159
outputServerLog("IRC: problem with server #"..i..", no channels given!")
160160
else
161161
local server = ircConnect(host,nick,port,password,secure)
162-
if nspass then
163-
ircIdentify(server,nspass)
164-
end
165-
for i,channel in ipairs (split(channels,44)) do
166-
ircJoin(server,gettok(channel,1,32),gettok(channel,2,32))
162+
if server then
163+
if nspass then
164+
ircIdentify(server,nspass)
165+
end
166+
for i,channel in ipairs (split(channels,44)) do
167+
ircJoin(server,gettok(channel,1,32),gettok(channel,2,32))
168+
end
169+
else
170+
outputServerLog("IRC: problem with server #"..i..", could not connect ("..tostring(getSocketErrorString(sockError)..")"))
167171
end
168172
end
169173
end

resources/irc/scripts/servers.lua

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ function func_ircJoin (server,channel,password)
8989
else
9090
ircRaw(server,"JOIN "..channel)
9191
end
92+
ircRaw(server,"NAMES "..channel)
9293
return chan
9394
else
9495
return false
@@ -160,14 +161,14 @@ end
160161

161162
function func_ircConnect (host,nick,port,password,secure)
162163
local server = createElement("irc-server")
163-
local socket = sockOpen(host,(port or 6667),secure)
164+
local socket,sockError = sockOpen(host,(port or 6667),secure)
164165
local timer = setTimer(connectingTimedOut,10000,1,server)
165166
if server and socket then
166167
servers[server] = {socket,host,host,nick,password,port,secure,false,false,false,getTickCount(),timer,0,{},false,{}}
167168
triggerEvent("onIRCConnecting",server)
168169
return server
169170
end
170-
return false
171+
return false,sockError
171172
end
172173

173174
function func_ircReconnect (server)

0 commit comments

Comments
 (0)