Hi, this might sound like a silly request, but is there any way to add colour to scripts??
i.e I run to games (triv and anagrams) would it be possible to have 1 game in a differant colour?
if everyone runs bcdc++ and a modified version of formatting.lua that recognises and colorizes your two games, it's possible
hi i found this script,is there any way it can be altered to work on sorton scripts and on all clients??
code:--------------------------------------------------------------------------------
--// vim:ts=4:sw=4:noet
-- use a namespace because we are in a global environment
formatting = {}
formatting.color = {}
--// ** edit below this line ** //-
-- set this to something other than nil if you have a dark background (it will invert the colors below)
formatting.background_is_dark = nil
-- use the following colors
formatting.color.normal = "cyan"; -- someone else's line
formatting.color.nick = "red"; -- my line: nick color
formatting.color.myline = "red"; -- my line: text color
formatting.color.mynick = "yellow"; -- someone else's line (contains my nick)
formatting.color.time = "gray";
formatting.color.link = "blue";
formatting.color.op = "darkyellow";
-- use this to match other nicknames than your own
formatting.also_match_nicks = { }; -- { "other", "nicks" }
--// ** do not edit below this line ** //--
-- heh!
function FormatChatText( hub, text )
local txtcolor = formatting.color.normal
local timecolor = formatting.color.time
local namecolor = formatting.color.normal
if (not text) then
DC():PrintDebug("FormatChatText: text == nil");
return nil;
end
-- escape chars
text = string.gsub( string.gsub( text, "([{}\\])", "\\%1" ), "\n", "\\line\n" )
if dcpp:hasHub( hub ) and dcpp:getHub( hub ):hasOwnNick() then
local hub = dcpp:getHub( hub )
local mynick = hub:getOwnNick()
local sNickOutput = "";
-- capture normal chat
local ret,c,pre,nick,post = string.find( text, "^(.-)<([^> ]+)>(.*)$" );
if (not ret) then -- capture !me speak
ret,c,pre,nick,post = string.find( text, "^(.-)%*%s*(%S+)(.*)$");
sNickOutput = "* \\b "..nick.."\\b0 ";
else
sNickOutput = "<\\b "..nick.."\\b0 >";
end
if (ret) then -- chat and !me, nothing abnormal
if mynick == nick then -- my line
txtcolor = formatting.color.myline
namecolor = formatting.color.nick;
elseif formatting.testMyNick( post, mynick ) then -- not my line, contains my nick
txtcolor = formatting.color.mynick
timecolor = formatting.color.mynick
end
if mynick ~= nick and hub:isOp( nick ) then
namecolor = formatting.color.op;
end
text = pre.."\\cf3 "..sNickOutput.."\\cf1 "..post;
end
end
-- colorize timestamp
text = string.gsub( text, "^(.\\line\n)(%[[0-9:]+%])", "%1\\cf4 %2\\cf1 " )
-- em
text = string.gsub( text, "(%s)(_%S+_)$", "%1\\ul %2\\ul0 " )
text = string.gsub( text, "(%s)(_%S+_)(%s)", "%1\\ul %2\\ul0 %3" )
text = string.gsub( text, "(%s)(*%S+*)$", "%1\\b %2\\b0 " )
text = string.gsub( text, "(%s)(*%S+*)(%s)", "%1\\b %2\\b0 %3" )
text = string.gsub( text, "(%s)(/[^/]+/)$", "%1\\i %2\\i0 " )
text = string.gsub( text, "(%s)(/[^/]+/)(%s)", "%1\\i %2\\i0 %3" )
-- colorize links
text = string.gsub( text, "([ <\t\r\n])(dchub://[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
text = string.gsub( text, "([ <\t\r\n])(//http://[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
text = string.gsub( text, "([ <\t\r\n])(www\.[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
text = string.gsub( text, "([ <\t\r\n])(//ftp://[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
--
DC():PrintDebug( "3>"..text )
return "{\\rtf1\\ansi\\deff0\\plain0\n"..
"{\\colortbl ;"..txtcolor..formatting.color.link..namecolor..timecolor.."}\n"..
"\\cf1 "..text.."}\n"
end
-- color conversion types
formatting.color_conversion = {}
formatting.color_conversion.black = {0, 0, 0}
formatting.color_conversion.white = {255, 255, 255}
formatting.color_conversion.gray = {127, 127, 127}
formatting.color_conversion.red = {255, 0, 0}
formatting.color_conversion.green = {0, 255, 0}
formatting.color_conversion.blue = {0, 0, 255}
formatting.color_conversion.yellow = {255, 255, 0}
formatting.color_conversion.magenta = {255, 0, 255}
formatting.color_conversion.cyan = {0, 255, 255}
-- dark variants
formatting.color_conversion.darkgray = {63, 63, 63}
formatting.color_conversion.darkred = {127, 0, 0}
formatting.color_conversion.darkgreen = {0, 127, 0}
formatting.color_conversion.darkblue = {0, 0, 127}
formatting.color_conversion.darkyellow = {127, 127, 0}
formatting.color_conversion.darkmagenta = {127, 0, 127}
formatting.color_conversion.darkcyan = {0, 127, 127}
-- aliases
formatting.color_conversion.brown = formatting.color_conversion.darkyellow
formatting.color_conversion.grey = formatting.color_conversion.gray
formatting.color_conversion.darkgrey = formatting.color_conversion.darkgray
-- convert colors..
for k,v in formatting.color do
if formatting.color_conversion[v] then
local c = formatting.color_conversion[v]
formatting.color[k] = "\\red"..c[1].."\\green"..c[2].."\\blue"..c[3]..";"
end
end
-- invert colors..
if formatting.background_is_dark then
DC():PrintDebug( "hier" )
for k,v in formatting.color do
DC():PrintDebug( "hierv:"..v )
local ret,c,r,g,b = string.find( v, "^\\red(%d+)\\green(%d+)\\blue(%d+);$" )
if ret then
formatting.color[k] = "\\red"..(255-tonumber(r))..
"\\green"..(255-tonumber(g))..
"\\blue"..(255-tonumber(b))..";"
DC():PrintDebug( "hierv="..formatting.color[k] )
end
end
end
-- escape also_match_nicks
for k,v in formatting.also_match_nicks do
formatting.also_match_nicks[k] = string.gsub( string.lower( v ), "([^a-z0-9])", "%%%1" )
end
function formatting.testMyNick( text, nick )
text = string.lower( text )
-- test also_match_nicks first
for k,v in formatting.also_match_nicks do
if string.find( text, "[^a-z]"..v.."[^a-z]" ) or string.find( text, "[^a-z]"..v.."$" ) then
return 1
end
end
-- ok.. not found.. try our hub specific nick
nick = string.lower( nick )
local enick = nil
local enick_notag = string.gsub( nick, "%[.*%]", "" )
if enick_notag ~= "" then
enick = string.gsub( enick_notag, "([^a-z0-9])", "%%%1" )
else
enick = string.gsub( nick, "([^a-z0-9])", "%%%1" )
end
if string.find( text, "[^a-z]"..enick.."[^a-z]" ) or string.find( text, "[^a-z]"..enick.."$" ) then
return 1
end
end
DC():PrintDebug( " ** Loaded formatting.lua **" )
that's a really old version of formatting.lua you got there. I suggest you fetch a newer one first.
after that, it's a matter of:
1) adding something unique to the output of the question and the answer
e.g. for every SendToAll and SendToNick, prepend either "[AnaQue]" or "[AnaAns]".
2) adding a check in formatting.lua for these strings,
e.g. Index: formatting.lua
===================================================================
--- formatting.lua (revision 623)
+++ formatting.lua (working copy)
@@ -52,6 +52,10 @@
end
elseif formatting.testPartnerLine( text ) then
txtcolor = formatting.color.partner
+ elseif string.find( text, "[AnaAns]", 1, 1 ) then
+ txtcolor = formatting.color.anaans
+ elseif string.find( text, "[AnaQue]", 1, 1 ) then
+ txtcolor = formatting.color.anaque
end
-- escape chars
text = string.gsub( text, "([{}\\])", "\\%1" )
@@ -216,6 +220,8 @@
if not formatting_opt.color.nick then formatting_opt.color.nick = "darkred" end
if not formatting_opt.color.partner then formatting_opt.color.partner = "darkmagenta" end
if not formatting_opt.color.noise then formatting_opt.color.noise = "darkgray" end
+ if not formatting_opt.color.anaans then formatting_opt.color.anaans = "darkgreen" end
+ if not formatting_opt.color.anaque then formatting_opt.color.anaque = "blue" end
if not formatting_opt.also_match_nicks then formatting_opt.also_match_nicks = {} end
end
thx for your help m8, but im not very good at putting scripts together any chance someone could help me out here.......i want the game scripted altered or redone so that questions and answers appear in differant colours
help is most appreciated : ))
ok thx bastya_elvtars got that ...
so how do i compille this to add colours to the game i asked about before cause i dont have a clue on where i would start such a thing??
That's the hole script.
I hope you guys can help :)
I was told that this formating lua could be altered so for dc++ ..... can some1 help me out here plz
i have no idea where to start
--// vim:ts=4:sw=4:noet
-- use a namespace because we are in a global environment
formatting = {}
-- load pickle functions
dofile("scripts/libsimplepickle.lua")
formatting.settings_file = "scripts/formatting_settings.txt"
-- every new line starts with the following, because of the multiline-URL-fix-hack
formatting.input_start = " "
-- regexes that should be considered noise
formatting.noise = {
-- NMDC Kick
"^"..formatting.input_start.."\r\n[0-9:%[%] ]*<[^> ]+> [^ ]+ is kicking [^ ]+ because",
-- DCH++ Banuser/Bannick/Banip
"^"..formatting.input_start.."\r\n[0-9:%[%] ]*<[^> ]+> [^ ]+ banned [^ ]+ by ip [^ ]+ and nick %(",
"^"..formatting.input_start.."\r\n[0-9:%[%] ]*<[^> ]+> [^ ]+ banned [0-9.]+ %(",
"^"..formatting.input_start.."\r\n[0-9:%[%] ]*<[^> ]+> [^ ]+ banned [^ ]+ by nick %(",
-- YHub Kick
"^"..formatting.input_start.."\r\n[0-9:%[%] ]*<[^> ]+> [^ ]+, IP: [0-9.]+ was kicked",
-- ADC test commands
"^"..formatting.input_start.."\r\n[0-9:%[%] ]*
.*$",
-- p14nd4's join/part noise add
"^"..formatting.input_start.."\r\n[0-9:%[%] ]*** Joins: [^ ]",
"^"..formatting.input_start.."\r\n[0-9:%[%] ]*** Parts: [^ ]",
}
function dcpp.FormatChatText( hub, text )
local txtcolor = formatting.color.normal
local timecolor = formatting.color.time
local nickcolor = formatting.color.nick
if formatting.isNoise( text ) then
-- escape chars
text = string.gsub( text, "([{}\\])", "\\%1" )
text = string.gsub( text, "\r\n", "\n" )
text = string.gsub( text, "\n", "\\line\n" )
txtcolor = formatting.color.noise
elseif dcpp:hasHub( hub ) and dcpp:getHub( hub ):getOwnNick() then
local hub = dcpp:getHub( hub )
local mynick = hub:getOwnNick()
if formatting.testMyLine( text, mynick ) then
txtcolor = formatting.color.self
formatting.findChatPartner( hub, text )
elseif formatting.testMyNick( text, mynick ) then
txtcolor = formatting.color.myname
timecolor = formatting.color.myname
if formatting.flash_on_myname then
hub:attention()
end
elseif formatting.testPartnerLine( text ) then
txtcolor = formatting.color.partner
end
-- escape chars
text = string.gsub( text, "([{}\\])", "\\%1" )
text = string.gsub( text, "\r\n", "\n" )
text = string.gsub( text, "\n", "\\line\n" )
-- colorize OPs
local ret,c,pre,nick,post = string.find( text,
"^("..formatting.input_start.."\\line\n[0-9:,%a%s%[%]]*<)([^> ]+)(>.*)$" )
if ret then
text = string.sub( pre, 1, -2 ).."\\cf3 <"..nick..">\\cf1 "..string.sub( post, 2 )
--text = string.sub( pre, 1, -2 ).."\\cf3 <\\b "..nick.."\\b0 >\\cf1 "..string.sub( post, 2 )
if hub:isOp( nick ) then
nickcolor = formatting.color.op
end
end
else
-- escape chars
text = string.gsub( text, "([{}\\])", "\\%1" )
text = string.gsub( text, "\r\n", "\n" )
text = string.gsub( text, "\n", "\\line\n" )
end
-- colorize timestamp
text = string.gsub( text, "^("..formatting.input_start.."\\line\n)(%[[0-9:,%s%a]*%])", "%1\\cf4 %2\\cf1 " )
-- em
text = string.gsub( text, "(%s)(_%S+_)$", "%1\\ul %2\\ul0 " )
text = string.gsub( text, "(%s)(_%S+_)(%s)", "%1\\ul %2\\ul0 %3" )
text = string.gsub( text, "(%s)(*%S+*)$", "%1\\b %2\\b0 " )
text = string.gsub( text, "(%s)(*%S+*)(%s)", "%1\\b %2\\b0 %3" )
text = string.gsub( text, "(%s)(/[^/\r\n\t]+/)$", "%1\\i %2\\i0 " )
text = string.gsub( text, "(%s)(/[^/\n\n\t]+/)(%s)", "%1\\i %2\\i0 %3" )
-- colorize links
text = string.gsub( text, "([ <\t\r\n])(dchub://[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
text = string.gsub( text, "([ <\t\r\n])(//http://[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
text = string.gsub( text, "([ <\t\r\n])(//https://[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
text = string.gsub( text, "([ <\t\r\n])(www\.[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
text = string.gsub( text, "([ <\t\r\n])(//ftp://[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
text = string.gsub( text, "([ <\t\r\n])(magnet:%?[^ \t\\>]+)", "%1\\ul\\cf2 %2\\cf1\\ul0 " )
text = string.gsub( text, "([ <\t\r\n])(irc://[^ \t\\>]+)","%1\\ul\\cf2 %2\\cf1\\ul0 " )
return "{\\urtf1\\ansi\\ansicpg1252\\deff0\\plain0\n"..
"{\\colortbl ;"..txtcolor..formatting.color.link..nickcolor..timecolor.."}\n"..
"\\cf1 "..text.."}\n"
end
-- time data
formatting.time = {}
formatting.time.partners = {}
-- color conversion types
formatting.color_conversion = {}
formatting.color_conversion.black = {0, 0, 0}
formatting.color_conversion.white = {255, 255, 255}
formatting.color_conversion.gray = {127, 127, 127}
formatting.color_conversion.red = {255, 0, 0}
formatting.color_conversion.green = {0, 255, 0}
formatting.color_conversion.blue = {0, 0, 255}
formatting.color_conversion.yellow = {255, 255, 0}
formatting.color_conversion.magenta = {255, 0, 255}
formatting.color_conversion.cyan = {0, 255, 255}
-- dark variants
formatting.color_conversion.darkgray = {63, 63, 63}
formatting.color_conversion.darkred = {127, 0, 0}
formatting.color_conversion.darkgreen = {0, 127, 0}
formatting.color_conversion.darkblue = {0, 0, 127}
formatting.color_conversion.darkyellow = {127, 127, 0}
formatting.color_conversion.darkmagenta = {127, 0, 127}
formatting.color_conversion.darkcyan = {0, 127, 127}
-- aliases
formatting.color_conversion.brown = formatting.color_conversion.darkyellow
formatting.color_conversion.grey = formatting.color_conversion.gray
formatting.color_conversion.darkgrey = formatting.color_conversion.darkgray
formatting.color_conversion.lightgrey = formatting.color_conversion.lightgray
-- convert colors..
function formatting.setColors()
formatting.color = {}
for k,v in formatting_opt.color do
if formatting.color_conversion[v] then
local c = formatting.color_conversion[v]
formatting.color[k] = "\\red"..c[1].."\\green"..c[2].."\\blue"..c[3]..";"
else
formatting.color[k] = v
end
-- optionally invert color
if formatting.background_is_dark then
local ret,c,r,g,b = string.find( formatting.color[k], "^\\red(%d+)\\green(%d+)\\blue(%d+);$" )
if ret then
formatting.color[k] = "\\red"..(255-tonumber(r))..
"\\green"..(255-tonumber(g))..
"\\blue"..(255-tonumber(b))..";"
end
end
end
end
-- set "also match nicks"
function formatting.setAlsoMatchNicks()
formatting.also_match_nicks = {}
for k,v in formatting_opt.also_match_nicks do
formatting.also_match_nicks[k] = string.gsub( string.lower( v ), "([^%l%d])", "%%%1" )
end
end
-- set other options
function formatting.setOtherOptions()
local function test( b )
b = string.lower( tostring( b ) )
if b == "nil" or b == "0" or b == "off" or b == "no" then return nil
else return 1
end
end
formatting.flash_on_myname = test( formatting_opt.flash_on_myname )
formatting.background_is_dark = test( formatting_opt.background_is_dark )
end
function formatting.setOptions()
formatting.setDefaultOptions()
formatting.setOtherOptions()
formatting.setColors()
formatting.setAlsoMatchNicks()
end
function formatting.setDefaultOptions()
if not formatting_opt then formatting_opt = {} end
if not formatting_opt.background_is_dark then
local bgcolor = DC():GetSetting( "BackgroundColor" ) -- BACKGROUND_COLOR (IntSetting)
local R = math.mod( bgcolor, 256 )
local G = math.mod( bgcolor / 256, 256 )
local B = math.mod( bgcolor / 256 / 256, 256 )
if R + G + B < 384 then
formatting_opt.background_is_dark = 1
else
formatting_opt.background_is_dark = 0
end
end
if not formatting_opt.flash_on_myname then formatting_opt.flash_on_myname = 0 end
if not formatting_opt.color then formatting_opt.color = {} end
if not formatting_opt.color.normal then formatting_opt.color.normal = "black" end
if not formatting_opt.color.self then formatting_opt.color.self = "red" end
if not formatting_opt.color.myname then formatting_opt.color.myname = "darkgreen" end
if not formatting_opt.color.time then formatting_opt.color.time = "darkgray" end
if not formatting_opt.color.link then formatting_opt.color.link = "blue" end
if not formatting_opt.color.op then formatting_opt.color.op = "blue" end
if not formatting_opt.color.nick then formatting_opt.color.nick = "darkred" end
if not formatting_opt.color.partner then formatting_opt.color.partner = "darkmagenta" end
if not formatting_opt.color.noise then formatting_opt.color.noise = "darkgray" end
if not formatting_opt.also_match_nicks then formatting_opt.also_match_nicks = {} end
end
function formatting.save()
formatting.setOptions()
pickle.store( formatting.settings_file, {formatting_opt = formatting_opt} )
end
function formatting.load()
local o = io.open( formatting.settings_file, "r" )
if o then
dofile( formatting.settings_file )
o:close()
end
formatting.setOptions()
end
--/////////////////////////////////--
--// chatline matching functions //--
--/////////////////////////////////--
function formatting.testMyLine( text, nick )
if string.find( text, "<"..nick.."> ", 1, 1 ) then
return 1
end
end
function formatting.testPartnerLine( text )
local now = os.time()
local ret = nil
for k,v in formatting.time.partners do
if string.find( text, "<"..k.."> ", 1, 1 ) then
ret = 1
formatting.time.partners[k] = now -- re-enforce user speaking
else
if now - v > 60*10 then -- expire after 10 mins
formatting.time.partners[k] = nil
end
end
end
return ret
end
function formatting.testMyNick( text, nick )
text = string.lower( text )
-- test also_match_nicks first
for k,v in formatting.also_match_nicks do
if string.find( text, "[^%l]"..v.."[^%l]" ) or string.find( text, "[^%l]"..v.."$" ) then
return 1
end
end
-- ok.. not found.. try our hub specific nick
nick = string.lower( nick )
local enick = nil
local enick_notag = string.gsub( nick, "%[.*%]", "" )
if enick_notag ~= "" then
enick = string.gsub( enick_notag, "([^a-z0-9])", "%%%1" )
else
enick = string.gsub( nick, "([^a-z0-9])", "%%%1" )
end
if string.find( text, "[^a-z]"..enick.."[^a-z]" ) or string.find( text, "[^a-z]"..enick.."$" ) then
return 1
end
end
function formatting.findChatPartner( hub, text )
local ret,c,nick = string.find( text, "> ([%[%]%a%d_-]+)" )
if not ret then return end
local notag = nil
if not string.find( nick, "[%[%]]" ) then notag = 1 end
-- iterate through hub nicks to find someone,
-- if we didn't check user existence, we'd store a heck of a lot of words
local list = hub:findUsers( nick, notag )
local now = os.time()
for k,v in list do
formatting.time.partners[v:getNick()] = now
end
end
function formatting.isNoise( text )
for k,v in formatting.noise do
if string.find( text, v ) then
return 1
end
end
end
--//////////////////////////////--
function formatting.tokenize( str )
local ret = {}
string.gsub( str, "(%w+)", function( s ) table.insert( ret, s ) end )
return ret
end
here is rest of that script ......
dcpp:setListener( "ownChatOut", "formatting",
function( hub, text )
if string.sub( text, 1, 1 ) ~= "/" then return end
parms = formatting.tokenize( string.sub( string.lower( text ), 2 ) )
if parms[1] == "help" then
hub:injectChat( "*** (formatting.lua) /color [what] [color], /flash [on/off], "..
"/highlight [add/del] [nick], /invert [on/off]" )
return 1
elseif parms[1] == "flash" then
if parms[2] == "on" then
formatting_opt.flash_on_myname = 1
formatting.save()
hub:injectChat( "*** Flash on your nick enabled" )
elseif parms[2] == "off" then
formatting_opt.flash_on_myname = 0
formatting.save()
hub:injectChat( "*** Flash on your nick disabled" )
else
hub:injectChat( "*** /flash (parameters: 'on' or 'off'): "..
"When enabled, the BCDC++ window flashes when someone calls you in main chat." )
end
return 1
elseif parms[1] == "invert" then
if parms[2] == "on" then
formatting_opt.background_is_dark = 1
formatting.save()
hub:injectChat( "*** Invert colors enabled")
elseif parms[2] == "off" then
formatting_opt.background_is_dark = 0
formatting.save()
hub:injectChat( "*** Invert colors disabled" )
else
hub:injectChat( "*** /invert (parameters: 'on' or 'off'): "..
"When enabled, the main chat colors are inverted, useful when there's "..
"low contrast between the chat colors and background (e.g. if you have a "..
"black background). "..
"As an alternate option, you can set the colors manually as you like by "..
"using /color, see /help." )
end
return 1
elseif parms[1] == "color" then
if parms[2] == "show" then
-- show current settings
local msg = "*** The current color set is the following:"
for k,v in formatting_opt.color do
msg = msg.. "\r\n*"..k..":* "..v
end
hub:injectChat( msg )
elseif not parms[2] or not parms[3] then
local msg = "*** /color (parameters: and ): "..
"Use this to change the colors used in the chat.\r\n"..
"Available color-identifiers to set ():\r\n"..
" normal = the normal text color\r\n"..
" self = lines you speak\r\n"..
" myname = lines where your name is used (someone calling you)\r\n"..
" time = the timestamp\r\n"..
" link = URLs (clickable links)\r\n"..
" op = the nickname of an operator (the one between angle brackets)\r\n"..
" nick = the nickname of normal people\r\n"..
" partner = lines someone with whom you spoke recently\r\n"..
" noise = kick messages\r\n"..
"Available colors ():\r\n "
for k,v in formatting.color_conversion do
msg = msg..k..", "
end
msg = string.sub( msg, 1, -3 )
msg = msg.."\r\nUse \"/color show\" to get the current color set displayed."
hub:injectChat( msg )
else
if formatting_opt.color[parms[2]] then
if formatting.color_conversion[parms[3]] then
formatting_opt.color[parms[2]] = parms[3];
formatting.save()
hub:injectChat( "*** /color -- set "..parms[2].." to "..parms[3] )
else
hub:injectChat( "*** /color -- invalid " )
end
else
hub:injectChat( "*** /color -- invalid " )
end
end
return 1
elseif parms[1] == "highlight" then
if not parms[2] or not parms[3] then
local msg = "*** /highlight (parameters: 'add' or 'del' and ): "..
"Adds or removes words to match for highlighting besides your own name. "..
"E.g. use \"/highlight add operator\" to let BCDC++ highlight lines that "..
"include the word \"operator\".\r\n"..
"Currently matched words:\r\n "
for k,v in formatting_opt.also_match_nicks do
msg = msg..v..", "
end
hub:injectChat( string.sub( msg, 1, -3 ) )
elseif parms[2] == "add" then
for k,v in formatting_opt.also_match_nicks do
if string.lower( v ) == parms[3] then
hub:injectChat( "*** /highlight -- "..parms[3].." exists already" )
return 1
end
end
table.insert( formatting_opt.also_match_nicks, parms[3] )
formatting.save()
hub:injectChat( "*** Highlight, added: "..parms[3] )
elseif parms[2] == "del" then
local rm = nil
for k,v in formatting_opt.also_match_nicks do
if string.lower( v ) == parms[3] then
table.remove( formatting_opt.also_match_nicks, k )
rm = 1
end
end
if rm then
formatting.save()
hub:injectChat( "*** Highlight, removed: "..parms[3] )
else
hub:injectChat( "*** /highlight -- "..parms[3].." didn't exist" )
end
else
hub:injectChat( "*** /highlight -- "..parms[2].." is not a switch" )
end
return 1
end
end
)
-- load saved settings
formatting.load()
formatting.save() -- recreate settings file
DC():PrintDebug( " ** Loaded formatting.lua **" )