@@ -15,7 +15,7 @@ local function nickequals(nick1, nick2)
15
15
return irclower (nick1 ) == irclower (nick2 )
16
16
end
17
17
18
- function irc : check_botcmd (msg )
18
+ function irc . check_botcmd (msg )
19
19
local prefix = irc .config .command_prefix
20
20
local nick = irc .conn .nick
21
21
local text = msg .args [2 ]
@@ -25,34 +25,34 @@ function irc:check_botcmd(msg)
25
25
-- First check for a nick prefix
26
26
if nickequals (nickpart , nick )
27
27
and (suffix == " : " or suffix == " , " ) then
28
- self : bot_command (msg , text :sub (# nick + 3 ))
28
+ irc . bot_command (msg , text :sub (# nick + 3 ))
29
29
return true
30
30
-- Then check for the configured prefix
31
31
elseif prefix and text :sub (1 , # prefix ):lower () == prefix :lower () then
32
- self : bot_command (msg , text :sub (# prefix + 1 ))
32
+ irc . bot_command (msg , text :sub (# prefix + 1 ))
33
33
return true
34
34
end
35
35
return false
36
36
end
37
37
38
38
39
- function irc : bot_command (msg , text )
39
+ function irc . bot_command (msg , text )
40
40
-- Remove leading whitespace
41
41
text = text :match (" ^%s*(.*)" )
42
42
if text :sub (1 , 1 ) == " @" then
43
43
local _ , _ , player_to , message = text :find (" ^.([^%s]+)%s(.+)$" )
44
44
if not player_to then
45
45
return
46
46
elseif not minetest .get_player_by_name (player_to ) then
47
- irc : reply (" User '" .. player_to .. " ' is not in the game." )
47
+ irc . reply (" User '" .. player_to .. " ' is not in the game." )
48
48
return
49
49
elseif not irc .joined_players [player_to ] then
50
- irc : reply (" User '" .. player_to .. " ' is not using IRC." )
50
+ irc . reply (" User '" .. player_to .. " ' is not using IRC." )
51
51
return
52
52
end
53
53
minetest .chat_send_player (player_to ,
54
54
" PM from " .. msg .user .nick .. " @IRC: " .. message , false )
55
- irc : reply (" Message sent!" )
55
+ irc . reply (" Message sent!" )
56
56
return
57
57
end
58
58
local pos = text :find (" " , 1 , true )
@@ -65,36 +65,36 @@ function irc:bot_command(msg, text)
65
65
args = " "
66
66
end
67
67
68
- if not self .bot_commands [cmd ] then
69
- self : reply (" Unknown command '" .. cmd .. " '. Try 'help'."
68
+ if not irc .bot_commands [cmd ] then
69
+ irc . reply (" Unknown command '" .. cmd .. " '. Try 'help'."
70
70
.. " Or use @playername <message> to send a private message" )
71
71
return
72
72
end
73
73
74
- local _ , message = self .bot_commands [cmd ].func (msg .user , args )
74
+ local _ , message = irc .bot_commands [cmd ].func (msg .user , args )
75
75
if message then
76
- self : reply (message )
76
+ irc . reply (message )
77
77
end
78
78
end
79
79
80
80
81
- function irc : register_bot_command (name , def )
81
+ function irc . register_bot_command (name , def )
82
82
if (not def .func ) or (type (def .func ) ~= " function" ) then
83
83
error (" Erroneous bot command definition. def.func missing." , 2 )
84
84
elseif name :sub (1 , 1 ) == " @" then
85
85
error (" Erroneous bot command name. Command name begins with '@'." , 2 )
86
86
end
87
- self .bot_commands [name ] = def
87
+ irc .bot_commands [name ] = def
88
88
end
89
89
90
90
91
- irc : register_bot_command (" help" , {
91
+ irc . register_bot_command (" help" , {
92
92
params = " <command>" ,
93
93
description = " Get help about a command" ,
94
- func = function (user , args )
94
+ func = function (_ , args )
95
95
if args == " " then
96
96
local cmdlist = { }
97
- for name , cmd in pairs (irc .bot_commands ) do
97
+ for name in pairs (irc .bot_commands ) do
98
98
cmdlist [# cmdlist + 1 ] = name
99
99
end
100
100
return true , " Available commands: " .. table.concat (cmdlist , " , " )
@@ -116,20 +116,20 @@ irc:register_bot_command("help", {
116
116
})
117
117
118
118
119
- irc : register_bot_command (" list" , {
119
+ irc . register_bot_command (" list" , {
120
120
params = " " ,
121
121
description = " List available commands." ,
122
- func = function (user , args )
122
+ func = function ()
123
123
return false , " The `list` command has been merged into `help`."
124
124
.. " Use `help` with no arguments to get a list."
125
125
end
126
126
})
127
127
128
128
129
- irc : register_bot_command (" whereis" , {
129
+ irc . register_bot_command (" whereis" , {
130
130
params = " <player>" ,
131
131
description = " Tell the location of <player>" ,
132
- func = function (user , args )
132
+ func = function (_ , args )
133
133
if args == " " then
134
134
return false , " Player name required."
135
135
end
@@ -145,9 +145,9 @@ irc:register_bot_command("whereis", {
145
145
146
146
147
147
local starttime = os.time ()
148
- irc : register_bot_command (" uptime" , {
148
+ irc . register_bot_command (" uptime" , {
149
149
description = " Tell how much time the server has been up" ,
150
- func = function (user , args )
150
+ func = function ()
151
151
local cur_time = os.time ()
152
152
local diff = os.difftime (cur_time , starttime )
153
153
local fmt = " Server has been running for %d:%02d:%02d"
@@ -160,9 +160,9 @@ irc:register_bot_command("uptime", {
160
160
})
161
161
162
162
163
- irc : register_bot_command (" players" , {
163
+ irc . register_bot_command (" players" , {
164
164
description = " List the players on the server" ,
165
- func = function (user , args )
165
+ func = function ()
166
166
local players = minetest .get_connected_players ()
167
167
local names = {}
168
168
for _ , player in pairs (players ) do
0 commit comments