[Mod] Chat History [chat_history]

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

[Mod] Chat History [chat_history]

by sorcerykid » Sun Aug 19, 2018 22:54

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: 467
Joined: Fri Apr 07, 2017 08:49
GitHub: bosapara
 

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

Re: [Mod] Chat History [chat_history]

by twoelk » Tue Aug 21, 2018 13:59

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: 1060
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

Re: [Mod] Chat History [chat_history]

by sorcerykid » Tue Aug 21, 2018 14:26

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: 467
Joined: Fri Apr 07, 2017 08:49
GitHub: bosapara

Re: [Mod] Chat History [chat_history]

by bosapara » Tue Aug 21, 2018 16:25

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: 1060
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

Re: [Mod] Chat History [chat_history]

by sorcerykid » Fri Aug 24, 2018 15:36

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: 467
Joined: Fri Apr 07, 2017 08:49
GitHub: bosapara

Re: [Mod] Chat History [chat_history]

by bosapara » Sun Aug 26, 2018 07:04

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: 65
Joined: Wed Mar 14, 2018 23:40
GitHub: askotos
IRC: aristotle_
In-game: aristotle

Re: [Mod] Chat History [chat_history]

by aristotle » Sun Aug 26, 2018 23:09

Thank you! Just downloaded! My LAN test server was waiting for it! :D
Happy builds & explorations!
 

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

Re: [Mod] Chat History [chat_history]

by sorcerykid » Sun Aug 26, 2018 23:43

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: 467
Joined: Fri Apr 07, 2017 08:49
GitHub: bosapara

Re: [Mod] Chat History [chat_history]

by bosapara » Mon Aug 27, 2018 02:04

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: 1060
Joined: Fri Aug 26, 2016 15:36
Location: Illinois, USA
GitHub: sorcerykid
In-game: Nemo

Re: [Mod] Chat History [chat_history]

by sorcerykid » Mon Aug 27, 2018 02:10

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: 467
Joined: Fri Apr 07, 2017 08:49
GitHub: bosapara

Re: [Mod] Chat History [chat_history]

by bosapara » Mon Aug 27, 2018 11:52

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
 


Return to WIP Mods



Who is online

Users browsing this forum: No registered users and 3 guests