Well I've watched this website for long. I have learned a lot from here by reading forums and testing other snippets. I've made a few socket snippets myself and I thought that I could post one of them. Constructive citicism is ofcourse welcome :)
The code goes into your remote (Alt + r).
Syntax is either !insult or /insult.
Example:
Insult: The next time you shave, could you stand an inch or two closer to the razor please?
or
<~EliteBot> Insult: I don't know what makes you so stupid, but it really works!
Update:
As per Jethro's request I removed the flood protect in the alias. Thanks, never thought of that :P
; Trigger !insult | Command /insult
; Pulls up a random insult to active window/channel
alias insult {
if $sock(insult) {
sockclose insult
}
sockopen insult www.randominsults.net 80
sockmark insult echo -a
}
on *:text:!insult:#:{
if $sock(insult) {
sockclose insult
}
inc -u4 %flood
sockopen insult www.randominsults.net 80
sockmark insult msg #
}
on *:sockopen:insult:{
sockwrite -n insult GET / HTTP/1.1
sockwrite -n insult Host: www.randominsults.net
sockwrite -n insult $crlf
}
on *:sockread:insult:{
var %insultreader
sockread %insultreader
if $regex(%insultreader,/td bordercolor=".+"Verdana" size="\d"><strong><i>(.+)<\/i><\/strong><\/font> <\/td/) {
$sock(insult).mark Insult: 4 $+ $regml(1)
}
}
Here is it:
alias insult {
if $sock(insult) {
sockclose insult
}
sockopen insult www.randominsults.net 80
sockmark insult $iif($isid,.msg $iif(#,#,$nick),echo -a)
}
on *:sockopen:insult:{
sockwrite -n insult GET / HTTP/1.1
sockwrite -n insult Host: $sock(insult).addr
sockwrite -n insult
}
on *:sockread:insult:{
var %insultreader
sockread %insultreader
if $regex(%insultreader,/<i>(.+)<\/i>/) {
$sock(insult).mark Insult: 4 $+ $regml(1)
}
}
on *:text:$($iif(!insult == $strip($1),$1)):*:{
if (!%flood) {
inc -u4 %flood
$insult
}
}
You already have an alias insult made. You don't need to open the same socket again. All you have to do is call from the alias to trigger the script for the text event. Keep up the nice work.
P.S. It's rather silly you place a flood trigger control in the alias....unless of course you try to flood yourself. lol