Skip to content

Commit

Permalink
Beta16
Browse files Browse the repository at this point in the history
新增几个小功能
添加正则表达式教程(半成品)
调整了替换角色名为别名
  • Loading branch information
LiXiuMing committed Oct 24, 2019
1 parent a68a103 commit 7a013a0
Show file tree
Hide file tree
Showing 8 changed files with 452 additions and 143 deletions.
29 changes: 27 additions & 2 deletions ChatStat/ChatStat.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ F:\World of Warcraft\_retail_\BlizzardInterfaceCode\Interface\FrameXML\UI.xsd">
<Script file="ChatStat.lua" />

<Frame name="TinomChatStatFrame" parent="UIParent" toplevel="true" hidden="true" movable="true" enableMouse="true">
<Size x="200" y="400"/>
<Size x="260" y="400"/>
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
Expand Down Expand Up @@ -52,7 +52,7 @@ F:\World of Warcraft\_retail_\BlizzardInterfaceCode\Interface\FrameXML\UI.xsd">
</Anchors>
<Color r="1" g="1" b="0"/>
</Texture>
<FontString name="$parentText1" parentArray="Texts" inherits="OptionsFontHighlight" justifyH="LEFT" justifyV="TOP">
<FontString name="$parentText1" parentArray="Texts" inherits="OptionsFontHighlight" justifyH="" justifyV="TOP">
<Anchors>
<Anchor point="TOPLEFT" relativeTo="$parentUnderline" relativePoint="BOTTOMLEFT" x="0" y="-4"/>
</Anchors>
Expand Down Expand Up @@ -186,4 +186,29 @@ F:\World of Warcraft\_retail_\BlizzardInterfaceCode\Interface\FrameXML\UI.xsd">
</Scripts>
</Frame>

<MessageFrame name="TinomMessageFrame" hidden="true" displayDuration="10" fadeDuration="0.5" fadePower="3" insertMode="TOP" parent="UIParent" frameStrata="DIALOG" frameLevel="1" toplevel="true" mixin="UIErrorsMixin">
<Size x="300" y="200" />
<Anchors>
<Anchor point="CENTER"/>
</Anchors>
<Backdrop bgFile="Interface\dialogframe\ui-dialogbox-gold-background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
<EdgeSize>
<AbsValue val="16"/>
</EdgeSize>
<TileSize>
<AbsValue val="16"/>
</TileSize>
<BorderColor r="1" g="1" b="1" a="1"/>
<Color r="0.2" g="0.2" b="0.2" a="0.8"/>

<BackgroundInsets>
<AbsInset left="5" right="5" top="5" bottom="5"/>
</BackgroundInsets>
</Backdrop>
<Scripts>
<OnLoad method="OnLoad"/>
<OnEvent method="OnEvent"/>
</Scripts>
<FontString inherits="OptionsFontHighlight" justifyH="CENTER"/>
</MessageFrame>
</Ui>
152 changes: 113 additions & 39 deletions Filter/Filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,36 +34,99 @@ Tinom.ReminderType = {
};

--[[-------------------------------------------------------------------------
-- 聊天频道名替换函数:因上级函数使用频道名字符串长度作为逻辑条件不便更改,
-- 故通过接管聊天框的AddMessage函数替换字符串,此处为把频道序号后的频道名隐藏.
-- AddMessage过滤
-------------------------------------------------------------------------]]--
function Tinom.ReplaceChannelName()
for i=1,NUM_CHAT_WINDOWS do
if (i ~= 2) then
local chatFrame = _G["ChatFrame"..i]
local addmsg = chatFrame.AddMessage
chatFrame.AddMessage = function(frame, text,...)
if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrChannelName) then
text = text:gsub( "%[(%d).-%]", "[%1]", 1 )
end
if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrAuthorName) then
text = text:gsub( "%[|cff([0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])(.-)(%-%S%S%S).-|r%]", "[|cff%1%2%3|r]", 1 );
if (Tinom.addMsgFilters) then
for _, filterFunc in next, Tinom.addMsgFilters do
text = filterFunc(text);
end
end
Tdebug(self,"log",frame.name..":"..text)
return addmsg(frame,text,...)
end
end
end
end
function Tinom.AddMessageFilter_AddMsgFilter (filter)
assert(filter);

function Tinom.CheckChannelLsit(self,arg9)
for i,v in ipairs(self.channelList) do
if arg9 == v then
return true;
if ( Tinom.addMsgFilters ) then
-- Only allow a filter to be added once
for index, filterFunc in next, Tinom.addMsgFilters do
if ( filterFunc == filter ) then
return;
end
end
else
Tinom.addMsgFilters = {};
end

tinsert(Tinom.addMsgFilters, filter);
end

function Tinom.AddMessageFilter_RemoveMsgFilter (filter)
assert(filter);

if ( Tinom.addMsgFilters ) then
for index, filterFunc in next, Tinom.addMsgFilters do
if ( filterFunc == filter ) then
tremove(Tinom.addMsgFilters, index);
end
end

if ( #Tinom.addMsgFilters == 0 ) then
Tinom.addMsgFilters = nil;
end
end
end

function Tinom.AddMessageFilter_AbbrChannelName( text )
--local player, lineID, channelName, channelNum, playerName = string.match( text,"|Hplayer:(.-):(.-):(.-):(.-)|h%[(.-)%]|h")
if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrChannelName) then
text = text:gsub( "%[(%d).-%]", "[%1]", 1 )
end
return text;
end

function Tinom.AddMessageFilter_AbbrAuthorName( text )
--local player, lineID, channelName, channelNum, playerName = string.match( text,"|Hplayer:(.-):(.-):(.-):(.-)|h%[(.-)%]|h")
if (TinomDB.Options.Default.Tinom_Switch_MsgFilter_AbbrAuthorName) then
text = text:gsub( "%[|cff(%x%x%x%x%x%x)(.-)(%-%S%S%S).-|r%]", "[|cff%1%2%3|r]", 1 );
end
return text;
end

