1
0
mirror of https://github.com/minetest-mods/irc.git synced 2025-06-29 14:40:36 +02:00

Major cleanup.

- Use `irc.foo` notation instead of `irc:foo`. It still
  supports the `irc:foo` usage, but will helpfully issue
  a warning with the location of the offending code.
- Remove unused arguments from functions.
This commit is contained in:
Diego Martínez
2017-03-15 21:33:47 -03:00
parent 5f8850bc15
commit 6bf4e111c2
9 changed files with 180 additions and 149 deletions

View File

@ -2,19 +2,19 @@
-- See LICENSE.txt for details.
function irc:player_part(name)
if not self.joined_players[name] then
function irc.player_part(name)
if not irc.joined_players[name] then
return false, "You are not in the channel"
end
self.joined_players[name] = nil
irc.joined_players[name] = nil
return true, "You left the channel"
end
function irc:player_join(name)
if self.joined_players[name] then
function irc.player_join(name)
if irc.joined_players[name] then
return false, "You are already in the channel"
end
self.joined_players[name] = true
irc.joined_players[name] = true
return true, "You joined the channel"
end
@ -22,23 +22,23 @@ end
minetest.register_chatcommand("join", {
description = "Join the IRC channel",
privs = {shout=true},
func = function(name, param)
return irc:player_join(name)
func = function(name)
return irc.player_join(name)
end
})
minetest.register_chatcommand("part", {
description = "Part the IRC channel",
privs = {shout=true},
func = function(name, param)
return irc:player_part(name)
func = function(name)
return irc.player_part(name)
end
})
minetest.register_chatcommand("who", {
description = "Tell who is currently on the channel",
privs = {},
func = function(name, param)
func = function()
local out, n = { }, 0
for plname in pairs(irc.joined_players) do
n = n + 1
@ -61,9 +61,9 @@ minetest.register_on_leaveplayer(function(player)
irc.joined_players[name] = nil
end)
function irc:sendLocal(message)
for name, _ in pairs(self.joined_players) do
function irc.sendLocal(message)
for name, _ in pairs(irc.joined_players) do
minetest.chat_send_player(name, message)
end
irc:logChat(message)
irc.logChat(message)
end