this will echo the title of the link pasted in the channel.
example:
http://www.youtube.com/
YouTube - Broadcast Yourself. ( http://www.youtube.com/ )
http://www.hawkee.com/
Hawkee Technology Social Network ( http://www.hawkee.com/ )
on *:text:*:#: {
if (http:// isin $1-) {
sockclose linkchecker
set %link $remove($matchtok($1-,http://,1,32),http://)
set %linkchan $chan
set %actlink $matchtok($1-,http://,1,32)
if (/ !isin %link) { set %link %link $+ / }
sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
halt
}
if (www. isin $1-) {
sockclose linkchecker
set %link $matchtok($1-,www.,1,32)
set %linkchan $chan
set %actlink $matchtok($1-,www.,1,32)
if (/ !isin %link) { set %link %link $+ / }
sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
halt
}
}
on *:sockopen:linkchecker: {
if $sockerr > 0 { sockclose $sockname | halt }
sockwrite -n $sockname GET / $+ $right(%link,$calc($len(%link)- $pos(%link,/,1))) HTTP/1.1
sockwrite -n $sockname Host: $remove($left(%link,$pos(%link,/,1)),/)
sockwrite -n $sockname $crlf
}
on *:sockread:linkchecker: {
if $sockerr > 0 { sockclose $sockname | halt }
sockread %linkh
if (%delbug != $null) && ($len(%linkch) <= 150) && (</title> !isin %linkh) { set %linkch %linkch %linkh }
if (%delbug != $null) && (</title> isin %linkh) {
echo -t %linkchan 13 $+ $replace(%linkch,",",',',&,&,<,<,>,>,©,©,®,®,™,™,€,€,£,£,¥,¥) (4 %actlink )
unset %delbug
sockclose $sockname
halt
}
if (<title> isin %linkh) {
set %linkch $remove($left(%linkh,$pos(%linkh,</title>,1)),</title>)
set %linkch $right(%linkch,$calc($len(%linkch)- $pos(%linkch,<title>,1) -6))
set %linkch $left(%linkch,$calc($len(%linkch)-1))
set %delbug 1
if (%linkch != $null) {
echo -t %linkchan 13 $+ $replace(%linkch,",",',',&,&,<,<,>,>,©,©,®,®,™,™,€,€,£,£,¥,¥) (4 %actlink )
sockclose $sockname
unset %delbug
halt
}
}
}
This should work
;**********************************************************
;*** Downloaded from http://www.hawkee.com/snippet/6941/
;**********************************************************
on *:TEXT:*:#: {
if ((www. isin $1-) || (http:// isin $1-)) && (*whatsmyip* !iswm $1-) { sockclose linkchecker | set %linkchan $chan
if (http:// isin $1-) { set %link $remove($matchtok($1-,http://,1,32),http://) | set %actlink $matchtok($1-,http://,1,32) }
else { set %link $matchtok($1-,www.,1,32) | set %actlink $matchtok($1-,www.,1,32) }
if (/ !isin %link) { set %link %link $+ / }
sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
halt
}
}
on *:sockopen:linkchecker: {
if $sockerr > 0 { sockclose $sockname | halt }
sockwrite -n $sockname GET / $+ $right(%link,$calc($len(%link)- $pos(%link,/,1))) HTTP/1.1
sockwrite -n $sockname Host: $remove($left(%link,$pos(%link,/,1)),/)
sockwrite -n $sockname $crlf
}
on *:sockread:linkchecker: {
if $sockerr > 0 { sockclose $sockname | halt }
sockread %linkh
if (%delbug != $null) && ($len(%linkch) <= 150) && (</title> !isin %linkh) { set %linkch %linkch %linkh }
if (%delbug != $null) && (</title> isin %linkh) {
; echo -t %linkchan 13 $+ $replace(%linkch,",",',',&,&,<,<,>,>,©,©,®,®,™,™,€,€,£,£,¥,¥) (4 %actlink )
msg %linkchan $+(07,$replace($remove(%linkch,‪,‬‏),",",',',&,&,<,<,>,>,©,©,®,®,™,™,€,€,£,£,¥,¥),) (4 %actlink )
unset %delbug %link %linkchan %actlink
sockclose $sockname
halt
}
if (<title> isin %linkh) {
set %linkch $remove($left(%linkh,$pos(%linkh,</title>,1)),</title>)
set %linkch $right(%linkch,$calc($len(%linkch)- $pos(%linkch,<title>,1) -6))
set %linkch $left(%linkch,$calc($len(%linkch)-1))
set %delbug 1
if (%linkch != $null) {
; echo -t %linkchan 13 $+ $replace(%linkch,",",',',&,&,<,<,>,>,©,©,®,®,™,™,€,€,£,£,¥,¥) (4 %actlink )
msg # %linkchan Title: $+(07,$replace($remove(%linkch,‪),",",',',&,&,<,<,>,>,©,©,®,®,™,™,€,€,£,£,¥,¥),) -> $+(04,%actlink,)
sockclose $sockname
unset %delbug %link %linkchan %actlink
halt
}
}
}
NOTE: That it's edited to msg channel instead of echo
For the url links posted in the channel, you could use regular expressions to match rather than using http:// isin $1- or www. isin $1- then use $regml() to set the variables. Using regex is more precise for the matching of certain strings than using the isin operator. Isin is prone to typo related issues and can easily be tampered with.
Great stuff cessill, works like a charm now, clean, minimal and no colors.
I had a thought though.. The main reason im using this is for a couple of reasons, alot of ppl are nervous about clicking strange links, so this will help them see some sort of page title.. also from an ops point of view it will help them identify potential spamming or infected websites... however while thinking a little more about this, i was curious to know how exactly dose the script access the sites?.. dose it so to speak "visit" the website.. or simply read the page title of a website. My concern here being that the bot will be visiting every link posted in chan, and its a possibility that some of these links will be spam or infected website.
just wondering about the safety aspects of it thats all, and im probably not exaplaining myself properly
best regards
pan
and again great script and tnx for the help
Hi
great script
Is there anyway to just have it reply the website title, and only in plain text (without colors)?
somehint just like this:
<Pan`bbl> http://science.howstuffworks.com/quantum-cryptology3.htm
HowStuffWorks "Photon Properties"on *:text:*:#: {
if (http:// isin $1-) {
sockclose linkchecker
set %link $remove($matchtok($1-,http://,1,32),http://)
set %linkchan $chan
set %actlink $matchtok($1-,http://,1,32)
if (/ !isin %link) { set %link %link $+ / }
sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
halt
}
if (www. isin $1-) {
sockclose linkchecker
set %link $matchtok($1-,www.,1,32)
set %linkchan $chan
set %actlink $matchtok($1-,www.,1,32)
if (/ !isin %link) { set %link %link $+ / }
sockopen linkchecker $remove($left(%link,$pos(%link,/,1)),/) 80
halt
}
}
on *:sockopen:linkchecker: {
if $sockerr > 0 { sockclose $sockname | halt }
sockwrite -n $sockname GET / $+ $right(%link,$calc($len(%link)- $pos(%link,/,1))) HTTP/1.1
sockwrite -n $sockname Host: $remove($left(%link,$pos(%link,/,1)),/)
sockwrite -n $sockname $crlf
}
on *:sockread:linkchecker: {
if $sockerr > 0 { sockclose $sockname | halt }
sockread %linkh
if (%delbug != $null) && ($len(%linkch) <= 150) && (</title> !isin %linkh) { set %linkch %linkch %linkh }
if (%delbug != $null) && (</title> isin %linkh) {
msg %linkchan 13 $+ $replace(%linkch,",",',',&,&,<,<,>,>,©,©,®,®,™,™,€,€,£,£,¥,¥) (4 %actlink )
unset %delbug
sockclose $sockname
halt
}
if (<title> isin %linkh) {
set %linkch $remove($left(%linkh,$pos(%linkh,</title>,1)),</title>)
set %linkch $right(%linkch,$calc($len(%linkch)- $pos(%linkch,<title>,1) -6))
set %linkch $left(%linkch,$calc($len(%linkch)-1))
set %delbug 1
if (%linkch != $null) {
msg %linkchan 13 $+ $replace(%linkch,",",',',&,&,<,<,>,>,©,©,®,®,™,™,€,€,£,£,¥,¥) (4 %actlink )
sockclose $sockname
unset %delbug
halt
}
}
}