[Mod] Beerchat: Chat rooms, colors and shortcuts [beerchat]

Post Reply
User avatar
Beerholder
Member
Posts: 199
Joined: Wed Aug 03, 2016 20:23
GitHub: evrooije
In-game: Beerholder

[Mod] Beerchat: Chat rooms, colors and shortcuts [beerchat]

by Beerholder » Post

[Mod] Beerchat [beerchat]

[Mod] Beerchat [beerchat] is a chat mod that supports chat channels/ chat rooms, colored messages, muting players, message sounds and chat shortcuts. It is in use on the Beerarchy server and as it is quite feature rich and has no dependencies on the Beerarchy subgame (or any other mods for that matter), I decided to spin it off just in case other people would like to use it. Full list of features:
  • Support for chat rooms, called channels, in which members can privately chat without flooding the main channel
  • The default chat has been turned into a channel as well, called main. You can leave (and rejoin) the main channel, e.g. when you are not interested or it is too spammy
  • Extremely easy to chat in a channel, just start your message with #your channel name: (in case of spaces in the channel name) or #my_channel (no colon needed if there are no spaces in the name)
  • You can still chat the old way. Just enter your message like you used to do and it will appear in the main chat automatically (no need to prepend with #main or do other difficult things)
  • Channels can be assigned a color so messages in that channel appear in that color. This way you can easily differentiate between main channel chats and private channel chats
  • Distance based chatting, called whispering. Players out of range will not see your message, players in range will see the message in a different color. Ideal to talk to nearby people and to differentiate messages
  • Provides shortcuts: @ for PMs, # for chat room messages and $ to whisper
  • Remembers the last player or last channel a message was sent to. So at first you can @player or #my_channel and after that just use @ or # only to send to that player/ channel again. Ability to switch channels so normal messages will be sent there
  • Uses the console/ standard chat "window" for chat messages
  • Message formats fully configurable (currently in the init.lua but really easy to do, all settings are in the top of the file and documented). You can pass parameters to the message strings as well. So if you want to strip the channel name from the main channel you can do so. You can shuffle elements around e.g. placing the channel name at the end of a message. You can add a time. You can put from_player and to_player in all messages or just a few
  • Sound notifications for private and channel messages
  • State is stored in mod storage and player attributes so they survive a server restart. E.g. channels you have created and joined will still be there after server restart. Players you have muted will also survive a server restart.
Spoiler
Image
Image
Source code: https://github.com/evrooije/beerchat
Download: https://github.com/evrooije/beerchat/archive/master.zip
Depends: none
Requires Minetest 0.4.16 because of mod storage and player attributes support in the mod
Attribution: Some code used from orwell's atchat: viewtopic.php?f=11&t=13593 and of course the other chat mods for their inspiration
Spoiler
  • Setting a default channel, e.g. messages typed normally will appear in the channel of your choice
  • Beerchat formspec to tweak per player settings such as enabling/ disabling sounds, managing channels, overriding colors, etc.
  • Configurable color for private messages
  • A "talk to" feature where you can send a public message but it will appear as <from_player> to <to_player>, possibly highlighting the message for that player only using a selected color. This to avoid confusion as to who the message was meant for e.g. in the case of <player01> can i use mese ; <player02> can you give me some diamonds ; <player03> yes
  • Shout with ! support
  • Externalizing the settings from the init.lua and support using configuration file and the main minetest.conf
  • Improved channel management by server administrator, e.g. to avoid wild growth of channels. Adding a last used timestamp to identify channel that have not been used in a long time. Automatic cleanup of old unused channels
  • Message highlighting when your name is mentioned in a chat message or when a message contains a certain string a la chat2
  • Option to place certain messages in the HUD a la chat2 and allow users to enable/ disable this feature via preferences formspec on a per message type (PM, channel, name mentions, etc.) basis. Even easier to identify messages of interest
  • Channel join/ leave sound/ chat notifications to the other members of the channel, so they can see when a member joins or leaves the channel or when they log in or out
Using the Mod In-Game

Channel Management
Channels are like chat rooms. Messages in channels are only sent to the members of that channel. They can be made private by password protecting it and a color to differentiate from the main chat. Channel management is done via chat commands. Parameters to these commands are comma separated. To create a channel, use the /create_channel or /cc command and supply channel name, optional password and optional color (defaults to white). Channels can be deleted via /delete_channel or /dc and this can only be done by the channel owner. The owner does not need to supply the channel's password to delete the channel. The /my_channels or /mc command shows the channels you are owner/ member of in json format. Some channel management examples below:

Code: Select all

/create_channel my super secret room,mysecretpass01,#00ffff
/create_channel my public room
/create_channel my red colored room without password,,#ff0000
/delete_channel my super secret room
To join a channel use the /join_channel or /jc command which takes the channel name and optionally a password. To leave a channel do /leave_channel or /lc and supply the channel name. If you are the owner of a channel, you can send an invite to a player using the /invite_channel or /ic command which will then send the channel name and password to the invited player.

Code: Select all

/jc someone else's channel,pass01
/lc channel i got bored with
/ic my private room,NicePlayer01
Channel Chats
When you chat normally, everything is written to the channel called main. Chats to main are prefixed with |#main| and given the default main channel color white. In order to write to a specific channel you have joined, start your chat with a #, then the channel name and then a colon. Messages sent this way will only be seen by the other members of the channel (unless someone has muted the sender, see also muting below). If you want to send another message to the same channel you can start it with just the # (without channel name). To switch to a channel in order to send messages to that channel without specifying the channel name, you can use #channel_name:

Code: Select all

#my channel: This will be sent to my channel
# This will also be sent to my channel as that was the last one used
#jokes In this case a colon is not needed as there is no space in the channel name
# This message will also be sent to the jokes channel
#peace_and_quiet
This normal message will now not be sent to main, but to the peace_and_quiet channel instead. No need to put a hash in front of your message
#main
Switched back to the main chat channel
These "hash chats" are prefixed with |#channel name| and appear in the color of that particular channel as specified during channel creation (or default white if no color was supplied at that time).

NOTE: You can leave the main channel! So if things are getting spammy, besides muting people (see below) you can leave the main channel and just chat in the other channels you are a member of.

Muting Players
To mute a player, just do /mute or /ignore player name. Unmuting is done via /unmute or /unignore player name. E.g.:

Code: Select all

/mute Griefer666
/unmute NicePlayerAfterAll
Private Messages
You can send private messages the old way using /msg but there is now a shorthand as well using the @ sign (like the at chat mod, code was inspired by this mod). To at chat a PM, just supply the user name or comma separated names you want to send the PM to. If you start the message with just @ without supplying player names, it will send the message to the last user(s) you sent a PM to, e.g.:

Code: Select all

@JohnDoe How's life?
@JohnDoe,MaryJane Shall we have a party at spawn >8-)))
@ Hey John, Mary, I will be at spawn in 5 minutes ok?
Whispering
You can whisper by starting your message with the $ sign. Only players within a range of 32 blocks will then be able to see your chat (which happens to be the same maximum range of seeing other players). The dollar chat will be sent to the main channel in a grey color. If you want to dollar chat with a larger or shorter range, you can supply the radius straight after the dollar. The maximum radius is (for now) 200 blocks (or you might just start using normal chat or use channels if you don't want others to hear you). Whispering is just there so that when used, chats from nearby players are colored differently (light grey) and can be more easily distinguished from the chat of players further away. The below dollar chats whisper the message to 16, 32 and 64 nodes respectively.

Code: Select all

$16 Can you hear me major Tom
$ Can you hear me now, major Tom?
$64 Can you heeeeeeeeeere I am floating round my tin can
Mod Settings, Configuration and Customization
Spoiler
Configuration is currently done in the init.lua so make the changes in there. For the main channel (channel where messages are sent by default if no channel was specified), you can change the name, the owner and the color. Colors are defined in hexadecimal and start with a #.

Code: Select all

local main_channel_name = "main"     -- The main channel is the one you send messages to when no channel is specified
local main_channel_owner = "ADMIN"   -- The owner of the main channel, usually ADMIN
local main_channel_color = "#ffffff" -- The color in hex of the main channel
The default channel color specifies the color of channels for which no color was passed as argument when the channel was created.

Code: Select all

local default_channel_color = "#ffffff" -- The default color of channels when no color is specified
You can enable or disable sounds and when sounds are enabled you can specify what sounds to play by changing the sound file strings:

Code: Select all

local enable_sounds = true -- Global flag to enable/ disable sounds
Example of a sound string below, make sure that you specify the sound file here without the .ogg extension and that you have the sound file stored in the sounds directory and with the .ogg extension

Code: Select all

local private_message_sound = "beerchat_chime" -- Sound when you receive a private message
Whisper settings control the range controlled dollar chats. The default range is the range used when you do not pass a radius when whispering. You cannot specify a radius larger than the max range. If you would like to be able to whisper over larger distances, you can increase the value of 200 to something higher. The whisper color can be used to visually differentiate whispers from the normal chats. Please note that whispering is done in the main channel.

Code: Select all

local whisper_default_range = 32
local whisper_max_range = 200
local whisper_color = "#aaaaaa"
Spoiler
In the settings section in the init.lua you can customize formatting of the messages. As you can see, parameters can be specified using ${parameter}:

Code: Select all

local main_channel_message_string = "|#${channel_name}| <${from_player}> ${message}"
You can remove the |#main| from main channel chats by removing the ${channel_name} parameter from the above string. This would format main channel messages using the default chat format from Minetest:

Code: Select all

local main_channel_message_string = "<${from_player}> ${message}"
The use of parameters not only allows you to add or remove elements, it also allows you to move elements around in the message string. E.g. to move the channel name to the end of the message:

Code: Select all

local main_channel_message_string = "<${from_player}> ${message} |#${channel_name}|"
The following parameters can be used in the message strings:
  • ${channel_name} name of the channel
  • ${channel_owner} owner of the channel
  • ${channel_password} password to use when joining the channel, used e.g. for invites
  • ${from_player} the player that is sending the message
  • ${to_player} player to which the message is sent, will contain multiple player names e.g. when sending a PM to multiple players
  • ${message} the actual message that is to be sent
  • ${time} the current time in 24 hour format, as returned from os.date("%X")
You can completely customize the formatting of the chat system to your liking, e.g. if you do not like the default use of the | character around channel names, you can change this into whatever you like. The below example uses [ and ] around the channel name in the channel message strings:

Code: Select all

local channel_message_string = "[#${channel_name}] <${from_player}> ${message}"
local main_channel_message_string = "[#${channel_name}] <${from_player}> ${message}"
About the Code
Be warned, the code is not pretty and even though it was refactored after spinning it off from the beerarchy subgame, it may need quite some more refactoring. And it would be nicer if it actually supplied an API, but oh well it was hacked together in 2-3 days. Also, it requires Minetest 0.4.16 as it uses both mod storage and player attributes to keep track of the channels and muted players. Otherwise, the code *should* work pretty much out of the box and I have not run into major issues yet on the Beerarchy server where it is actually running. However be careful when running this mod together with other chat mods, as they could very likely interfere with each other. Have fun and let me know in case of issues!
Attachments
beerchat2.png
beerchat2.png (381.3 KiB) Viewed 1123 times
beerchat1.png
beerchat1.png (435.9 KiB) Viewed 1123 times
Last edited by Beerholder on Sun Jul 23, 2017 22:51, edited 2 times in total.

User avatar
maikerumine
Member
Posts: 1420
Joined: Mon Aug 04, 2014 14:27
GitHub: maikerumine
In-game: maikerumine

Re: [Mod] Beerchat [beerchat]

by maikerumine » Post

Excellent!! :)
Talamh Survival Minetest-->viewtopic.php?f=10&t=12959

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [Mod] Beerchat [beerchat]

