Update chatplus, email and report
This commit is contained in:
parent
2b18dc58ea
commit
c812241314
18 changed files with 604 additions and 223 deletions
22
mods/chatplus/.gitattributes
vendored
Normal file
22
mods/chatplus/.gitattributes
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Custom for Visual Studio
|
||||
*.cs diff=csharp
|
||||
*.sln merge=union
|
||||
*.csproj merge=union
|
||||
*.vbproj merge=union
|
||||
*.fsproj merge=union
|
||||
*.dbproj merge=union
|
||||
|
||||
# Standard to msysgit
|
||||
*.doc diff=astextplain
|
||||
*.DOC diff=astextplain
|
||||
*.docx diff=astextplain
|
||||
*.DOCX diff=astextplain
|
||||
*.dot diff=astextplain
|
||||
*.DOT diff=astextplain
|
||||
*.pdf diff=astextplain
|
||||
*.PDF diff=astextplain
|
||||
*.rtf diff=astextplain
|
||||
*.RTF diff=astextplain
|
215
mods/chatplus/.gitignore
vendored
Normal file
215
mods/chatplus/.gitignore
vendored
Normal file
|
@ -0,0 +1,215 @@
|
|||
#################
|
||||
## Eclipse
|
||||
#################
|
||||
|
||||
*.pydevproject
|
||||
.project
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.classpath
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
|
||||
#################
|
||||
## Visual Studio
|
||||
#################
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.sln.docstates
|
||||
|
||||
# Build results
|
||||
|
||||
[Dd]ebug/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
build/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.log
|
||||
*.scc
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
*.ncrunch*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.Publish.xml
|
||||
*.pubxml
|
||||
|
||||
# NuGet Packages Directory
|
||||
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
||||
#packages/
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Others
|
||||
sql/
|
||||
*.Cache
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.[Pp]ublish.xml
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file to a newer
|
||||
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
App_Data/*.mdf
|
||||
App_Data/*.ldf
|
||||
|
||||
#############
|
||||
## Windows detritus
|
||||
#############
|
||||
|
||||
# Windows image file caches
|
||||
Thumbs.db
|
||||
ehthumbs.db
|
||||
|
||||
# Folder config file
|
||||
Desktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Mac crap
|
||||
.DS_Store
|
||||
|
||||
|
||||
#############
|
||||
## Python
|
||||
#############
|
||||
|
||||
*.py[co]
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
dist/
|
||||
build/
|
||||
eggs/
|
||||
parts/
|
||||
var/
|
||||
sdist/
|
||||
develop-eggs/
|
||||
.installed.cfg
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
.coverage
|
||||
.tox
|
||||
|
||||
#Translations
|
||||
*.mo
|
||||
|
||||
#Mr Developer
|
||||
.mr.developer.cfg
|
|
@ -1,7 +1,8 @@
|
|||
# Chatplus
|
||||
|
||||
Adds ignoring and email style inboxes. Also provides a powerful API,
|
||||
and optionally allows distance limiting.
|
||||
**NOTE: Chatplus has split into two mods, chatplus and [email](https://github.com/rubenwardy/email)**
|
||||
|
||||
Adds ignoring, distance limiting (optional) and a swear filter (optional). Also provides a powerful API.
|
||||
|
||||
License: GPL 3.0 or later.
|
||||
|
||||
|
@ -11,12 +12,6 @@ Created by rubenwardy.
|
|||
|
||||
* /ignore [name] - ignore a player
|
||||
* /unignore [name] - unignore a player
|
||||
* /mail [name] [msg] - message a player (online or offline!)
|
||||
* /inbox - open your inbox
|
||||
* /inbox clear - clear your inbox
|
||||
* /inbox text - see the text version of the inbox.
|
||||
* /inbox txt - alias of /inbox text
|
||||
* /inbox t - alias of /inbox text
|
||||
|
||||
## HUD
|
||||
|
||||
|
|
|
@ -70,19 +70,24 @@ function chatplus.load()
|
|||
if from_file.players and from_file.version >= 2 then
|
||||
chatplus.players = from_file.players
|
||||
else
|
||||
chatplus.old_inbox = {}
|
||||
chatplus.players = {}
|
||||
for name, data in pairs(from_file) do
|
||||
chatplus.players[name] = data
|
||||
local inbox = data.inbox
|
||||
data.inbox = {}
|
||||
data.inbox = nil
|
||||
chatplus.players[name] = data
|
||||
chatplus.old_inbox[name] = {}
|
||||
for _, msg in pairs(inbox) do
|
||||
table.insert(data.inbox, {
|
||||
table.insert(chatplus.old_inbox[name], {
|
||||
date = "?",
|
||||
from = "?",
|
||||
msg = msg
|
||||
})
|
||||
end
|
||||
end
|
||||
if chatplus.on_old_inbox then
|
||||
chatplus.on_old_inbox(chatplus.old_inbox)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
@ -211,7 +216,7 @@ end
|
|||
-- Minetest callbacks
|
||||
minetest.register_on_chat_message(function(...)
|
||||
local ret = chatplus.send(...)
|
||||
if ret and minetest.global_exists("irc") then
|
||||
if ret and minetest.global_exists("irc") and irc.on_chatmessage then
|
||||
irc.on_chatmessage(...)
|
||||
end
|
||||
return ret
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
Adds ignoring and email style inboxes. Also provides a powerful API,
|
||||
and optionally allows distance limiting.
|
||||
Adds chat functions such as ignoring, distance limiting, and swear filtering.
|
||||
Also provides a powerful API, and optionally allows distance limiting.
|
||||
|
|
|
@ -6,9 +6,6 @@
|
|||
---------------------
|
||||
|
||||
dofile(minetest.get_modpath("chatplus") .. "/api.lua")
|
||||
dofile(minetest.get_modpath("chatplus") .. "/mail.lua")
|
||||
|
||||
|
||||
|
||||
--
|
||||
-- Ignoring
|
||||
|
|
|
@ -1,195 +0,0 @@
|
|||
-- Chat Plus
|
||||
-- by rubenwardy
|
||||
---------------------
|
||||
-- mail.lua
|
||||
-- Adds C+'s email.
|
||||
---------------------
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local _player = chatplus.poke(player:get_player_name(),player)
|
||||
-- inbox stuff!
|
||||
if _player.inbox and #_player.inbox>0 then
|
||||
minetest.after(10, minetest.chat_send_player,
|
||||
player:get_player_name(),
|
||||
"(" .. #_player.inbox .. ") You have mail! Type /inbox to recieve")
|
||||
end
|
||||
end)
|
||||
|
||||
-- inbox
|
||||
function chatplus.showInbox(name, text_mode)
|
||||
-- Get player info
|
||||
local player = chatplus.players[name]
|
||||
|
||||
-- Show
|
||||
if text_mode then
|
||||
if not player or not player.inbox or #player.inbox == 0 then
|
||||
return true, "Your inbox is empty!"
|
||||
else
|
||||
minetest.chat_send_player(name, #player.inbox .. " items in your inbox:")
|
||||
for i = 1, #player.inbox do
|
||||
local item = player.inbox[i]
|
||||
minetest.chat_send_player(name, i .. ") " ..item.date ..
|
||||
" <" .. item.from .. "> " .. item.msg)
|
||||
end
|
||||
return true, "End of mail (" .. #player.inbox .. " item)"
|
||||
end
|
||||
else
|
||||
local fs = "size[12,8]"
|
||||
fs = fs .. "vertlabel[0,0;Chatplus Mail]"
|
||||
|
||||
fs = fs .. "tablecolumns[color;text;color;text;text]"
|
||||
fs = fs .. "tableoptions[highlight=#ffffff33]"
|
||||
fs = fs .. "table[0.5,0;11.25,7;inbox;"
|
||||
fs = fs .. "#ffffff,Date,,From,Message"
|
||||
if not player or not player.inbox or #player.inbox == 0 then
|
||||
fs = fs .. ",#d0d0d0,,#d0d0d0," ..
|
||||
minetest.formspec_escape(":)") ..
|
||||
"," ..
|
||||
minetest.formspec_escape("Well done! Your inbox is empty!")
|
||||
else
|
||||
for i = 1, #player.inbox do
|
||||
fs = fs .. ",#D0D0D0,"
|
||||
fs = fs .. minetest.formspec_escape(player.inbox[i].date) .. ","
|
||||
if minetest.check_player_privs(player.inbox[i].from, {kick = true, ban = true}) then
|
||||
fs = fs .. "#FFD700,"
|
||||
else
|
||||
fs = fs .. "#ffffff,"
|
||||
end
|
||||
fs = fs .. minetest.formspec_escape(player.inbox[i].from) .. ","
|
||||
fs = fs .. minetest.formspec_escape(player.inbox[i].msg)
|
||||
end
|
||||
end
|
||||
fs = fs .. "]"
|
||||
|
||||
fs = fs .. "button[0,7.25;2,1;clear;Delete All]"
|
||||
--fs = fs .. "button[0,7.25;2,1;clear;Mark as read]"
|
||||
fs = fs .. "button_exit[10.1,7.25;2,1;close;Close]"
|
||||
fs = fs .. "label[2,7.4;Exit then type /mail username message to reply]"
|
||||
|
||||
minetest.show_formspec(name, "chatplus:inbox", fs)
|
||||
|
||||
return true, "Opened inbox!"
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player,formname,fields)
|
||||
if fields.clear then
|
||||
local name = player:get_player_name()
|
||||
chatplus.poke(name).inbox = {}
|
||||
chatplus.save()
|
||||
minetest.chat_send_player(name, "Inbox cleared!")
|
||||
chatplus.showInbox(name)
|
||||
end
|
||||
|
||||
--[[if fields.mark_all_read then
|
||||
if player and player.inbox and #player.inbox > 0 then
|
||||
for i = 1, #player.inbox do
|
||||
player.inbox[i].read = true
|
||||
end
|
||||
chatplus.save()
|
||||
minetest.chat_send_player(name, "Marked all as read!")
|
||||
chatplus.showInbox(name)
|
||||
end
|
||||
end]]--
|
||||
end)
|
||||
|
||||
minetest.register_chatcommand("inbox", {
|
||||
params = "clear?",
|
||||
description = "inbox: print the items in your inbox",
|
||||
func = function(name, param)
|
||||
if param == "clear" then
|
||||
local player = chatplus.poke(name)
|
||||
player.inbox = {}
|
||||
chatplus.save()
|
||||
|
||||
return true, "Inbox cleared"
|
||||
elseif param == "text" or param == "txt" or param == "t" then
|
||||
return chatplus.showInbox(name, true)
|
||||
else
|
||||
return chatplus.showInbox(name, false)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
function chatplus.send_mail(name, to, msg)
|
||||
minetest.log("ChatplusMail - To: "..to..", From: "..name..", MSG: "..msg)
|
||||
chatplus.log("ChatplusMail - To: "..to..", From: "..name..", MSG: "..msg)
|
||||
if chatplus.players[to] then
|
||||
table.insert(chatplus.players[to].inbox, {
|
||||
date = os.date("%Y-%m-%d %H:%M:%S"),
|
||||
from = name,
|
||||
msg = msg})
|
||||
chatplus.save()
|
||||
|
||||
minetest.chat_send_player(to, name .. " sent you mail! Type /inbox to see it.")
|
||||
|
||||
return true, "Message sent to " .. to
|
||||
else
|
||||
return false, "Player '" .. to .. "' does not exist"
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("mail", {
|
||||
params = "name msg",
|
||||
description = "mail: add a message to a player's inbox",
|
||||
func = function(name, param)
|
||||
chatplus.poke(name)
|
||||
local to, msg = string.match(param, "^([%a%d_-]+) (.+)")
|
||||
|
||||
if not to or not msg then
|
||||
minetest.chat_send_player(name,"mail: <playername> <msg>",false)
|
||||
return
|
||||
end
|
||||
|
||||
return chatplus.send_mail(name, to, msg)
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_globalstep(function(dtime)
|
||||
chatplus.count = chatplus.count + dtime
|
||||
if chatplus.count > 5 then
|
||||
chatplus.count = 0
|
||||
-- loop through player list
|
||||
for key,value in pairs(chatplus.players) do
|
||||
if (
|
||||
chatplus.loggedin and
|
||||
chatplus.loggedin[key] and
|
||||
chatplus.loggedin[key].player and
|
||||
value and
|
||||
value.inbox and
|
||||
chatplus.loggedin[key].player.hud_add and
|
||||
chatplus.loggedin[key].lastcount ~= #value.inbox
|
||||
) then
|
||||
if chatplus.loggedin[key].msgicon then
|
||||
chatplus.loggedin[key].player:hud_remove(chatplus.loggedin[key].msgicon)
|
||||
end
|
||||
|
||||
if chatplus.loggedin[key].msgicon2 then
|
||||
chatplus.loggedin[key].player:hud_remove(chatplus.loggedin[key].msgicon2)
|
||||
end
|
||||
|
||||
if #value.inbox>0 then
|
||||
chatplus.loggedin[key].msgicon = chatplus.loggedin[key].player:hud_add({
|
||||
hud_elem_type = "image",
|
||||
name = "MailIcon",
|
||||
position = {x=0.52, y=0.52},
|
||||
text="chatplus_mail.png",
|
||||
scale = {x=1,y=1},
|
||||
alignment = {x=0.5, y=0.5},
|
||||
})
|
||||
chatplus.loggedin[key].msgicon2 = chatplus.loggedin[key].player:hud_add({
|
||||
hud_elem_type = "text",
|
||||
name = "MailText",
|
||||
position = {x=0.55, y=0.52},
|
||||
text=#value.inbox .. " /inbox",
|
||||
scale = {x=1,y=1},
|
||||
alignment = {x=0.5, y=0.5},
|
||||
})
|
||||
end
|
||||
chatplus.loggedin[key].lastcount = #value.inbox
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
24
mods/email/README.md
Normal file
24
mods/email/README.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Email
|
||||
|
||||
![screenshot](https://cdn.pbrd.co/images/8fn5I3u.png)
|
||||
|
||||
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
|
1
mods/email/depends.txt
Normal file
1
mods/email/depends.txt
Normal file
|
@ -0,0 +1 @@
|
|||
chatplus?
|
1
mods/email/description.txt
Normal file
1
mods/email/description.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Adds email style inboxes to Minetest.
|
44
mods/email/hud.lua
Normal file
44
mods/email/hud.lua
Normal file
|
@ -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)
|
48
mods/email/hudkit.lua
Normal file
48
mods/email/hudkit.lua
Normal file
|
@ -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
|
215
mods/email/init.lua
Normal file
215
mods/email/init.lua
Normal file
|
@ -0,0 +1,215 @@
|
|||
email = {
|
||||
log = function(msg) end
|
||||
}
|
||||
local _loading = true
|
||||
|
||||
if minetest.global_exists("chatplus") then
|
||||
email.log = chatplus.log
|
||||
|
||||
function chatplus.on_old_inbox(inbox)
|
||||
if _loading then
|
||||
return
|
||||
end
|
||||
|
||||
email.inboxes = inbox
|
||||
end
|
||||
end
|
||||
|
||||
function email.init()
|
||||
email.inboxes = {}
|
||||
email.load()
|
||||
_loading = false
|
||||
if minetest.global_exists("chatplus") and chatplus.old_inbox then
|
||||
chatplus.on_old_inbox(chatplus.old_inbox)
|
||||
end
|
||||
end
|
||||
|
||||
function email.load()
|
||||
local file = io.open(minetest.get_worldpath() .. "/email.txt", "r")
|
||||
if file then
|
||||
local from_file = minetest.deserialize(file:read("*all"))
|
||||
file:close()
|
||||
if type(from_file) == "table" then
|
||||
if from_file.mod == "email" and tonumber(from_file.ver_min) <= 1 then
|
||||
email.inboxes = from_file.inboxes
|
||||
else
|
||||
error("[Email] Attempt to read incompatible email.txt file.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function email.save()
|
||||
local file = io.open(minetest.get_worldpath() .. "/email.txt", "w")
|
||||
if file then
|
||||
file:write(minetest.serialize({
|
||||
mod = "email", version = 1, ver_min = 1,
|
||||
inboxes = email.inboxes }))
|
||||
file:close()
|
||||
end
|
||||
end
|
||||
minetest.register_on_shutdown(email.save)
|
||||
|
||||
function email.get_inbox(name)
|
||||
return email.inboxes[name] or {}
|
||||
end
|
||||
|
||||
function email.clear_inbox(name)
|
||||
email.inboxes[name] = nil
|
||||
email.save()
|
||||
end
|
||||
|
||||
minetest.register_on_joinplayer(function(player)
|
||||
local inbox = email.get_inbox(player:get_player_name())
|
||||
if #inbox > 0 then
|
||||
minetest.after(10, function()
|
||||
minetest.chat_send_player(player:get_player_name(),
|
||||
"(" .. #inbox .. ") You have mail! Type /inbox to recieve")
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
function email.get_formspec(name)
|
||||
local inbox = email.get_inbox(name)
|
||||
|
||||
local fs = "size[12,8]"
|
||||
fs = fs .. "vertlabel[0,0;email Mail]"
|
||||
|
||||
function row(fs, c1, date, from, msg)
|
||||
date = minetest.formspec_escape(date)
|
||||
from = minetest.formspec_escape(from)
|
||||
msg = minetest.formspec_escape(msg)
|
||||
return fs .. ",#d0d0d0," .. table.concat({date, c1, from, msg}, ",")
|
||||
end
|
||||
|
||||
fs = fs .. "tablecolumns[color;text;color;text;text]"
|
||||
fs = fs .. "tableoptions[highlight=#ffffff33]"
|
||||
fs = fs .. "table[0.5,0;11.25,7;inbox;"
|
||||
fs = fs .. "#ffffff,Date,,From,Message"
|
||||
if #inbox == 0 then
|
||||
fs = row(fs, "#d0d0d0", "", ":)", "Well done! Your inbox is empty!")
|
||||
else
|
||||
for i = 1, #inbox do
|
||||
local color = "#ffffff"
|
||||
if minetest.check_player_privs(inbox[i].from, {kick = true, ban = true}) then
|
||||
color = "#FFD700"
|
||||
end
|
||||
local msg = inbox[i].msg
|
||||
fs = row(fs, color, inbox[i].date, inbox[i].from, msg:sub(1, 44))
|
||||
while #msg > 45 do
|
||||
msg = msg:sub(45, #msg)
|
||||
fs = row(fs, color, "", "", msg:sub(1, 44))
|
||||
end
|
||||
end
|
||||
end
|
||||
fs = fs .. "]"
|
||||
|
||||
fs = fs .. "button[0,7.25;2,1;clear;Delete All]"
|
||||
--fs = fs .. "button[0,7.25;2,1;clear;Mark as read]"
|
||||
fs = fs .. "button_exit[10.1,7.25;2,1;close;Close]"
|
||||
fs = fs .. "label[2,7.4;Exit then type /mail username message to reply]"
|
||||
|
||||
return fs
|
||||
end
|
||||
|
||||
function email.show_inbox(name, text_mode)
|
||||
if text_mode then
|
||||
local inbox = email.get_inbox(name)
|
||||
if #inbox == 0 then
|
||||
return true, "Your inbox is empty!"
|
||||
else
|
||||
minetest.chat_send_player(name, #inbox .. " items in your inbox:")
|
||||
for i = 1, #inbox do
|
||||
local item = inbox[i]
|
||||
minetest.chat_send_player(name, i .. ") " ..item.date ..
|
||||
" <" .. item.from .. "> " .. item.msg)
|
||||
end
|
||||
return true, "End of mail (" .. #inbox .. " items)"
|
||||
end
|
||||
else
|
||||
local fs = email.get_formspec(name)
|
||||
minetest.show_formspec(name, "email:inbox", fs)
|
||||
|
||||
return true, "Opened inbox!"
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_on_player_receive_fields(function(player,formname,fields)
|
||||
if fields.clear then
|
||||
local name = player:get_player_name()
|
||||
email.clear_inbox(name)
|
||||
minetest.chat_send_player(name, "Inbox cleared!")
|
||||
email.show_inbox(name)
|
||||
end
|
||||
|
||||
--[[if fields.mark_all_read then
|
||||
if player and player.inbox and #player.inbox > 0 then
|
||||
for i = 1, #player.inbox do
|
||||
player.inbox[i].read = true
|
||||
end
|
||||
minetest.chat_send_player(name, "Marked all as read!")
|
||||
email.show_inbox(name)
|
||||
end
|
||||
end]]--
|
||||
end)
|
||||
|
||||
function email.send_mail(name, to, msg)
|
||||
minetest.log("Email - To: "..to..", From: "..name..", MSG: "..msg)
|
||||
email.log("Email - To: "..to..", From: "..name..", MSG: "..msg)
|
||||
if true then
|
||||
local mail = {
|
||||
date = os.date("%Y-%m-%d %H:%M:%S"),
|
||||
from = name,
|
||||
msg = msg}
|
||||
|
||||
if email.inboxes[to] then
|
||||
table.insert(email.inboxes[to], mail)
|
||||
else
|
||||
email.inboxes[to] = { mail }
|
||||
end
|
||||
|
||||
email.save()
|
||||
|
||||
minetest.chat_send_player(to, name .. " sent you mail! Type /inbox to see it.")
|
||||
|
||||
return true, "Message sent to " .. to
|
||||
else
|
||||
return false, "Player '" .. to .. "' does not exist"
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("inbox", {
|
||||
params = "[/clear/text]",
|
||||
description = "Inbox: Blank to see inbox. Use 'clear' to empty inbox, 'text' for text only.",
|
||||
func = function(name, param)
|
||||
if param == "clear" then
|
||||
email.clear_inbox(name)
|
||||
|
||||
return true, "Inbox cleared"
|
||||
elseif param == "text" or param == "txt" or param == "t" then
|
||||
return email.show_inbox(name, true)
|
||||
else
|
||||
return email.show_inbox(name, false)
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("mail", {
|
||||
params = "name msg",
|
||||
description = "mail: add a message to a player's inbox",
|
||||
func = function(name, param)
|
||||
local to, msg = string.match(param, "^([%a%d_-]+) (.+)")
|
||||
if to and msg then
|
||||
return email.send_mail(name, to, msg)
|
||||
else
|
||||
return false, "Usage: mail <playername> <some message>"
|
||||
end
|
||||
|
||||
end
|
||||
})
|
||||
|
||||
dofile(minetest.get_modpath("email") .. "/hud.lua")
|
||||
|
||||
email.init()
|
BIN
mods/email/textures/email_mail.png
Normal file
BIN
mods/email/textures/email_mail.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 270 B |
12
mods/report/README.md
Normal file
12
mods/report/README.md
Normal file
|
@ -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.
|
||||
|
|
@ -1 +1 @@
|
|||
chatplus
|
||||
email
|
||||
|
|
1
mods/report/description.txt
Normal file
1
mods/report/description.txt
Normal file
|
@ -0,0 +1 @@
|
|||
Allows players to report misconduct or bugs using /report.
|
|
@ -1,7 +1,3 @@
|
|||
if not chatplus.send_mail then
|
||||
error("You need to update chatplus!")
|
||||
end
|
||||
|
||||
minetest.register_chatcommand("report", {
|
||||
func = function(name, param)
|
||||
param = param:trim()
|
||||
|
@ -19,20 +15,20 @@ minetest.register_chatcommand("report", {
|
|||
-- Get comma separated list of online moderators and admins
|
||||
local mods = {}
|
||||
for _, player in pairs(minetest.get_connected_players()) do
|
||||
local pname = player:get_player_name()
|
||||
if minetest.check_player_privs(pname, {kick = true, ban = true}) then
|
||||
table.insert(mods, pname)
|
||||
minetest.chat_send_player(pname, "-!- " .. name .. " reported: " .. param)
|
||||
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, ", ")
|
||||
chatplus.send_mail(name, minetest.setting_get("name"),
|
||||
email.send_mail(name, minetest.setting_get("name"),
|
||||
"Report: " .. param .. " (mods online: " .. mod_list .. ")")
|
||||
return true, "Reported. Moderators currently online: " .. mod_list
|
||||
else
|
||||
chatplus.send_mail(name, minetest.setting_get("name"),
|
||||
email.send_mail(name, minetest.setting_get("name"),
|
||||
"Report: " .. param .. " (no mods online)")
|
||||
return true, "Reported. We'll get back to you."
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue