MIRC 指令碼/進階/文字匹配
on TEXT
當您收到私人和/或頻道訊息時,on TEXT 事件會觸發。
格式
on <level>:TEXT:<matchtext>:<*><?><#[,#]>:<commands>
示例
on 1:TEXT:*help*:#mirc,#irchelp:/msg $nick what is the problem?
on ACTION 和 on NOTICE 事件使用與 on TEXT 完全相同的格式,分別在動作和通知事件時觸發。
匹配文字可以是萬用字元字串,其中
* matches any text & matches any word text matches if text contains only this word text* matches if text starts with this word *text matches if text ends with this word *text* matches if text contains this word anywhere
匹配文字也可以是正則表示式。請參見訪問級別中的 $ 字首部分。
可以使用以下方法指定此事件發生的 location:
? for any private message # for any channel message #mirc for any messages on channel #mirc * for any private or channel messages
示例
on 1:TEXT:hello*:#:/msg $chan Welcome to $chan $nick!
這會在任何頻道監聽以 hello 開頭的任何行,並歡迎在頻道中說它的人。
on 1:TEXT:*cookie*:#food:/describe $chan gives $nick a cookie :)
這會在 #food 頻道監聽包含 cookie 的任何訊息,並給傳送它的人一個 cookie。
on 1:ACTION:moo:#:/msg $chan Aha, I see we have a cow among us.
這會在任何頻道監聽包含 moo 的動作,並相應地做出反應。
on 1:NOTICE:*:?:/msg $nick I am AFK, back in a moment!
這監聽任何私人的通知,並用您離開鍵盤的訊息進行回覆。
為了獲得更大的靈活性,您也可以使用變數代替 matchtext 和 channel 引數。
on 1:TEXT:%matchtext:%channel:/msg $nick You just said $1- on channel %channel
%matchtext 的值將與使用者傳送的任何文字匹配,%channel 的值將與傳送訊息的頻道匹配。
注意:您不能透過對自己輸入文字來測試這些事件。它們只能由其他人對頻道或私信中說的話來觸發。