Skip to content

Commit ca6ec43

Browse files
committed
Optional nickservname parameter
1 parent c4c10b4 commit ca6ec43

File tree

4 files changed

+19
-6
lines changed

4 files changed

+19
-6
lines changed

resources/irc/scripts/handling.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ addEventHandler("onIRCRaw",root,
7272
end
7373
servers[source].outputbuffer = {}
7474
end
75+
ircIdentify(source,servers[source].nickservpass,servers[source].nickservname)
7576
end
7677
if t[2] == "002" then
7778
servers[source].host = string.sub(t[7],1,-2)

resources/irc/scripts/loading.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ function internalConnect ()
149149
local port = tonumber(xmlNodeGetAttribute(server,"port")) or 6667
150150
local password = xmlNodeGetAttribute(server,"password") or false
151151
local secure = xmlNodeGetAttribute(server,"secure") == "true" or false
152+
local nsname = xmlNodeGetAttribute(server,"nickservname") or xmlNodeGetAttribute(server,"nickservername") or false
152153
local nspass = xmlNodeGetAttribute(server,"nickservpass") or xmlNodeGetAttribute(server,"nickserverpass") or false
153154
if not host then
154155
outputDebugString("problem with irc server #"..i..", no host given!")
@@ -160,7 +161,7 @@ function internalConnect ()
160161
local server = ircConnect(host,nick,port,password,secure)
161162
if server then
162163
if nspass then
163-
ircIdentify(server,nspass)
164+
ircIdentify(server,nspass,nsname)
164165
end
165166
for i,channel in ipairs (split(channels,44)) do
166167
ircJoin(server,gettok(channel,1,32),gettok(channel,2,32))

resources/irc/scripts/servers.lua

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
---------------------------------------------------------------------
88

99
-- everything is saved here
10-
servers = {} -- syntax: [server] = {socket=element, name=string, host=string, nick=string, password=string, port=number,secure=bool,nickservpass=string, lastping=number, connected=bool, outputbuffer=table, inputbuffer=string}
10+
servers = {} -- syntax: [server] = {socket=element, name=string, host=string, nick=string, password=string, port=number,secure=bool, lastping=number, connected=bool, outputbuffer=table, inputbuffer=string, nickservname=string, nickservpass=string}
1111

1212
------------------------------------
1313
-- Servers
@@ -147,10 +147,20 @@ function func_outputIRC (message)
147147
end
148148
registerFunction("outputIRC","func_outputIRC","string")
149149

150-
function func_ircIdentify (server,password)
151-
return ircRaw(server,"PRIVMSG NickServ :IDENTIFY "..password)
150+
function func_ircIdentify (server,password,name)
151+
servers[server]["nickservname"] = name
152+
servers[server]["nickservpass"] = password
153+
if servers[server].connected then
154+
if name then
155+
return ircRaw(server,"PRIVMSG NickServ :IDENTIFY "..name.." "..password)
156+
else
157+
return ircRaw(server,"PRIVMSG NickServ :IDENTIFY "..password)
158+
end
159+
else
160+
return true
161+
end
152162
end
153-
registerFunction("ircIdentify","func_ircIdentify","irc-server","string")
163+
registerFunction("ircIdentify","func_ircIdentify","irc-server","string","(string)")
154164

155165
function func_ircConnect (host,nick,port,password,secure)
156166
local server = createElement("irc-server")
@@ -179,7 +189,6 @@ function func_ircReconnect (server,reason)
179189
sockClose(servers[server].socket)
180190
triggerEvent("onIRCConnecting",server)
181191
servers[server].connected = false
182-
servers[server].connected = false
183192
servers[server].socket = sockOpen(ircGetServerHost(server),ircGetServerPort(server),ircIsServerSecure(server))
184193
for i,channel in ipairs (ircGetServerChannels(server)) do
185194
ircRaw(server,"JOIN "..tostring(ircGetChannelName(channel)))

resources/irc/settings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
password="server password" (optional)
99
secure="false" (optional default: false)
1010
11+
nickservname="name" if your nick is registered on the nickserver put it here (optional)
1112
nickservpass="password" if your nick is registered on the nickserver put it here (optional)
1213
/>
1314
add as many servers as you want
1415
-->
1516

1617
<server
1718
host="irc.gtanet.com"
19+
port="6667"
1820
nick="SocketsBot"
1921
channels="#MCvarial"
2022
/>

0 commit comments

Comments
 (0)