gmcp.Comm.Channel - chat capture

Post Reply
Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

gmcp.Comm.Channel - chat capture

Post by Caled »

That's a lot of events for a clan tell:
clt test
System Message:
GMCP event <gmcp.Comm> display(gmcp) to see the full content
System Message:
GMCP event <gmcp.Comm.Channel> display(gmcp) to see the full content
System Message:
GMCP event <gmcp.Comm.Channel.Text> display(gmcp) to see the full content
System Message:
GMCP event <gmcp.Comm> display(gmcp) to see the full content
System Message:
GMCP event <gmcp.Comm.Channel> display(gmcp) to see the full content
System Message:
GMCP event <gmcp.Comm.Channel.Start> display(gmcp) to see the full content
System Message:
GMCP event <gmcp.Comm> display(gmcp) to see the full content
System Message:
GMCP event <gmcp.Comm.Channel> display(gmcp) to see the full content
System Message:
GMCP event <gmcp.Comm.Channel.End> display(gmcp) to see the full content
Code: [show] | [select all] lua
{
  Channel = {
    Start = "clt8",
    Text = {
      text = "[0;32m(Dark Fire): You say, \"Test.\"[0m[0;37m",
      talker = "Irruel",
      channel = "clt8"
    },
    End = "clt8",
Any suggestions on how to echo the text field to a miniconsole while keeping the colour?
I've created a table to convert ansi codes to colour tags, and experimented with string.find on the ansi codes themselves, but the text still has the backslashes \ escaping the quotes.

I've tried using selectString(line,1) on the gmcp.Comms.Channel.End event, but the line hasn't arrived yet so I just select the prompt before it. I've tried using moveCursor +1 to get the next line, but that can't work as the line doesn't exist yet.

I've tried doing:

gui.chancap_console_All:echo( gmcp.Comm.Channel.Text.text )

But the ansi codes show up in the miniconsole output.

Any hints?

User avatar
demonnic
Posts: 720
Joined: Sat Dec 05, 2009 3:19 pm

Re: gmcp.Comm.Channel - chat capture

Post by demonnic »

Code: [show] | [select all] lua
  local message = gmcp.Comm.Channel
  local color = howeverYouAreTranslatingTheColor()
  local messageText = string.sub(message.Text.text, 10)
  messageText = string.sub(messageText, 1, -8)
  gui.chancap_console_All:cecho(color..messageText)
the string.subs handle stripping the ansi color codes out of the string.

And just because I'm lazy, I'd be interested in that table. I've hand coded values for mine for now but making such a table was on the list. Still trying to figure out gagging the chat line, tempLineTriggers() aren't managing it somehow.

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: gmcp.Comm.Channel - chat capture

Post by Caled »

So, I have it working but have found another stumbling block.

The first thing I every do when I create a new profile, is redefine several of the default ansi colours. I do this because four of them are all but unreadable on a black background. But how do I call those colours so that I am not forcing my personal colour choices on the people that use this script?

So I have:
Code: [show] | [select all] lua
gui.ansiconv = {
	["[0;31m"] = "1",
	["[0;32m"] = "2",
	["[0;33m"] = "3",
	["[0;34m"] = "4",
	["[0;35m"] = "5",
	["[0;36m"] = "6",
	["[0;37m"] = "7",
	["[0;1;30m"] = "8",
	["[0;1;31m"] = "9",
	["[0;1;32"] = "10",
	["[0;1;33m"] = "11",
	["[0;1;34m"] = "12",
	["[0;1;35m"] = "13",
	["[0;1;36m"] = "14",
	["[0;1;37m"] = "15",
}
But I know of no way to set a colour by it's ansi number.

For example, if I could do: fg(2)
(no good as it only takes colour names from showColors() )

Any ideas?

Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Re: gmcp.Comm.Channel - chat capture

Post by Caled »

The script as it currently stands:
(event is: gmcp.Comm.Channel.Text)
Code: [show] | [select all] lua
--capandappend


function gmcp_comm()
	local s = gmcp.Comm.Channel.Text.text
	local leader = 8
	if s:find( "0;1;" ) then leader = leader +2	end

	local col = s:sub(2, leader-1)
	col = gui.ansiconv[col][2]
	s = s:sub(leader)
	s = s:sub(1, -12)

	local channel = gmcp.Comm.Channel.Text.channel
	if 		channel == "web" 		then  gui.chancap_console_Web:cecho("<" .. col .. ">" .. s .. "\n")
	elseif 	channel == "tell"	 	then  gui.chancap_console_Tells:cecho("<" .. col .. ">" .. s .. "\n")
	elseif 	channel == "says"	 	then  gui.chancap_console_Tells:cecho("<" .. col .. ">" .. s .. "\n")
	else												 gui.chancap_console_Orgs:cecho("<" .. col .. ">" .. s .. "\n")
	end


  gui.chancap_console_All:cecho("<" .. col .. ">" .. s .. "\n")
 -- gui.chancap_console_All:cecho(col .. "\n")
end

gui.ansiconv = {
	["[0;31m"] = {"1", "orange"},
	["[0;32m"] = {"2", "dark_green"},
	["[0;33m"] = {"3", "dark_khaki"},
	["[0;34m"] = {"4", "royal_blue"},
	["[0;35m"] = {"5", "dark_violet"},
	["[0;36m"] = {"6", "cadet_blue"},
	["[0;37m"] = {"7", "light_grey"},
	["[0;1;30m"] = {"8", "grey"},
	["[0;1;31m"] = {"9", "orange_red"},
	["[0;1;32"] = {"10", "green"},
	["[0;1;33m"] = {"11", "yellow"},
	["[0;1;34m"] = {"12", "cornflower_blue"},
	["[0;1;35m"] = {"13", "magenta"},
	["[0;1;36m"] = {"14", "cyan"},
	["[0;1;37m"] = {"15", "white"},
}

Post Reply