-
Notifications
You must be signed in to change notification settings - Fork 1
/
AutoLink873.tcl
75 lines (66 loc) · 2.45 KB
/
AutoLink873.tcl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
namespace eval ::MWAutoLink {
##################################################
# Operator873's AutoLink #
##################################################
#I hold no rights to the following script and #
# release it to the general public to be used, #
# re-written in part or in whole, or shared so #
# long as this original header is included as is.#
# #
# operator873@873gear.com #
# #
##################################################
##################################################
# CONFIGURATION AND SETTINGS #
##################################################
# Set language
#
# Set the subdomain or 'lanugage' in MediaWiki installs
variable lang "en"
# Set project
#
# Set the main domain or 'project' in MediaWiki installs
variable proj "wikipedia.org"
##################################################
# END OF CONFIGURATION AND SETTINGS #
# Code follows. Edit at your own risks. #
##################################################
bind pubm - "*\[\[*\]\]*" ::MWAutoLink::AutoLink
bind pubm - "*\{\{*\}\}*" ::MWAutoLink::AutoTempLink
bind pub - "!setlink" ::MWAutoLink::AutoLinkSwitch
variable url "https://$::MWAutoLink::lang.$::MWAutoLink::proj/wiki/"
}
proc ::MWAutoLink::AutoLinkSwitch {nick host hand chan text} {
set flip [lindex [split $text] 0]
switch $flip {
"on" {
setudef flag AutoLink
channel set $chan +AutoLink
putserv "PRIVMSG $chan :\002\00312AutoLink873\002\00312 \00303ENABLED!\00303"
}
"off" {
setudef flag AutoLink
channel set $chan -AutoLink
putserv "PRIVMSG $chan :\002\00312AutoLink873\002\00312 \00304DISABLED!\00304"
}
default {
putserv "PRIVMSG $chan :\002\00304ERROR!\002\00304 \003AutoLink command not recognized. Aborting...\003"
}
}
}
proc ::MWAutoLink::AutoLink {nick host hand chan text} {
if {[channel get $chan AutoLink]} {
set linkString "$text"
regsub {.*\[\[} $linkString {} linkString
regsub {\|.*\]\].*} $linkString {} linkString
regsub {\]\].*} $linkString {} linkString
regsub {.*\{\{} $linkString {Template:} linkString
regsub {\|.*\}\}.*} $linkString {} linkString
regsub {\}\}.*} $linkString {} linkString
set linkString [string map {{ } {_}} $linkString]
set linkString [join $linkString]
if {$linkString ne ""} {
putserv "PRIVMSG $chan :$::MWAutoLink::url$linkString"
}
}
}