by azekill_DIABLO » Post

Perfectly done!
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
Beerholder
Member
Posts: 199
Joined: Wed Aug 03, 2016 20:23
GitHub: evrooije
In-game: Beerholder

Re: [Mod] Beerchat [beerchat]

by Beerholder » Post

azekill_DIABLO wrote:Perfectly done!
Well not that quite perfectly (hence in WIP I guess ;) just found a bug on Beerarchy where using the @ history caused a crash. Just patched it now in master so just git pull or redownload and it should be fixed!

User avatar
azekill_DIABLO
Member
Posts: 7507
Joined: Wed Oct 29, 2014 20:05
GitHub: azekillDIABLO
In-game: azekill_DIABLO
Location: OMICRON
Contact:

Re: [Mod] Beerchat [beerchat]

by azekill_DIABLO » Post

Beerholder wrote:
azekill_DIABLO wrote:Perfectly done!
Well not that quite perfectly (hence in WIP I guess ;) just found a bug on Beerarchy where using the @ history caused a crash. Just patched it now in master so just git pull or redownload and it should be fixed!
Cool thing, dude. I'd like to have my own server. It would be the first mod i'd put on it!
Gone, but not dead. Contact me on discord: azekill_DIABLO#6565
DMs are always open if you want to get in touch!

