作者hmml (hmml)
看板mud_sanc
标题Re: [心得] MUSHclient - Plugins:抓取聊天讯息
时间Sat Aug 3 09:30:45 2013
新增对指令 to chat 的支援。
-----------------------------------------------------------
<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[
conversion = {
['black'] = ANSI(0)..ANSI (30),
['maroon'] = ANSI(0)..ANSI (31),
['green'] = ANSI(0)..ANSI (32),
['olive'] = ANSI(0)..ANSI (33),
['navy'] = ANSI(0)..ANSI (34),
['purple'] = ANSI(0)..ANSI (35),
['teal'] = ANSI(0)..ANSI (36),
['silver'] = ANSI(0)..ANSI (37),
--以下高亮
['gray'] = ANSI (30, 40,1),
['red'] = ANSI (31, 40,1),
['lime'] = ANSI (32, 40,1),
['yellow'] = ANSI (33, 40,1),
['blue'] = ANSI (34, 40,1),
['magenta'] = ANSI (35, 40,1),
['cyan'] = ANSI (36, 40,1),
['white'] = ANSI (37,40,1),
} --色码表。
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
w:Simulate(conversion[RGBColourToName(v.textcolour)]..v.text)
end -- for each style run
w:Simulate('\n')
end -- ID
end -- world found
end -- function redirect
]]>
</script>
-----------------------------------------------------------
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 220.132.196.45
1F:推 elvrael :成功抓到to chat了 感谢 :D 08/06 10:16