function Tinom.AddMessageFilter_AuthorAliasName( text )
local fullName, authorName, authorServer = string.match( text,"|Hplayer:((.-)%-(.-)):")
for k,v in pairs(TinomDB.filterDB.replaceName) do
if ( authorName and (authorName == k) ) then
if (v) then
text = text:gsub(authorName,v,2);
text = text:gsub(v,authorName,1);
Tinom.ChatStat_Filtered("ReplaceName",authorName);
return text;
end
elseif ( fullName and (fullName == k) ) then
if (v) then
text = text:gsub(authorName,v,2);
text = text:gsub(v,authorName,1);
Tinom.ChatStat_Filtered("ReplaceName",authorName);
return text;
end
end
end
return false;
return text;
end

--[[-------------------------------------------------------------------------
-- 频道过滤
-------------------------------------------------------------------------]]--
function Tinom.MsgFilter( self,event,... )
if ( not TinomDB.Options.Default.Tinom_Switch_MsgFilter_MainEnable )then
return false;
Expand Down Expand Up @@ -113,6 +176,15 @@ function Tinom.MsgFilter( self,event,... )
return ignore, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12, arg13, arg14;
end

function Tinom.CheckChannelLsit(self,arg9)
for i,v in ipairs(self.channelList) do
if arg9 == v then
return true;
end
end
return false;
end

function Tinom.MsgFilter_AddMsgFilter (filter)
assert(filter);

Expand Down Expand Up @@ -183,8 +255,14 @@ end

function Tinom.MsgFilter_BlacklistKeyword( msg,authorName,authorServer, remind )
assert(authorName and msg);


if not TinomDB.Options.Default.Tinom_Switch_MsgFilter_BlackKeywordCaseSensitive then
msg = string.lower(msg);
end
for _,keyword in pairs(TinomDB.filterDB.blackListKeyword) do
if not TinomDB.Options.Default.Tinom_Switch_MsgFilter_BlackKeywordCaseSensitive then
keyword = string.lower(keyword);
end
if msg:find(keyword) then
Tinom.ChatStat_Filtered("BlackListKeyword",authorName);
return true, nil, nil, remind;
Expand Down Expand Up @@ -297,29 +375,28 @@ function Tinom.MsgFilter_FoldMsg( msg,authorName,authorServer, remind )
return false, msg, nil, remind;
end

function Tinom.MsgFilter_ReplaceName( msg,authorName,authorServer, remind )
local newMsg,newName;
local name = authorName.."-"..authorServer;

for k,v in pairs(TinomDB.filterDB.replaceName) do
if ( authorName == k ) then
if (v) then
Tinom.ChatStat_Filtered("ReplaceName",authorName);
newName = v.."-"..authorServer;
return false, newMsg, newName, remind;
end
elseif ( name == k ) then
if (v) then
Tinom.ChatStat_Filtered("ReplaceName",authorName);
newName = v;
return false, newMsg, newName, remind;
end
end
end
return false, newMsg, newName, remind;
end
-- function Tinom.MsgFilter_ReplaceName( msg,authorName,authorServer, remind )
-- local newMsg,newName;
-- local name = authorName.."-"..authorServer;

-- for k,v in pairs(TinomDB.filterDB.replaceName) do
-- if ( authorName == k ) then
-- if (v) then
-- Tinom.ChatStat_Filtered("ReplaceName",authorName);
-- newName = v.."-"..authorServer;
-- return false, newMsg, newName, remind;
-- end
-- elseif ( name == k ) then
-- if (v) then
-- Tinom.ChatStat_Filtered("ReplaceName",authorName);
-- newName = v;
-- return false, newMsg, newName, remind;
-- end
-- end
-- end
-- return false, newMsg, newName, remind;
-- end

-- 替换角色消息:
function Tinom.MsgFilter_ReplaceNameMsg( msg,authorName,authorServer, remind )
local newMsg,newName;
local name = authorName.."-"..authorServer;
Expand All @@ -342,7 +419,6 @@ function Tinom.MsgFilter_ReplaceNameMsg( msg,authorName,authorServer, remind )
return false, newMsg, newName, remind;
end

-- 关键字替换:
function Tinom.MsgFilter_ReplaceKeyword( msg,authorName,authorServer, remind )
local newMsg = msg;
for i=1,2 do
Expand All @@ -358,7 +434,6 @@ function Tinom.MsgFilter_ReplaceKeyword( msg,authorName,authorServer, remind )
return false, newMsg, nil, remind;
end

-- 关键字消息替换:
function Tinom.MsgFilter_ReplaceKeywordMsg( msg,authorName,authorServer, remind )
local newMsg;
for k,v in pairs(TinomDB.filterDB.replaceKeywordMsg) do
Expand All @@ -373,7 +448,6 @@ function Tinom.MsgFilter_ReplaceKeywordMsg( msg,authorName,authorServer, remind
return false, nil, nil, remind;
end

-- 声音提醒 --
function Tinom.Reminder( type )
if not type then return; end

Expand All @@ -383,7 +457,7 @@ function Tinom.Reminder( type )
end

--[[-------------------------------------------------------------------------
-- 消息过滤函数:过滤物品消息,屏蔽灰色物品
-- 拾取过滤
-------------------------------------------------------------------------]]--
function Tinom.MsgFilter_Item( self, event, ... )
if not TinomDB.Options.Default.Tinom_Switch_MsgFilter_IgnoreGrayItems then return; end
Expand Down
Loading

0 comments on commit 7a013a0

Please sign in to comment.