hMailServer中文论坛 QQ群:80049760 SSL在线生成 https://www.sssssssss.com/ 临时邮箱 https://www.linshiyouxiang.com

自动过滤关键字

与hMailServer脚本相关,戳此进入。
回复
头像
Hsia
网站管理员
网站管理员
帖子: 336
注册: 2014年11月26日, 12:41
地址: 上海
联系:

自动过滤关键字

帖子 Hsia »

过滤。CSV文件格式应该是:
For Example:
Bugger, B*g**r,1
Bloody, Blooming,1
shit,poo,0

代码: 全选

Sub OnAcceptMessage(oClient, oMessage)
   If (oClient.Username = "") Then
      Dim Location
      Location = "C:\Program Files (x86)\hMailServer\Events\Filter.csv"

      Dim objFSO
      Dim objTextFile
      Dim strWords,i
      Dim restrict

      Set objFSO = CreateObject("Scripting.FileSystemObject")
      Set objTextFile = objFSO.OpenTextFile(Location, 1)

      Dim objRegEx
      Set objRegEx = CreateObject("VBScript.RegExp")

      objRegEx.Global = True   
      objRegEx.IgnoreCase = True

      Do While objTextFile.AtEndOfStream <> True
         strWords = split(objTextFile.Readline, ",")
         restrict = strWords(2)
         if restrict = 1 then
            objRegEx.Pattern = "(\s|_|\W|[0-9])" & strWords(0) & "(\s|_|\W|[0-9])"
            oMessage.Body = objRegEx.Replace(oMessage.Body, "$1" & strWords(1) & "$2" )
            oMessage.HTMLBody = objRegEx.Replace(oMessage.HTMLBody, "$1" & strWords(1) & "$2" )
         else
            oMessage.Body = Replace(oMessage.Body,strWords(0),strWords(1),1,-1,1)
            oMessage.HTMLBody = Replace(oMessage.HTMLBody,strWords(0),strWords(1),1,-1,1)
         end if
      Loop
      oMessage.Save()
   End If
End Sub
原文
回复