blob: e9355556a5f79ffa5fbb127c9c8b88fb3042b97f (
plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# -----------------------------------------------------------------------------
# tiny_url.tcl v0.1 [2004-10-19]
#
# This script will listen on channels and convert long URLs into shorter
# URLs using the TinyURL.com website.
#
# Written by: FAIN on QuakeNet <fain@flamingfist.org>
# -----------------------------------------------------------------------------
# ----- Settings --------------------------------------------------------------
# Set this to the minimum length of URLs to convert
set url_length 80
# -----------------------------------------------------------------------------
package require http 2.3
bind pubm - "*" scan_text
bind act - "*" scan_text
# -----------------------------------------------------------------------------
# Name : scan_text
# Purpose : Scans for URLs and converts to TinyURLs
# -----------------------------------------------------------------------------
proc scan_text {nick uhost hand chan arg} {
global botnick url_length
if {($arg == "boeser bot") ||
($arg == "dummer bot") ||
($arg == "böser bot")} {
putserv "PRIVMSG $chan :Tut mir ja leid $nick! Wirklich!!!"
return 0
}
if {($arg == "guter bot") ||
($arg == "braver bot")} {
putserv "PRIVMSG $chan :Ich weiss, ich weiss :-)"
return 0
}
set arg [split $arg]
foreach act_arg $arg {
if {(([string match "http://*" $act_arg] == 1) ||
([string match "https://*" $act_arg] == 1) ||
([string match "ftp://*" $act_arg] == 1) ||
([string match "www.*" $act_arg] == 1))} {
# Make sure it wasn't the bot who said it
set url $act_arg
if {$nick == $botnick} {
return 0
}
# Check length of URL
set length [string length $url]
if {$length >= $url_length} {
#set tinyurl [make_tinyurl $url]
set tinyurl [exec perl -e "use WWW::Shorten::TinyURL;print makeashorterlink(\"$url\");"]
if {$tinyurl != "0"} {
set title [exec perl -e "use URI::Title;print URI::Title::title(\"$url\");"]
putserv "PRIVMSG $chan :\002Tiny URL\002: $tinyurl \[$title\] (URL by \002$nick\002)"
}
}
if {([string match "*youtube*watch*" $url] == 1)} {
set title [exec perl -e "use URI::Title;print URI::Title::title(\"$url\");"]
if {([string match "* - YouTube" $title] == 1)} {
set title [string range $title 0 end-10]
putserv "PRIVMSG $chan :\002Youtube\002: $title (URL by \002$nick\002)"
}
}
}
}
return 0
}
# -----------------------------------------------------------------------------
# Name : make_tinyurl
# Purpose : Does the actual conversion
# -----------------------------------------------------------------------------
proc make_tinyurl { arg } {
set page [::http::geturl http://tinyurl.com/create.php?url=${arg}]
set lines [split [::http::data $page] \n]
set numLines [llength $lines]
for {set i 0} {$i < $numLines} {incr i 1} {
set line [lindex $lines $i]
if {[string match "<input type=hidden name=tinyurl value=\"*\">" $line] == 1} {
set tinyurl_line [string trim $line]
regsub -all -nocase "<input type=hidden name=tinyurl value=\"" $tinyurl_line "" tinyurl_line
regsub -all -nocase "\">" $tinyurl_line "" tinyurl_line
return $tinyurl_line
}
}
return "0"
}
putlog "---> tiny_url.tcl v0.1 by FAIN @ QuakeNet <fain@flamingfist.org> loaded"
|