Skip to content

Commit 1c14957

Browse files
committed
added help file, updated exports, fixed socket errors
1 parent 155f0c3 commit 1c14957

File tree

7 files changed

+50
-37
lines changed

7 files changed

+50
-37
lines changed

resources/irc/help.htm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<html>
2+
<head>
3+
<meta HTTP-EQUIV="REFRESH" content="0; url=http://wiki.multitheftauto.com/wiki/Resource:Irc">
4+
</head>
5+
</html>

resources/irc/meta.xml

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -58,55 +58,50 @@
5858
<!-- Don't touch anything below! -->
5959
<info author="MCvarial" version="1.0.2" type="misc" name="irc" description="Echobot to be used on irc" />
6060

61+
<export function="ircGetChannelFromName" type="server" http="false" />
62+
<export function="ircGetEchoChannels" type="server" http="false" />
63+
<export function="ircGetChannelServer" type="server" http="false" />
64+
<export function="ircGetChannels" type="server" http="false" />
65+
<export function="ircSetChannelMode" type="server" http="false" />
66+
<export function="ircGetChannelName" type="server" http="false" />
67+
<export function="ircGetChannelMode" type="server" http="false" />
68+
<export function="ircGetChannelUsers" type="server" http="false" />
69+
<export function="ircGetChannelTopic" type="server" http="false" />
70+
<export function="ircIsEchoChannel" type="server" http="false" />
71+
<export function="ircRaw" type="server" http="false" />
6172
<export function="ircHop" type="server" http="false" />
6273
<export function="ircSay" type="server" http="false" />
63-
<export function="ircRaw" type="server" http="false" />
6474
<export function="ircPart" type="server" http="false" />
6575
<export function="ircJoin" type="server" http="false" />
6676
<export function="ircAction" type="server" http="false" />
6777
<export function="ircNotice" type="server" http="false" />
6878
<export function="outputIRC" type="server" http="false" />
69-
<export function="ircConnect" type="server" http="false" />
7079
<export function="ircIdentify" type="server" http="false" />
80+
<export function="ircConnect" type="server" http="false" />
7181
<export function="ircReconnect" type="server" http="false" />
7282
<export function="ircDisconnect" type="server" http="false" />
7383
<export function="ircChangeNick" type="server" http="false" />
74-
75-
<export function="ircGetServers" type="server" http="false" />
7684
<export function="ircGetServerName" type="server" http="false" />
7785
<export function="ircGetServerHost" type="server" http="false" />
7886
<export function="ircGetServerPort" type="server" http="false" />
7987
<export function="ircGetServerPass" type="server" http="false" />
8088
<export function="ircGetServerNick" type="server" http="false" />
8189
<export function="ircIsServerSecure" type="server" http="false" />
8290
<export function="ircGetServerChannels" type="server" http="false" />
83-
84-
<export function="ircGetChannelServer" type="server" http="false" />
85-
<export function="ircSetChannels" type="server" http="false" />
86-
<export function="ircSetChannelMode" type="server" http="false" />
87-
<export function="ircGetChannelName" type="server" http="false" />
88-
<export function="ircGetChannelMode" type="server" http="false" />
89-
<export function="ircGetChannelUsers" type="server" http="false" />
90-
<export function="ircGetChannelTopic" type="server" http="false" />
91-
<export function="ircGetChannelFromName" type="server" http="false" />
92-
<export function="ircIsEchoChannel" type="server" http="false" />
93-
9491
<export function="ircSetUserMode" type="server" http="false" />
9592
<export function="ircGetUserMode" type="server" http="false" />
9693
<export function="ircGetUserNick" type="server" http="false" />
97-
<export function="ircGetUsers" type="server" http="false" />
9894
<export function="ircGetUserServer" type="server" http="false" />
99-
<export function="ircGetUserLevel" type="server" http="false" />
95+
<export function="ircGetUsers" type="server" http="false" />
96+
<export function="ircGetUserFromNick" type="server" http="false" />
10097
<export function="ircGetUserVhost" type="server" http="false" />
101-
<export function="ircGetUserFromName" type="server" http="false" />
102-
98+
<export function="ircGetUserLevel" type="server" http="false" />
10399
<export function="addIRCCommandHandler" type="server" http="false" />
104100
<export function="ircGetCommands" type="server" http="false" />
105101
<export function="ircGetCommandLevel" type="server" http="false" />
106102
<export function="ircIsCommandEchoChannelOnly" type="server" http="false" />
107103

108104
<!-- Don't touch this, you might break it. -->
109-
<script src="scripts/socketerrors.lua" type="server" />
110105
<script src="scripts/loading.lua" type="server" />
111106
<script src="scripts/utility.lua" type="server" />
112107
<script src="scripts/channels.lua" type="server" />

resources/irc/scripts/acl.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,14 @@ function func_addIRCCommandHandler (cmd,fn,level,echoChannelOnly)
2020
end
2121
registerFunction("addIRCCommandHandler","func_addIRCCommandHandler","string","function/string","(number)","(boolean)")
2222