User avatar
rubenwardy
Moderator
Posts: 6978
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: [Mod] Beerchat: Chat rooms, colors and shortcuts [beerch

by rubenwardy » Post

Awesome! How well does this integrate with the IRC mod?
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Beerholder
Member
Posts: 199
Joined: Wed Aug 03, 2016 20:23
GitHub: evrooije
In-game: Beerholder

Re: [Mod] Beerchat: Chat rooms, colors and shortcuts [beerch

by Beerholder » Post

rubenwardy wrote:Awesome! How well does this integrate with the IRC mod?
Not at the moment but I can definitely have a look at it and see if that is possible :)

User avatar
Beerholder
Member
Posts: 199
Joined: Wed Aug 03, 2016 20:23
GitHub: evrooije
In-game: Beerholder

Re: [Mod] Beerchat: Chat rooms, colors and shortcuts [beerch

by Beerholder » Post

Update 2017-07-04
Added the ability to switch channels by just supplying #channel_name. You can now do this:

Code: Select all

#my_channel
This message (without the hash prefix) will be sent to my_channel
No need to do #my_channel message or # message
#main
We now switched back to the main channel
Assuming you named your main channel main. Also fixed one small bug (typo in variable name) and a typo in one of the strings.

User avatar
ThomasMonroe
Member
Posts: 286
Joined: Tue Apr 04, 2017 16:21
GitHub: ThomasMonroe314
IRC: ThomasMonroe TMcSquared
In-game: ThomasMonroe TMcSquared
Location: Wherever I am at

Re: [Mod] Beerchat: Chat rooms, colors and shortcuts [beerch

by ThomasMonroe » Post

I hope you get this to work with the IRC Mod cause that would be awesome.
I don't make messes, I just, er...disturb the local entropy!

User avatar
hephaestus
Member
Posts: 10
Joined: Sun Jan 14, 2024 16:11
IRC: hephaestus

Re: [Mod] Beerchat: Chat rooms, colors and shortcuts [beerchat]

by hephaestus » Post

I liked so much this mod, congratulations!!

User avatar
hephaestus
Member
Posts: 10
Joined: Sun Jan 14, 2024 16:11
IRC: hephaestus

Re: [Mod] Beerchat: Chat rooms, colors and shortcuts [beerchat]

by hephaestus » Post

I have a question. is possible to send messages from discord to MT chat?

User avatar
Mantar
Member
Posts: 589
Joined: Thu Oct 05, 2017 18:46
Contact:

Re: [Mod] Beerchat: Chat rooms, colors and shortcuts [beerchat]

by Mantar » Post

Yes, matterbridge can send to/from discord and MT chat both.
Lead dev of Exile, git repo: https://codeberg.org/Mantar/Exile

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 18 guests