Random Insult

By Kiddo96 on Sep 25, 2011

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>&nbsp;<\/td/) {
    $sock(insult).mark Insult: 4 $+ $regml(1)
  }
}

Comments

Sign in to comment.
Jethro   -  Sep 25, 2011

Yes, definitely. You can use the $event identifier, but then I was abusing the $isid, because it's shorter. There ain't much of a difference really. If you choose $event, you can change $insult to simply insult

 Respond  
Kiddo96   -  Sep 25, 2011

That's very nice Jethro, knew it was easy. But just for my own learning purposes, is it possible to change this:

 sockmark insult $iif($isid,.msg $iif(#,#,$nick),echo -a) 

To this?:

 sockmark insult $iif($event == text,.msg $iif(#,#,$nick),echo -a) 
 Respond  
Jethro   -  Sep 25, 2011

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
  }
}
 Respond  
Kiddo96   -  Sep 25, 2011

Yup I know it is and I know I can do it too lol. Though I'm to tired for it now :P

 Respond  
Jethro   -  Sep 25, 2011

If you want it as an echo for the alias, it's an easy fix.

 Respond  
Kiddo96   -  Sep 25, 2011

I like it Jethro, though yours doesn't work for /insult if you want a single echo to your window. Thanks for showing your version :)

 Respond  
Jethro   -  Sep 25, 2011

Deleted due to an edit below.

 Respond  
Kiddo96   -  Sep 25, 2011

Thanks Jethro, never thought of that lol. And also, if I got you right, is there a way to "combine" the /insult with the bot's !insult command? If you could show that I'd be more than happy :)

 Respond  
Jethro   -  Sep 25, 2011

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

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.