Insult Generator V1(beta?)

By narcos on Jun 24, 2016

Still a work in progress. Leave ideas/feedback/criticism etc

Insult generator dialog. Right click a menu, channel, or query box and click "Insult Generator" to open the dialog.
4 second flood protection built in. Can be changed by altering the value behind var %flameflood

Options
A) Insult on highlight
B) Insult on private message
C) Add channels to exceptions list. Script will not execute in those channels.
D) Add nicknames to exceptions list. Script will not respond to those nicknames.
E) Turn script On/off

Image
Image
Image
Image

dialog ingen {

  title "Insult Generator"
  size -1 -1 201 138
  option dbu
  check "Insult on highlight", 1, 6 27 58 10
  check "Insult on private msg", 2, 6 38 64 10
  list 3, 6 68 50 24, size
  text "Channel exceptions", 4, 6 58 73 8
  button "Add to list", 6, 58 108 37 10
  button "Remove", 7, 58 81 37 10, disable
  text "Nickname exceptions", 8, 104 58 53 8
  edit "", 9, 104 108 50 10
  list 10, 104 68 50 24, size
  button "Add to list", 11, 157 108 37 10
  button "Remove", 12, 157 81 37 10, disable
  radio "On", 13, 5 3 19 10
  radio "Off", 14, 5 12 20 10
  text "Status:", 16, 51 3 25 9
  list 5, 6 95 50 24, size
  list 15, 77 3 101 50, size
}

on *:TEXT:*:#: { 
  if ($hget(ingen,status) == on) {

    if ($nick isin $hget(ingen,nickex))  { return }
    if ($chan isin $hget(ingen,chanex)) { return }

    if ($hget(ingen,highlights) == on) {
      if ($me isin $1-) {

        if (%flameflood) { return }
        set -z %flameflood 4

        if ($sock(flame)) .sockclose flame | set %flame.msg msg $chan $nick | sockopen flame www.insultgenerator.org 80 
      }
    } 
  }
}

on *:TEXT:*:?: { 
  if ($hget(ingen,status) == on) {
    if ($hget(ingen,pvt) == on) {
      if ($nick isin $hget(ingen,nickex))  { return }

      if (%flameflood) { return }
      set -z %flameflood 4

      if ($sock(flame)) .sockclose flame | set %flame.msg msg $nick  | sockopen flame www.insultgenerator.org 80 
    }

  }
}

on *:SOCKOPEN:flame: {
  sockwrite -nt $sockname GET / HTTP/1.1
  sockwrite -nt $sockname Host: www.insultgenerator.org
  sockwrite $sockname $crlf
}

on *:SOCKREAD:flame: {
  var %sockreader 
  sockread %sockreader
  if (</div> isin %sockreader && *div class* !iswm %sockreader) {
    %flame.msg $remove(%sockreader,</div>,&nbsp;,&#44;)
    .unset %flame.*
    .sockclose $sockname
  }
}

on *:dialog:ingen:init:0:{ 
  didtok $dname 5 32 $regsubex($str(-,$chan(0)),/(.)/g,$+($chan(\n),$chr(32))) 

  refresh3
  refresh10 

  if (!$hget(ingen)) { hmake ingen 10 }
  if ($isfile(ingen.hsh)) { hload  ingen ingen.hsh }

  if ($hget(ingen,status) == on) { did -c $dname 13 | did -a $dname 15 Insult Generator Active }
  if ($hget(ingen,status) == off) { did -c $dname 14 | did -a $dname 15 Insult Generator OFF }

  if ($hget(ingen,highlights) == on) { did -c $dname 1 }
  if ($hget(ingen,pvt) == on) { did -c $dname 2 }
}

on *:dialog:ingen:sclick:*:{
  var %a did -a $dname
  var %b did -b $dname
  var %e did -e $dname
  var %r did -r $dname
  var %u did -u $dname

  if ($did == 1) && ($did(1).state == 1) { hadd -m ingen highlights on | %a 15 Now insulting highlights }
  if ($did == 1) && ($did(1).state == 0) { hadd -m ingen highlights off | %a 15 Insult on highlight OFF } 
  if ($did == 2) && ($did(2).state == 1) { hadd -m ingen pvt on | %a 15 Now insulting private messages }
  if ($did == 2) && ($did(2).state == 0) { hadd -m ingen pvt off | %a 15 Insult on private message OFF }

  if ($did == 13) { %a 15 Insult Generator Active | hadd -m ingen status on }
  if ($did == 14) { %a 15 Insult Generator OFF | hadd -m ingen status off }
  if ($did == 3) { %e 7 }
  if ($did == 10) { %e 12 }

  if ($did == 7) { hadd ingen chanex $remtok($hget(ingen,chanex),$did(3).seltext,1,44) | %a 15 Deleted $did(3).seltext | refresh3 | %b 7 } ;deletechannel 
  if ($did == 12) { hadd ingen nickex $remtok($hget(ingen,nickex),$did(10).seltext,1,44) | %a 15 Deleted $did(10).seltext | refresh10 | %b 12 } ;deletenick

  if ($did == 6) { hadd ingen chanex $addtok($hget(ingen,chanex),$did(5).seltext,44) | %a 15 Added $did(5).seltext | refresh3 } ;addchannel
  if ($did == 11) { hadd ingen nickex $addtok($hget(ingen,nickex),$did(9).text,44) | %a 15 Added $did(9).text | refresh10 } ;addnickname
}

alias refresh3 {
  did -r $dname 3
  var %a 1
  while ($gettok($hget(ingen,chanex),%a,44) != $null) {
    did -a $dname 3 $v1
    inc %a
  }
}
alias refresh10 {
  did -r $dname 10
  var %a 1
  while ($gettok($hget(ingen,nickex),%a,44) != $null) {
    did -a $dname 10 $v1
    inc %a
  }
}

Menu channel,status,query {
Insult Generator:/dialog -m ingen ingen }

On *:Start:{
  if (!$hget(ingen)) { hmake ingen 10 }
  if ($isfile(ingen.hsh)) { hload  ingen ingen.hsh }
}
on *:Exit: { 
  if ($hget(ingen)) { hsave ingen ingen.hsh } 
} 
on *:Disconnect: { 
  if ($hget(ingen)) { hsave ingen ingen.hsh } 
}

Comments

Sign in to comment.
CrazyDriver   -  Jul 26, 2016

Doesn't seem to want to work for me, just says 'CrazyDriver' on reply that's all, I have it ON and in the exact way you've done to make sure it works, but nothing else happens.

 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.