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)
|
Loading…
Add table
Add a link
Reference in a new issue