Page 1 of 1
[Mod] Chat History [chat_history]
Posted: Sun Aug 19, 2018 22:54
by sorcerykid
Chat History Mod v2.0
chat_history (by sorcerykid)
Chat History is an interactive chat history viewer with a variety of message filtering options and notification sounds for use on servers. This mod is intended to be compatible with all versions of Minetest 0.4.16+. It has been in continuous use on the
Just Test Tribute server since July 2017 with only minor revisions and no known bugs.
PS. A lot of people have been asking me (for over a year now) to release this mod, so here it is finally. Sorry for the delay ;)
Repository:
https://bitbucket.org/sorcerykid/chat_history
Download Archive (.zip)
Download Archive (.tar.gz)
Dependencies:
Default Mod
https://github.com/minetest/minetest_game
ActiveFormspecs Mod
https://bitbucket.org/sorcerykid/formspecs
Chat2 Mod (optional)
https://github.com/minetest-mods/chat2
Source Code License:
Copyright (c) 2017-2018, Leslie Krause
GNU Lesser General Public License v3 (LGPL-3.0)
Media License:
Creative Commons Attribution 4.0 International (CC BY 4.0)
See included README.txt for licensing terms.
Usage Instructions:
With the
/chat command, you can view the entire chat history (up to 100 messages) or you can filter messages by a specific player as well as by PM or shout. When filtering by PM, you will only see private messages sent to you or that you sent to other players. You can also copy the output text directly to the clipboard. For convenience sake, messages are sorted newest first.
With the
/c [search_phrase] command, you can search for messages containing only a specific phrase in addition to the existing filters. For more refined queries, DOS-like wildcards are supported: ? matches a single character, + matches one or more characters, and * matches any number of characters.
Best of all, since the messages are stored server-side, it is possible to view chat history that occurred prior to logging in, including offline private messages. An alert sound will also play if you receive a private message while logged into the server. No more wading through pages of text just to catch up on any important discussions while you were away!
The primary impetus for this mod was to aid in moderation and administration tasks. For example, copying text into a translator is impossible given the existing chat interface. On a multi-lingual server, however, that is near essential. Likewise, the ability to search and filter text can be beneficial when investigating chat-related misconduct while in-game.
For server operators (and mod or game developers) that wish to interface directly with the Chat History, I've provided the following two functions:
- chat_history.add_message( sender, recipient, message )
Inserts a new message into the chat history buffer
- sender - the name of the player sending a message
- recipient - the name of the player to receive a private message, or nil for a global message
- message - the text of the new message
chat_history.open( name, filter_player )
Opens the chat history viewer for a specified player
- name - the name of the player to show the formspec to
- filter_player - an optional player name by which to filter the messages
In an upcoming release, a configuration setting will be available to change the buffer limit and review limit (which are currently hardcoded).
Re: [Mod] Chat History [chat_history]
Posted: Mon Aug 20, 2018 14:12
by bosapara
+ Different design:
Re: [Mod] Chat History [chat_history]
Posted: Tue Aug 21, 2018 13:59
by twoelk
not only usefull but also nice looking :-D
maybe a "copy to clipboard" button, that is if minetest" supports such, could help with mobil devices or other systems that don't offer the feature from within minetest.
Re: [Mod] Chat History [chat_history]
Posted: Tue Aug 21, 2018 14:26
by sorcerykid
Thanks for feedback twoelk! I wish there was an easy way to copy text to clipboard, but that would require a modded client. The best I could do is to offer an editable text field. For non-mobile users, at least there are keyboard shortcuts :)
I really feel like this mod is essential for multiplayer games. I used it routinely (even as an ordinary player) on JT2. Whenever I logged into the server, I typed /chat to see what people were talking about and if I had any missed PM's.
Re: [Mod] Chat History [chat_history]
Posted: Tue Aug 21, 2018 16:25
by bosapara
Is it possible to add button to sfinv crafting menu?
for macrocraft im used this (down), but for chat mod it doesnt work
Code: Select all
image_button[5.75,0.5;1,1;macro.png;x;]
and
minetest.register_on_player_receive_fields(function (player, formname, fields)
if fields["x"] and minetest.registered_chatcommands["x"] then
minetest.registered_chatcommands["x"]["func"](player:get_player_name())
end
end)
Re: [Mod] Chat History [chat_history]
Posted: Fri Aug 24, 2018 15:36
by sorcerykid
bosapara wrote:Is it possible to add button to sfinv crafting menu?
for macrocraft im used this (down), but for chat mod it doesnt work
You'll need to call the chat_history.open( player_name ) function as described in the first post. Be sure that the chat_history mod is added as a dependency to sfinv.
As for the Macro Crafting Manager, I will add official support for sfinv in the next version. Come to think of it, I should also provide an API to open the form so it isn't necessary for mods to call the chat command directly.
Re: [Mod] Chat History [chat_history]
Posted: Sun Aug 26, 2018 07:04
by bosapara
sorcerykid wrote:bosapara wrote:Is it possible to add button to sfinv crafting menu?
for macrocraft im used this (down), but for chat mod it doesnt work
You'll need to call the chat_history.open( player_name ) function as described in the first post. Be sure that the chat_history mod is added as a dependency to sfinv.
As for the Macro Crafting Manager, I will add official support for sfinv in the next version. Come to think of it, I should also provide an API to open the form so it isn't necessary for mods to call the chat command directly.
Used chat_history(player_name), but it works only for /chat nick. For /chat it doesnt work
Re: [Mod] Chat History [chat_history]
Posted: Sun Aug 26, 2018 23:09
by aristotle
Thank you! Just downloaded! My LAN test server was waiting for it! :D
Re: [Mod] Chat History [chat_history]
Posted: Sun Aug 26, 2018 23:43
by sorcerykid
bosapara wrote:
Used chat_history(player_name), but it works only for /chat nick. For /chat it doesnt work
That's strange. I created a test mod that opens the chat history as soon as a player joins the server, and it seems to work.
Code: Select all
minetest.register_on_joinplayer( function( player )
local player_name = player:get_player_name( )
chat_history.open( player_name )
end )
Are you sure that you are supplying the correct parameter to the function (the name of the player to show the formspec to)?
Re: [Mod] Chat History [chat_history]
Posted: Mon Aug 27, 2018 02:04
by bosapara
sorcerykid wrote:bosapara wrote:
Used chat_history(player_name), but it works only for /chat nick. For /chat it doesnt work
That's strange. I created a test mod that opens the chat history as soon as a player joins the server, and it seems to work.
Code: Select all
minetest.register_on_joinplayer( function( player )
local player_name = player:get_player_name( )
chat_history.open( player_name )
end )
Are you sure that you are supplying the correct parameter to the function (the name of the player to show the formspec to)?
Your command /chat works good, but there different command for form creating
I tell about an example /chat2 with 'chat_history.open' command, im used this and it works only for /chat2 nick
Code: Select all
minetest.register_chatcommand("chat2", {
params = "",
description = "View the recent chat history with optional message filters.",
func = function(name, param)
chat_history.open(minetest.get_player_by_name(name), filter_player)
return true
end
})
Re: [Mod] Chat History [chat_history]
Posted: Mon Aug 27, 2018 02:10
by sorcerykid
The chat_history.open() function takes a player name. You are passing a player object. That is why it's not working.
Re: [Mod] Chat History [chat_history]
Posted: Mon Aug 27, 2018 11:52
by bosapara
sorcerykid wrote:The chat_history.open() function takes a player name. You are passing a player object. That is why it's not working.
Thanx for advices. Finaly found the way, but all works for 99%, need to choose empty player to get chat history
When i add this code - it doesnt work (or i do something wrong)
Code: Select all
if param ~= "" and not minetest.player_exists( param ) then
return false, "Unknown player specified."
else
Add 'sfinv?' to dependences and code to chat_history mod
Code: Select all
minetest.register_chatcommand( "chat9", {
description = "View automated info notifications.",
func = function( name, param )
local meta = { filter_phrase = "", player_list = get_player_list( ) }
minetest.create_form( meta, minetest.get_player_by_name( name ), get_player_formspec( name, meta, param, false, false ), on_close_player_formspec )
end
} )
if rawget(_G, "sfinv") then --sfinv installed (part of minetest_game since 0.4.15)
assert(sfinv.enabled)
local orig_get = sfinv.pages["sfinv:crafting"].get
sfinv.override_page("sfinv:crafting", {
get = function(self, player, context)
local fs = orig_get(self, player, context)
return fs .. ("image_button[7,2.5;1,1;msg0.png;chat9;]")
end
})
--compatibility with pre-0.4.16 sfinv
local set_page = sfinv.set_page or function(player, name)
--assumptions: src pg has no leave callback, dst pg has no enter callback
local ctx = {page=name}
sfinv.contexts[player:get_player_name()] = ctx
sfinv.set_player_inventory_formspec(player, ctx)
end
--show the form when the button is pressed and hide it when done
minetest.register_on_player_receive_fields(function(player, formname, fields)
if fields["chat9"] and minetest.registered_chatcommands["chat9"] then
minetest.registered_chatcommands["chat9"]["func"](player:get_player_name())
return true
elseif fields.worldedit_gui_exit then --return to original page
set_page(player, "sfinv:crafting")
return true
end
return false
end)
end
Re: [Mod] Chat History [chat_history]
Posted: Wed Jan 08, 2020 01:45
by Wuzzy
By the way, Minetest supports read-only text fields now.
Re: [Mod] Chat History [chat_history]
Posted: Wed Jan 08, 2020 21:04
by sorcerykid
Wuzzy wrote:By the way, Minetest supports read-only text fields now.
The text-field is intentionally editable so that users can copy the chat history to the clipboard. This way messages can be saved to a text file, pasted into an online translator, etc.
Re: [Mod] Chat History [chat_history]
Posted: Thu Jan 09, 2020 00:52
by Wuzzy
IIRC, read-only text fields can be copied as well. Not sure.
Re: [Mod] Chat History [chat_history]
Posted: Sat Jan 11, 2020 00:29
by Lone_Wolf
Wuzzy wrote:IIRC, read-only text fields can be copied as well
If the builtin escape menu uses read-only text fields then you're right about being able to copy from it. I just tested
Edit: Nice mod btw. I can see this being quite useful...
Re: [Mod] Chat History [chat_history]
Posted: Sat Jan 11, 2020 01:07
by sorcerykid
Thanks for the heads up, as that it is really great news!
I can probably add a conditional to output a read-only field when the server version is 5.0 or above, otherwise fallback to the editable field to maintain compatibility with 0.4.x clients. Or if anything, just make it a configuration setting. I've long been wanting to improve the interface with colorized messages, and now I can foresee that being possibility :)
Re: [Mod] Chat History [chat_history]
Posted: Tue Jan 14, 2020 01:15
by v-rob
Old textareas can be made read-only be omitting the name, but you can't copy and paste from them (tested on 0.4.16). 5.0.0 read-only textareas can be copy and paste.
Re: [Mod] Chat History [chat_history]
Posted: Fri Feb 14, 2020 16:33
by sorcerykid
Version 3.0 is now underway!
I just completed a MAJOR refactoring of Chat History so now it adheres to the recommended best practices as described in last-week's
Code Guide for ActiveFormspecs. This has the advantage that all form-related functions and variables have been consolidated, which has greatly streamlined the logic since it was becoming unbearable to even plan for feature updates in this mod's original state.
Here's the current 3.0-dev branch:
https://github.com/sorcerykid/chat_history/tree/3.0-dev
Incidentally, Chat History was the very first mod that employed the ActiveFormspecs API back in 2017, hence that is why it retained the legacy code-structure. However, with these improvements finally in place under-the-hood, I can eventually begin work on a Minetest 5.0-specific version of Chat History that features a much fancier GUI :)