mirror of
https://github.com/minetest-mods/irc_commands.git
synced 2025-01-09 15:20:19 +01:00
Log logins, logouts, and commands
This commit is contained in:
parent
8980b78908
commit
a14d46155a
8
init.lua
8
init.lua
@ -21,12 +21,15 @@ mt_irc.register_bot_command("login", {
|
|||||||
local found, _, username, password = args:find("^([^%s]+)%s([^%s]+)$")
|
local found, _, username, password = args:find("^([^%s]+)%s([^%s]+)$")
|
||||||
if not found then
|
if not found then
|
||||||
username = args
|
username = args
|
||||||
|
password = ""
|
||||||
end
|
end
|
||||||
if minetest.auth_table[username] and
|
if minetest.auth_table[username] and
|
||||||
minetest.auth_table[username].password == minetest.get_password_hash(username, (password or "")) then
|
minetest.auth_table[username].password == minetest.get_password_hash(username, password) then
|
||||||
|
minetest.debug("User "..from.." from IRC logs in as "..username)
|
||||||
irc_users[from] = username
|
irc_users[from] = username
|
||||||
mt_irc.say(from, "You are now logged in as "..username)
|
mt_irc.say(from, "You are now logged in as "..username)
|
||||||
else
|
else
|
||||||
|
minetest.debug("User "..from.." from IRC attempted log in as "..username.." unsuccessfully")
|
||||||
mt_irc.say(from, "Incorrect password or player does not exist")
|
mt_irc.say(from, "Incorrect password or player does not exist")
|
||||||
end
|
end
|
||||||
end})
|
end})
|
||||||
@ -35,6 +38,7 @@ mt_irc.register_bot_command("logout", {
|
|||||||
description = "Logout",
|
description = "Logout",
|
||||||
func = function (from, args)
|
func = function (from, args)
|
||||||
if irc_users[from] then
|
if irc_users[from] then
|
||||||
|
minetest.debug("User "..from.." from IRC logs out of "..irc_users[from])
|
||||||
irc_users[from] = nil
|
irc_users[from] = nil
|
||||||
mt_irc.say(from, "You are now logged off")
|
mt_irc.say(from, "You are now logged off")
|
||||||
else
|
else
|
||||||
@ -64,6 +68,7 @@ mt_irc.register_bot_command("cmd", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.check_player_privs(irc_users[from], command.privs) then
|
if minetest.check_player_privs(irc_users[from], command.privs) then
|
||||||
|
minetest.debug("User "..from.." from IRC runs "..args.." as "..irc_users[from])
|
||||||
command.func(irc_users[from], (params or ""))
|
command.func(irc_users[from], (params or ""))
|
||||||
mt_irc.say(from, "Command run successfuly")
|
mt_irc.say(from, "Command run successfuly")
|
||||||
end
|
end
|
||||||
@ -82,6 +87,7 @@ mt_irc.register_bot_command("say", {
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
if minetest.check_player_privs(irc_users[from], {shout=true}) then
|
if minetest.check_player_privs(irc_users[from], {shout=true}) then
|
||||||
|
minetest.debug("User "..from.." from IRC says "..args.." as "..irc_users[from])
|
||||||
minetest.chat_send_all("<"..irc_users[from].."@IRC> "..args)
|
minetest.chat_send_all("<"..irc_users[from].."@IRC> "..args)
|
||||||
mt_irc.say(from, "Message sent successfuly")
|
mt_irc.say(from, "Message sent successfuly")
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user