[Mod] Chat History [chat_history]

Post Reply
User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

[Mod] Chat History [chat_history]

by sorcerykid » Post

Image

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.

Image

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).

User avatar
bosapara
Member
Posts: 637
Joined: Fri Apr 07, 2017 08:49

Re: [Mod] Chat History [chat_history]

by bosapara » Post

+ Different design:

Image
Attachments
chat_history.zip
(14.01 KiB) Downloaded 78 times

twoelk
Member
Posts: 1482
Joined: Fri Apr 19, 2013 16:19
GitHub: twoelk
IRC: twoelk
In-game: twoelk
Location: northern Germany

Re: [Mod] Chat History [chat_history]

by twoelk » Post

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.

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Chat History [chat_history]

by sorcerykid » Post

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.

User avatar
bosapara
Member
Posts: 637
Joined: Fri Apr 07, 2017 08:49

Re: [Mod] Chat History [chat_history]

by bosapara » Post

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)

Image

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Chat History [chat_history]

by sorcerykid » Post

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.

User avatar
bosapara
Member
Posts: 637
Joined: Fri Apr 07, 2017 08:49

Re: [Mod] Chat History [chat_history]

by bosapara » Post

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

User avatar
aristotle
Member
Posts: 79
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle
Location: Currently on Melpomene, waiting for the starship to be fixed.
Contact:

Re: [Mod] Chat History [chat_history]

by aristotle » Post

Thank you! Just downloaded! My LAN test server was waiting for it! :D
Happy builds & explorations! | Initiating my Creative Minetest channel on YouTube

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Chat History [chat_history]

by sorcerykid » Post

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)?

User avatar
bosapara
Member
Posts: 637
Joined: Fri Apr 07, 2017 08:49

Re: [Mod] Chat History [chat_history]

by bosapara » Post

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
})	

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Chat History [chat_history]

by sorcerykid » Post

The chat_history.open() function takes a player name. You are passing a player object. That is why it's not working.

User avatar
bosapara
Member
Posts: 637
Joined: Fri Apr 07, 2017 08:49

Re: [Mod] Chat History [chat_history]

by bosapara » Post

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

Image


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

User avatar
Wuzzy
Member
Posts: 4803
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Chat History [chat_history]

by Wuzzy » Post

By the way, Minetest supports read-only text fields now.

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Chat History [chat_history]

by sorcerykid » Post

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.

User avatar
Wuzzy
Member
Posts: 4803
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: [Mod] Chat History [chat_history]

by Wuzzy » Post

IIRC, read-only text fields can be copied as well. Not sure.

User avatar
Lone_Wolf
Member
Posts: 2578
Joined: Sun Apr 09, 2017 05:50
GitHub: LoneWolfHT
IRC: LandarVargan
In-game: LandarVargan

Re: [Mod] Chat History [chat_history]

by Lone_Wolf » Post

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...
My ContentDB -|- Working on CaptureTheFlag -|- Minetest Forums Dark Theme!! (You need it)

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Chat History [chat_history]

by sorcerykid » Post

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 :)

User avatar
v-rob
Developer
Posts: 971
Joined: Thu Mar 24, 2016 03:19
GitHub: v-rob
IRC: v-rob
Location: Right behind you.

Re: [Mod] Chat History [chat_history]

by v-rob » Post

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.
Core Developer | My Best Mods: Bridger - Slats - Stained Glass

User avatar
sorcerykid
Member
Posts: 1847
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Chat History [chat_history]

by sorcerykid » Post

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 :)

Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests