[Mod] Chat log [chatlog]
[Mod] Chat log [chatlog]
The name says it all. Creates a chatlog.txt file in the world directory.
I don't know if this already exists but I couldn't find one so I decided to make one.
Also there is a monthfirst variable inside the init.lua which does what it says(if true the date for Feb 1st would be 2/1/13 if false it would be(1/2/13) and by default I made it true because i'm guessing most people here are American?
The chat log looks something like this(note: the monthfirst is set to false in this picture):
License: CC0
Download:
4Shared(zip)
Dropbox(zip direct download)
Enjoy!
I don't know if this already exists but I couldn't find one so I decided to make one.
Also there is a monthfirst variable inside the init.lua which does what it says(if true the date for Feb 1st would be 2/1/13 if false it would be(1/2/13) and by default I made it true because i'm guessing most people here are American?
The chat log looks something like this(note: the monthfirst is set to false in this picture):
License: CC0
Download:
4Shared(zip)
Dropbox(zip direct download)
Enjoy!
Last edited by JBR on Sun Jun 09, 2013 18:15, edited 1 time in total.
So do you think I should change the default value to false? And the pic is meant to show how you can use it to see whether people are lying or whatever but yeah it is pretty funny.Mito551 wrote:most people here are european. if i'm not wrong. funny pic, lol
Last edited by JBR on Sun Jun 09, 2013 16:04, edited 1 time in total.
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
First of all, WTFPL is not "minetest's version of public domain", its a valid and wiedly used license.JBR wrote:Well I don't like the minetest's version of public domain because it has swearing in it and I think public domain is perfectly valid.Nore wrote:Looks good! However, you have to specify a license (for example, CC0), because public domain is not one.
Second: public domain is not a license in some countries, thus its not accepted in this forum.
Third: Choose CC0 if you dont like the "swearing" in WTFPL.
Ok, though what does CC0 stand for?PilzAdam wrote:First of all, WTFPL is not "minetest's version of public domain", its a valid and wiedly used license.JBR wrote:Well I don't like the minetest's version of public domain because it has swearing in it and I think public domain is perfectly valid.Nore wrote:Looks good! However, you have to specify a license (for example, CC0), because public domain is not one.
Second: public domain is not a license in some countries, thus its not accepted in this forum.
Third: Choose CC0 if you dont like the "swearing" in WTFPL.
Edit: Sorry if I came across a bit uptight when I said " public domain is perfectly valid" I didn't mean to be and TBH I don't care much about the license for this.
Last edited by JBR on Sun Jun 09, 2013 16:14, edited 1 time in total.
- PilzAdam
- Member
- Posts: 4026
- Joined: Fri Jul 20, 2012 16:19
- GitHub: PilzAdam
- IRC: PilzAdam
- Location: Germany
http://creativecommons.org/publicdomain/zero/1.0/ 0.5 seconds search in the internet.JBR wrote:Ok, though what does CC0 stand for?PilzAdam wrote:First of all, WTFPL is not "minetest's version of public domain", its a valid and wiedly used license.JBR wrote:
Well I don't like the minetest's version of public domain because it has swearing in it and I think public domain is perfectly valid.
Second: public domain is not a license in some countries, thus its not accepted in this forum.
Third: Choose CC0 if you dont like the "swearing" in WTFPL.
- rubenwardy
- Moderator
- Posts: 7025
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: London, United Kingdom
- Contact:
Yeah your right sorry for being so lazy. Changing now.PilzAdam wrote:http://creativecommons.org/publicdomain/zero/1.0/ 0.5 seconds search in the internet.JBR wrote:Ok, though what does CC0 stand for?PilzAdam wrote: First of all, WTFPL is not "minetest's version of public domain", its a valid and wiedly used license.
Second: public domain is not a license in some countries, thus its not accepted in this forum.
Third: Choose CC0 if you dont like the "swearing" in WTFPL.
- rubenwardy
- Moderator
- Posts: 7025
- Joined: Tue Jun 12, 2012 18:11
- GitHub: rubenwardy
- IRC: rubenwardy
- In-game: rubenwardy
- Location: London, United Kingdom
- Contact:
You have to doJBR wrote:It's not on minerubenwardy wrote:Is chat not logged in debug.txt?
Code: Select all
debug_level = 2
- CraigyDavi
- Member
- Posts: 582
- Joined: Sat Aug 10, 2013 13:08
- GitHub: davisonio
- IRC: davisonio
- In-game: CraigyDavi
- Location: Hampshire, UK
- Contact:
Re:
A crash occurs when someone uses the percentage sign (%) in the chat.
For anyone wanting to use this mod, you could use this code instead to fix it:
For anyone wanting to use this mod, you could use this code instead to fix it:
Code: Select all
local chatlog = minetest.get_worldpath().."/chatlog.txt"
function playerspeak(name,msg)
f = io.open(chatlog, "a")
f:write(os.date("(%m/%d/%y %X) [")..name.."]: "..msg.."\n")
f:close()
end
minetest.register_on_chat_message(playerspeak)
- Hybrid Dog
- Member
- Posts: 2852
- Joined: Thu Nov 01, 2012 12:46
- GitHub: HybridDog
Re: Re:
thanksCraigyDavi wrote:A crash occurs when someone uses the percentage sign (%) in the chat.
For anyone wanting to use this mod, you could use this code instead to fix it:Code: Select all
local chatlog = minetest.get_worldpath().."/chatlog.txt" function playerspeak(name,msg) f = io.open(chatlog, "a") f:write(os.date("(%m/%d/%y %X) [")..name.."]: "..msg.."\n") f:close() end minetest.register_on_chat_message(playerspeak)
- Linuxdirk
- Member
- Posts: 3246
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: [Mod] Chat log [chatlog]
Can we have %Y-%m-%dT%X (or a minetest.conf option) to be ISO compliant? :)
- Krock
- Developer
- Posts: 4683
- Joined: Thu Oct 03, 2013 07:48
- GitHub: SmallJoker
- Location: Switzerland
- Contact:
Re: [Mod] Chat log [chatlog]
How about:
Code: Select all
os.date("%x") -> date
os.date("%x %X") -> date time
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>
Re: [Mod] Chat log [chatlog]
Hi all,
Also instead of the line:
One could use the following two lines:
This way, the chat will be saved in daily files (several separated smaller files, one file for each day, in an ordinal and easy to find way), instead of a very big file.
Note: The files will be inside a new directory (a subdirectory) named "chatlog", inside the "worlds/nameOfTheMap" directory.
You need to add some code to create the "chatlog" subdirectory for the first time (before starting the server), or you create it manually (otherwise there will be an error).
Well, just an idea, and trying to share it. :)
Regards,
Also instead of the line:
Code: Select all
local chatlog = minetest.get_worldpath().."/chatlog.txt"
Code: Select all
local chatdate = (os.date("%Y%m%d")) --chatdate will be, for example, 20150127.txt -->> YYYY MM DD (year month day)
local chatlog = minetest.get_worldpath().."/chatlog/"..chatdate..".txt"
Note: The files will be inside a new directory (a subdirectory) named "chatlog", inside the "worlds/nameOfTheMap" directory.
You need to add some code to create the "chatlog" subdirectory for the first time (before starting the server), or you create it manually (otherwise there will be an error).
Well, just an idea, and trying to share it. :)
Regards,
- Linuxdirk
- Member
- Posts: 3246
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: [Mod] Chat log [chatlog]
Since this mod is CC0 and I like the idea of a chat logfile I created my own version of this mod basing on the same idea. I release my version also under CC0.
A default chatlog line is [%date%] <%name%> %message% … where %date%, %name% and %message% get replaced with the actual date, name and message of the chat line being processed. The default file name is chatlog.%Y-%m-%d.log within the world directory.
Since Lua does not have a function to create folders without loading additional modules (which is insecure because the modules in question might not be installed) or system calls (which are not portable between different operating systems) it is not possible to create sub-directories for log files (except you create them manually beforehand).
Changing the default variables is possible in two locations the first location is in init.lua itself in the section “Default values” but that is not desirable (because one should always separate code and configuration). The second and better solution is to define them in your server’s configuration file or the minetest.conf file.
chatlog_logfile_name allows changing the logfile’s file name. You can use the known date variables here (But as described before: no sub-directories except you create them manually). With chatlog_date_string you describe how the date should be represented in the single chatlog entries. And chatlog_line_format defines the actual chatlog lines.
For chatlog_line_format three additional variables are available: %date% gets replaced by the date defined via chatlog_date_string or its default value, %name% gets replaced with the name of the user sending the chat message and %message% gets replaced with the message itself. Other variables are not being replaced.
Code: Select all
-- Helper function for loading optional values
local function getValid(value, default)
v = minetest.setting_get(value)
return (v == nil and default or v)
end
-- Default values
local defaultFile = 'chatlog.%Y-%m-%d.log'
local defaultDate = '%X'
local defaultLine = '[%date%] <%name%> %message%\n'
-- Read values from minetest.conf or set default values
chatlogFilename = getValid('chatlog_logfile_name', defaultFile)
chatlogDateString = getValid('chatlog_date_string', defaultDate)
chatlogLineFormat = getValid('chatlog_line_format', defaultLine)
function chatlogWriteLine(name, message)
local logfileName = os.date(chatlogFilename)
local line = chatlogLineFormat
line = line:gsub('%%date%%', os.date(chatlogDateString))
line = line:gsub('%%name%%', name)
line = line:gsub('%%message%%', message)
f = io.open(minetest.get_worldpath()..'/'..logfileName, 'a')
f:write(line)
f:close()
end
minetest.register_on_chat_message(chatlogWriteLine)
Since Lua does not have a function to create folders without loading additional modules (which is insecure because the modules in question might not be installed) or system calls (which are not portable between different operating systems) it is not possible to create sub-directories for log files (except you create them manually beforehand).
Changing the default variables is possible in two locations the first location is in init.lua itself in the section “Default values” but that is not desirable (because one should always separate code and configuration). The second and better solution is to define them in your server’s configuration file or the minetest.conf file.
chatlog_logfile_name allows changing the logfile’s file name. You can use the known date variables here (But as described before: no sub-directories except you create them manually). With chatlog_date_string you describe how the date should be represented in the single chatlog entries. And chatlog_line_format defines the actual chatlog lines.
For chatlog_line_format three additional variables are available: %date% gets replaced by the date defined via chatlog_date_string or its default value, %name% gets replaced with the name of the user sending the chat message and %message% gets replaced with the message itself. Other variables are not being replaced.
- QwertyDragon
- Member
- Posts: 20
- Joined: Sat Dec 24, 2016 15:37
- Contact:
Re: [Mod] Chat log [chatlog]
I am using Linuxdirk's version:
Minetest 0.4.15 self compiled run-in-place on Ubuntu 14.04
And had a server crash with this error:
I do not understand what the error is really pointing to.
Tried to reproduce by typing "%" and every other character in chat, but crash does not reproduce for me. So it does not seem like it happens by user typing % or anything. I like this mod and would like to keep using it, unless there is a better option.
Anyone have any suggestions?
Code: Select all
-- Helper function for loading optional values
local function getValid(value, default)
v = minetest.setting_get(value)
return (v == nil and default or v)
end
-- Default values
local defaultFile = 'chatlog.%Y-%m-%d.log'
local defaultDate = '%X'
local defaultLine = '[%date%] <%name%> %message%\n'
-- Read values from minetest.conf or set default values
chatlogFilename = getValid('chatlog_logfile_name', defaultFile)
chatlogDateString = getValid('chatlog_date_string', defaultDate)
chatlogLineFormat = getValid('chatlog_line_format', defaultLine)
function chatlogWriteLine(name, message)
local logfileName = os.date(chatlogFilename)
local line = chatlogLineFormat
line = line:gsub('%%date%%', os.date(chatlogDateString))
line = line:gsub('%%name%%', name)
line = line:gsub('%%message%%', message)
f = io.open(minetest.get_worldpath()..'/'..logfileName, 'a')
f:write(line)
f:close()
end
minetest.register_on_chat_message(chatlogWriteLine)
And had a server crash with this error:
Code: Select all
2017-02-13 02:09:42: ERROR[Main]: ServerError: Lua: Runtime error from mod 'chatlog' in callback on_chat_message(): .../STABLE/minetest/bin/../mods/chatlog/init.lua:24: invalid capture index
2017-02-13 02:09:42: ERROR[Main]: stack traceback:
2017-02-13 02:09:42: ERROR[Main]: [C]: in function 'gsub'
2017-02-13 02:09:42: ERROR[Main]: /STABLE/minetest/bin/../mods/chatlog/init.lua:24: in function <.../STABLE/minetest/bin/../mods/chatlog/init.lua:19>
2017-02-13 02:09:42: ERROR[Main]: .../STABLE/minetest/bin/../builtin/game/register.lua:412: in function <.../STABLE/minetest/bin/../builtin/game/register.lua:392>
Tried to reproduce by typing "%" and every other character in chat, but crash does not reproduce for me. So it does not seem like it happens by user typing % or anything. I like this mod and would like to keep using it, unless there is a better option.
Anyone have any suggestions?
My GitLab, and Obior pages, and YouTube as QuixoticalPig, and Twitter as vuvvobUd. irc as QwertyDragon
- Linuxdirk
- Member
- Posts: 3246
- Joined: Wed Sep 17, 2014 11:21
- In-game: Linuxdirk
- Location: Germany
- Contact:
Re: [Mod] Chat log [chatlog]
Can’t reproduce with the version provided by Arch Linux.
Code: Select all
$ minetest --version
Minetest 0.4.15 (Linux)
Using Irrlicht 1.8.4
Build info: VER=0.4.15 BUILD_TYPE=Release RUN_IN_PLACE=0 USE_GETTEXT=1 USE_SOUND=1 USE_CURL=1 USE_FREETYPE=1 USE_LUAJIT=1 STATIC_SHAREDIR="/usr/share/minetest"
$ lua5.2 -v
Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio
$ luajit -v
LuaJIT 2.0.4 -- Copyright (C) 2005-2015 Mike Pall. http://luajit.org/
$ uname -rms
Linux 4.9.6-1-ARCH x86_64
Re: [Mod] Chat log [chatlog]
This mod works great. One thing though, please add the players joining and leaving in the logs. Thanks.
Ignore my old posts.
- AntumDeluge
- Member
- Posts: 215
- Joined: Sun Aug 07, 2016 05:42
- GitHub: AntumDeluge
- IRC: AntumDeluge
- Contact:
Re: [Mod] Chat log [chatlog]
Created GitHub repo for this.
Re: [Mod] Chat log [chatlog]
Hi,
This mod is very USEFUL!!!
Thanks...
I have one question: is possible to add the ip of the players like: <IP> <USER> <TIME-DATE> <message> ?
Thanks again for all...
R
This mod is very USEFUL!!!
Thanks...
I have one question: is possible to add the ip of the players like: <IP> <USER> <TIME-DATE> <message> ?
Thanks again for all...
R