Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes issue #27 - Don't show commands as a part of mainchat history. [WIP] #13

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions chatlogger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,42 @@
function OnStartup()
tConfig, tChatHistory = {
sBotName = SetMan.GetString( 21 ) or "PtokaX",
sProfiles = "012", -- No history for commands from users with profiles
sLogsPath = "/www/ChatLogs/",
tCommands = {
"history", "help", "custhelp", "me", "report", "topic", "say", "kick", "ban", "banip",
"fullban", "fullbanip", "nickban", "tempban", "tempbanip", "fulltempban", "fulltempbanip",
"nicktempban", "getblocks", "getmyblocks", "unban", "permunban", "tempunban", "getbans",
"getpermbans", "gettempbans", "clrpermbans", "clrtempbans", "rangeban", "fullrangeban",
"rangetempban", "fullrangetempban", "rangeunban", "rangepermunban", "rangetempunban",
"getrangebans", "getrangepermbans", "getrangetempbans", "clrrangepermbans",
"clrrangetempbans", "checknickban", "checkipban", "checkrangeban", "getpass",
"clrpassbans", "startscript", "stopscript", "restartscript", "restartscripts",
"getscripts", "reloadtxt", "restart", "hubtopic", "passwd", "warn", "send",
"revertnick", "changenick", "mute", "block", "unblock", "desu", "san", "chan", "sub",
"foreveralone", "nomorealone", "getprofiles", "unsub", "unmute", "drop", "getinfo",
"op", "gag", "ungag", "changereg", "addreguser", "delreguser", "massmsg", "opmassmsg", "myip",
},
iMaxLines = 100,
}, { "Hi!" }
end

CustomCommands = {}
for _, comm in ipairs(tConfig.tCommands) do
CustomCommands[comm] = true
end

function ChatArrival( tUser, sMessage )
LogMessage( sMessage:sub(1, -2) )
local sCmd, sData = sMessage:match( "%b<> [-+*/?!#](%w+)%s?(.*)|" )
local sTime = os.date( "%I:%M:%S %p" )
local sChatLine = "["..sTime.."] "..sMessage:sub( 1, -2 )
if not( sCmd and tConfig.sProfiles:find(tUser.iProfile) ) then
if not CustomCommands[sCmd] then
table.insert( tChatHistory, sChatLine )
if tChatHistory[tConfig.iMaxLines + 1] then
table.remove( tChatHistory, 1 )
end
end
if sCmd then
if CustomCommands[sCmd] then
return ExecuteCommand( sCmd:lower(), sData, tUser )
end
return false
Expand Down