作者hmml (hmml)
看板mud_sanc
标题Re: [心得] MUSHclient - Plugins:抓取聊天讯息
时间Sat Oct 5 17:11:11 2013
小小的修正:让它可以抓到背景颜色。
-----------------------------------------------------------
<triggers>
--捕获to chat 讯息,name:chlogging
<trigger
enabled="n"
expand_variables="y"
group="chlog"
keep_evaluating="y"
match="^.*$"
name="chlogging"
script="color_chats"
regexp="y"
sequence="100"
>
</trigger>
--结束捕获to chat,关闭chlogging
<trigger
enabled="y"
group="chlog"
keep_evaluating="y"
match="^﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎﹎$"
name="chlogend"
regexp="y"
repeat="y"
send_to="12"
sequence="100"
>
<send>SetTriggerOption('chlogging','enabled','N')</send>
</trigger>
--开始捕获to chat,打开chlogging
<trigger
enabled="y"
group="chlog"
lines_to_match="3"
keep_evaluating="y"
match="【闲聊─[^\n]+\n﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊﹊
\n.*\n"
multi_line="y"
script="color_chats"
name="chlogopen"
regexp="y"
send_to="12"
sequence="100"
>
<send>
SetTriggerOption('chlogging','enabled','Y')
--防止关闭to chat失败,五秒後再关一次。
DoAfterSpecial(5,"SetTriggerOption('chlogging','enabled','N')",12)
</send>
</trigger>
--捕获一般单行讯息。
<trigger
enabled="y"
match="^(>)*( )*(.*偷偷的告诉|〔队伍频道〕|.*大呼:|$友克鑫拍卖|【圣殿八
卦|.*\)说道:|.*频道-|【闲聊)"
omit_from_output="n"
regexp="y"
script="color_chats"
sequence="100"
>
</trigger>
</triggers>
<!-- Script -->
<script>
<![CDATA[
local conversion= {
['black'] = ANSI (30,22),
['maroon'] = ANSI (31,22),
['green'] = ANSI (32,22),
['olive'] = ANSI (33,22),
['navy'] = ANSI (34,22),
['purple'] = ANSI (35,22),
['teal'] = ANSI (36,22),
['silver'] = ANSI (37,22),
--以下高亮
['gray'] = ANSI (30,1),
['red'] = ANSI (31,1),
['lime'] = ANSI (32,1),
['yellow'] = ANSI (33,1),
['blue'] = ANSI (34,1),
['magenta'] = ANSI (35,1),
['cyan'] = ANSI (36,1),
['white'] = ANSI (37,1),
}
-- 前景
local BACKconversion= {
['black'] = ANSI (40),
['maroon'] = ANSI (41),
['green'] = ANSI (42),
['olive'] = ANSI (43),
['navy'] = ANSI (44),
['purple'] = ANSI (45),
['teal'] = ANSI (46),
['silver'] = ANSI (47),
}
--背景
chat_world = "sanc_chat_list"
--聊天讯息输出视窗。
Listen_Player = 'hmml5'
--补捉讯息的角色。
local first_time = true
--不管它,不要改。
function color_chats (name, line, wildcards, styles)
-- 试着找到 "chat_ world"
local w = GetWorld (chat_world)
-- get "chat" world
-- 如果找不到,试着去打开它
if first_time and not w
then
local filename = GetInfo (67) .. chat_world .. ".mcl"
Open (filename)
w = GetWorld (chat_world)
-- 再试一次
if not w
then
ColourNote ("white", "red", "无法打开指定的档案:" .. filename)
first_time = false
-- don't repeatedly show failure message
end -- 找不到
end -- can't find world first time around
if w
then -- 如果存在,w就是存着'chat_world' ID值的变数。
if GetAlphaOption("player") == Listen_Player
then
--显示时间
w:Simulate(ANSI (32, 40,1)..os.date ("[%dD %H:%M>"))
for _, v in ipairs (styles)
do
--显示内容
Colour_Code = conversion[RGBColourToName(v.textcolour)]..
BACKconversion[RGBColourToName (v.backcolour)]
w:Simulate(Colour_Code..v.text) --内容
end -- for each style run
end -- ID
end -- world found
end -- function redirect
]]>
</script>
-----------------------------------------------------------
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.132.196.45