23-
function ircGetCommands ()
23+
function func_ircGetCommands ()
2424
local cmds = {}
2525
for cmd,_ in pairs (commands) do
2626
table.insert(cmds,cmd)
2727
end
2828
return cmds
2929
end
30+
registerFunction("ircGetCommands","func_ircGetCommands")
3031

3132
function func_ircGetCommandLevel (cmd)
3233
if commands[cmd] then

resources/irc/scripts/channels.lua

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function func_ircGetChannelFromName (channel)
2222
end
2323
registerFunction("ircGetChannelFromName","func_ircGetChannelFromName","string")
2424

25-
function ircGetEchoChannels ()
25+
function func_ircGetEchoChannels ()
2626
local channels = {}
2727
for i,channel in ipairs (ircGetChannels()) do
2828
if ircIsEchoChannel(channel) then
@@ -31,13 +31,14 @@ function ircGetEchoChannels ()
3131
end
3232
return channels
3333
end
34+
registerFunction("ircGetEchoChannels","func_ircGetEchoChannels")
3435

3536
function func_ircGetChannelServer (channel)
3637
return getElementParent(channel)
3738
end
3839
registerFunction("ircGetChannelServer","func_ircGetChannelServer","irc-channel")
3940

40-
function ircGetChannels (server)
41+
function func_ircGetChannels (server)
4142
if servers[server] then
4243
local channels = {}
4344
for i,channels in ipairs (ircGetChannels()) do
@@ -49,6 +50,7 @@ function ircGetChannels (server)
4950
end
5051
return getElementsByType("irc-channel")
5152
end
53+
registerFunction("ircGetChannels","func_ircGetChannels","(irc-server)")
5254

5355
function func_ircSetChannelMode (channel,mode)
5456
return ircRaw(getElementParent(channel),"MODE "..channels[channel][1].." :"..mode)

resources/irc/scripts/servers.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ function func_ircHop (channel,reason)
3232
end
3333
registerFunction("ircHop","func_ircHop","irc-channel","(string)")
3434

35-
function ircSay (target,message)
36-
if type(message) ~= "string" then return false end
35+
function func_ircSay (target,message)
3736
if #message > 400 then
3837
for i=1,math.ceil(#message/400) do
3938
ircSay(target,string.sub(message,(i-1)*400,i*400))
@@ -53,6 +52,7 @@ function ircSay (target,message)
5352
end
5453
return false
5554
end
55+
registerFunction("ircSay","func_ircSay","irc-channel/irc-user","string")
5656

5757
function func_ircPart (channel,reason)
5858
local channelName = ircGetChannelName(channel)
@@ -102,8 +102,7 @@ function func_ircAction (channel,message)
102102
end
103103
registerFunction("ircAction","func_ircAction","irc-channel","string")
104104

105-
function ircNotice (target,message)
106-
if type(message) ~= "string" then return false end
105+
function func_ircNotice (target,message)
107106
if #message > 400 then
108107
for i=1,math.ceil(#message/400) do
109108
ircNotice(target,string.sub(message,(i-1)*400,i*400))
@@ -119,6 +118,7 @@ function ircNotice (target,message)
119118
end
120119
return false
121120
end
121+
registerFunction("ircNotice","func_ircNotice","irc-channel/irc-user","string")
122122

123123
function func_outputIRC (message)
124124
if #message > 400 then

resources/irc/scripts/socketerrors.lua

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,13 @@
1-
---------------------------------------------------------------------
1+
---------------------------------------------------------------------
22
-- Project: irc
33
-- Author: MCvarial
44
-- Contact: [email protected]
55
-- Version: 1.0.2
66
-- Date: 31.10.2010
77
---------------------------------------------------------------------
88

9-
function getSocketErrorString (i)
10-
if type(i) == "number" and sockets[i] then
11-
return sockets[i]
12-
else
13-
return "Unknown error"
14-
end
15-
end
16-
179
-- linux error codes
18-
local socketErrors = {}
10+
socketErrors = {}
1911
socketErrors[001] = "Operation not permitted"
2012
socketErrors[002] = "No such file or directory"
2113
socketErrors[003] = "No such process"

resources/irc/scripts/utility.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,22 @@ end
115115
function getNumberFromVersion (version)
116116
local p1,p2,p3 = unpack(split(version,46))
117117
return tonumber((100*tonumber(p1))+(10*tonumber(p2))+(tonumber(p3)))
118+
end
119+
120+
function getSocketErrorString (i)
121+
local error
122+
if type(i) == "number" then
123+
local file = fileOpen("scripts/socketerrors.lua")
124+
if file then
125+
local content = fileRead(file,fileGetSize(file))
126+
if content then
127+
loadstring(content)()
128+
if socketErrors[i] then
129+
error = socketErrors[i]
130+
end
131+
end
132+
fileClose(file)
133+
end
134+
end
135+
return error or "Unknown error"
118136
end

0 commit comments

Comments
 (0)