add email and report
parent
270420cbab
commit
3a3fbb38d3
|
@ -0,0 +1,22 @@
|
|||
# Email
|
||||
|
||||
Created by rubenwardy.
|
||||
|
||||
License: WTFPL.
|
||||
|
||||
## Usage
|
||||
|
||||
Send an email:
|
||||
|
||||
* /mail username message to send
|
||||
|
||||
View inbox:
|
||||
|
||||
* /inbox
|
||||
* /inbox text
|
||||
|
||||
No formspec commands (good for IRC):
|
||||
|
||||
* /mail username message to send
|
||||
* /inbox text
|
||||
* /inbox clear
|
|
@ -0,0 +1 @@
|
|||
chatplus?
|
|
@ -0,0 +1,44 @@
|
|||
local hudkit = dofile(minetest.get_modpath("email") .. "/hudkit.lua")
|
||||
email.hud = hudkit()
|
||||
function email.update_hud(player)
|
||||
local name = player:get_player_name()
|
||||
local inbox = email.get_inbox(name)
|
||||
|
||||
if inbox and #inbox > 0 then
|
||||
if email.hud:exists(player, "email:text") then
|
||||
email.hud:change(player, "email:text", "text", #inbox .. " /inbox")
|
||||
else
|
||||
email.hud:add(player, "email:icon", {
|
||||
hud_elem_type = "image",
|
||||
name = "MailIcon",
|
||||
position = {x=0.52, y=0.52},
|
||||
text="email_mail.png",
|
||||
scale = {x=1,y=1},
|
||||
alignment = {x=0.5, y=0.5},
|
||||
})
|
||||
|
||||
email.hud:add(player, "email:text", {
|
||||
hud_elem_type = "text",
|
||||
name = "MailText",
|
||||
position = {x=0.55, y=0.52},
|
||||
text= #inbox .. " /inbox",
|
||||
scale = {x=1,y=1},
|
||||
alignment = {x=0.5, y=0.5},
|
||||
})
|
||||
end
|
||||
else
|
||||
email.hud:remove(player, "email:icon")
|
||||
email.hud:remove(player, "email:text")
|
||||
end
|
||||
end
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
email.hud.players[player:get_player_name()] = nil
|
||||
end)
|
||||
function email.update_all_hud()
|
||||
local players = minetest.get_connected_players()
|
||||
for _, player in pairs(players) do
|
||||
email.update_hud(player)
|
||||
end
|
||||
minetest.after(5, email.update_all_hud)
|
||||
end
|
||||
minetest.after(5, email.update_all_hud)
|
|
@ -0,0 +1,48 @@
|
|||
-- HudKit, by rubenwardy
|
||||
-- License: Either WTFPL or CC0, you can choose.
|
||||
|
||||
local function hudkit()
|
||||
return {
|
||||
players = {},
|
||||
|
||||
add = function(self, player, id, def)
|
||||
local name = player:get_player_name()
|
||||
local elements = self.players[name]
|
||||
|
||||
if not elements then
|
||||
self.players[name] = {}
|
||||
elements = self.players[name]
|
||||
end
|
||||
|
||||
elements[id] = player:hud_add(def)
|
||||
end,
|
||||
|
||||
exists = function(self, player, id)
|
||||
local elements = self.players[player:get_player_name()]
|
||||
return elements and elements[id]
|
||||
end,
|
||||
|
||||
change = function(self, player, id, stat, value)
|
||||
local elements = self.players[player:get_player_name()]
|
||||
if not elements or not elements[id] then
|
||||
return false
|
||||
end
|
||||
|
||||
player:hud_change(elements[id], stat, value)
|
||||
return true
|
||||
end,
|
||||
|
||||
remove = function(self, player, id)
|
||||
local elements = self.players[player:get_player_name()]
|
||||
if not elements or not elements[id] then
|
||||
return false
|
||||
end
|
||||
|
||||
player:hud_remove(elements[id])
|
||||
elements[id] = nil
|
||||
return true
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
return hudkit
|
Binary file not shown.
After Width: | Height: | Size: 270 B |
|
@ -0,0 +1,12 @@
|
|||
# Report
|
||||
|
||||
Allows players to report things to admins and online moderators.
|
||||
|
||||
Suppose `player`, `griefer` and `moderator` are online players.
|
||||
`player` runs this command: `/report griefer is griefing`
|
||||
`moderator` sees: `-!- player reported: griefer is griefing`
|
||||
The Admin (named in "name") is mailed via chatplus: `<player1> Report: player2 is griefing (mods online: player3)`
|
||||
|
||||
License: WTFPL
|
||||
Depends: chatplus.
|
||||
|
|
@ -0,0 +1 @@
|
|||
email
|
|
@ -0,0 +1,38 @@
|
|||
minetest.register_chatcommand("report", {
|
||||
func = function(name, param)
|
||||
param = param:trim()
|
||||
if param == "" then
|
||||
return false, "Please add a message to your report. " ..
|
||||
"If it's about (a) particular player(s), please also include their name(s)."
|
||||
end
|
||||
local _, count = string.gsub(param, " ", "")
|
||||
if count == 0 then
|
||||
minetest.chat_send_player(name, "If you're reporting a player, " ..
|
||||
"you should also include a reason why. (Eg: swearing, sabotage)")
|
||||
end
|
||||
|
||||
-- Send to online moderators / admins
|
||||
-- Get comma separated list of online moderators and admins
|
||||
local mods = {}
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local toname = player:get_player_name()
|
||||
if minetest.check_player_privs(toname, {kick = true, ban = true}) then
|
||||
table.insert(mods, toname)
|
||||
minetest.chat_send_player(toname, "-!- " .. name .. " reported: " .. param)
|
||||
end
|
||||
end
|
||||
|
||||
if #mods > 0 then
|
||||
mod_list = table.concat(mods, ", ")
|
||||
email.send_mail(name, minetest.setting_get("name"),
|
||||
"Report: " .. param .. " (mods online: " .. mod_list .. ")")
|
||||
irc:say(name .. " sent a report! (mods online: " .. mod_list .. ")")
|
||||
return true, "Reported. Moderators currently online: " .. mod_list
|
||||
else
|
||||
email.send_mail(name, minetest.setting_get("name"),
|
||||
"Report: " .. param .. " (no mods online)")
|
||||
irc:say(name .. " sent a report! (no mods online)")
|
||||
return true, "Reported. We'll get back to you."
|
||||
end
|
||||
end
|
||||
})
|
Loading…
Reference in New Issue