This snippet saves any links that starts with http://. It will also shows a random link when the !rlink command is used.
Update:
Wont save links more then once. (Doesnt matter wich nickname has applied it!)
Added !lastlink
Added Floodcontrol
Added an $iif identifier for the usage of @ public and !. private commands.
Example:
Nick: http://google.com
Bot: (echo) Links saved by Nick | Written http://google.com ( $+ By Nick $+ ) in links.txt
Nick: !rlink
Bot: Here is your random link: http://hawkee.com (By Bielie993)
Nick: !lastlink
Bot: This is the last link that has been saved: http://google.com (By Nick)
Check the printscreen for an example!!!!!!
on *:TEXT:*:#:{
if ($isurl($1-) == $true) {
if ($linkcheck($wildtok($1-,*http://*.*,1,32)) == $true) { /echo Skipping the link since its already on the 4links.txt 1file! | return }
else {
/echo Link: ( $+ $wildtok($1-,*http://*.*,1,32) $+ ) saved by4 $nick | write links.txt $wildtok($1-,*http://*.*,1,32) ( $+ By4 $nick $+ 1) | set %lastlink $wildtok($1-,*http://*.*,1,32) ( $+ By4 $nick $+ 1)
}
}
if ($1 == !rlink) || ($1 == .rlink) || ($1 == @rlink) { $iif($left($1,1) == @,/msg #,/notice $nick) Here is your random link: $linkss | .ignore -u2 $nick }
if ($1 == !lastlink) || ($1 == .lastlink) || ($1 == @lastlink) { $iif($left($1,1) == @,/msg #,/notice $nick) This is the last link that has been saved: %lastlink | .ignore -u2 $nick }
}
alias linkss {
if (!$read(links.txt)) { return Nothing Found }
else { return $read(links.txt) }
}
alias linkcheck {
if ($read(links.txt,nw,$+(*,$1-,*)) != $null) { return $true }
else { return $false }
}
alias isurl return $iif($regex($1-,/\b(?:(?:htt|ft)ps?://(?:www|ftp\.)?|www|ftp\.).*(?:\.[a-z]{2,4})(?::\d+)?(?:/\w+(?:/\w*/*)*|(?:\.[a-z]{2,4})|\?\S*)*\b/gi),$iif($prop,$regml($v1),$true))
I see that you have used regex in your code, why not take advantage of it more?
This:> if ($1 == !rlink) || ($1 == .rlink) || ($1 == @rlink) { $iif($left($1,1) == @,/msg #,/notice $nick) Here is your random link: $linkss | .ignore -u2 $nick }
if ($1 == !lastlink) || ($1 == .lastlink) || ($1 == @lastlink) { $iif($left($1,1) == @,/msg #,/notice $nick) This is last link that has been saved: %lastlink | .ignore -u2 $nick }can be done as:
if ($regex($1,/^([!@.])(r|last)link$/iS)) {
$iif($regml(1) == @,msg #,notice $nick) $iif($regml(2) == r,$&
Here is your random link: $linkss,$&
This is last link that has been saved: %lastlink)
.ignore -u2 $nick
}