User:Bookofjude/wikilinks.ice
Appearance
Usage
[edit]- Press Control-S to bring up Script Editor
- Paste into a new script file
- Hit "update and close" in the Main menu.
Notes
[edit]- Will break on piped|links
- Doesn't support crosswiki namespace
- Doesn't support {{Templates}}
- Echoes link below messages as per following example:
[10:10] <Someuser> Blah blah blah [[WP:AFD]] blah blah blah. [[WP:POINT]] blah blah blah. [10:10] http://en.wikipedia.org/wiki/WP:AFD http://en.wikipedia.org/wiki/WP:POINT
Code
[edit]Function WikiMatch(TextToMatch) Dim regEx, CurrentMatch, CurrentMatches, ActualLink, Links, CurrentSearch Set regEx = New RegExp regEx.Pattern = "\[\[([^\|\]]*)(\|[^\]]*)?\]\]" regEx.IgnoreCase = True regEx.Global = True regEx.MultiLine = True Set CurrentMatches = regEx.Execute(TextToMatch) For Each CurrentSearch in CurrentMatches ActualLink = Replace(CurrentSearch,"[[", "") ActualLink = Replace(ActualLink, "]]", "") ActualLink = Replace(ActualLink, "{{", "") ActualLink = Replace(ActualLink, "}}", "") ActualLink = Replace(ActualLink, " ", "_") if ActualLink <> "" Then WikiMatch = Wikimatch + " http://en.wikipedia.org/wiki/" + ActualLink End If Next End Function Sub ONTEXT(Message,Channel,Nickname,Host,ServerNumber) Dim Matches Matches = WikiMatch(Message) If Matches <> "" Then SendCommand "/echo " + Channel + " " + Matches , ServerNumber End If End Sub Sub ONQUERY(Message,Nickname,Host,ServerNumber) Dim Matches Matches = WikiMatch(Message) If Matches <> "" Then SendCommand "/echo =" + Nickname + " " + Matches , ServerNumber End If End Sub