Project

General

Profile

[Script] Simple insult

Added by Per Amundsen over 9 years ago

Gets a random result from www.randominsults.net

on *:TEXT:!insult:#:{ 
  insult $nick
}

alias insult {
  sockopen insult www.randominsults.net 80
  sockmark insult # $1-
}

on *:sockopen:insult:{
  if ($sockerr > 0) return
  sockwrite -n insult GET / HTTP/1.0
  sockwrite -n insult Host: www.randominsults.net
  sockwrite -n insult
}

on *:sockread:insult:{
  if ($sockerr > 0) return
  var %text
  sockread %text

  if ($regex(%text, /<strong><i>(.*?)<\/i><\/strong>/)) {
    msg $gettok($sock($sockname).mark, 1, 32) $gettok($sock($sockname).mark, 2, 32) $regml(1)
    sockclose $sockname
  }
}