mIRC Homepage
Posted By: Exuviax Creating Polls in chat (Using StreamPoll) - 10/12/14 09:09 PM
So recently strawpoll.me added in DDOS protection, so you can't use this script (Curiously of Loki)

Code:
on *:text:!poll *:#:{
  var %regex = /(?:(.+?)\s*[:-]+\s*|())(.+?)$/iS
  if ($regex($strip($2-),%regex)) {
    var %title = $iif($regml(1),$v1,Poll)
    var %options = $regsubex($regml(2),/\s* $+ $chr(44) $+ \s*/g,$chr(44))
  }
  else return

  noop $strawpoll.create(#,%title,%options)
}

alias strawpoll.create {
  var %chan = $1, %title = $urlencode($2), %options
  var %multi = true, %permissive = false

  var %i = 1, %n = $numtok($3,44)
  while (%i <= %n) {
    %options = %options $+ &options[]= $+ $urlencode($gettok($3,%i,44))
    inc %i
  }

  var %sockname = strawpoll. $+ $ticks
  hfree -w %sockname | hmake %sockname
  hadd %sockname headerfile %sockname $+ .header.txt
  hadd %sockname datafile %sockname $+ .data.txt

  hadd %sockname host strawpoll.me
  hadd %sockname request /ajax/new-poll
  hadd %sockname method POST
  hadd %sockname data $+(title=,%title,%options,&multi=,%multi,&permissive=,%permissive)
  hadd %sockname signal strawpoll.create
  hadd %sockname params %chan

  sockopen %sockname $hget(%sockname,host) 80
}

on *:signal:strawpoll.create:{
  var %err = $1, %sockname = $2, %header = $3, %data = $4, %chan = $5

  if (* 200 OK iswm $read(%header,1)) && ($regex($read(%data,n,1),(\d+))) {
    msg %chan http://strawpoll.me/ $+ $regml(1)
  }
  else msg %chan Could not create poll.

  hfree -w %sockname
  .remove %header | .remove %data
}

on *:sockopen:strawpoll.*:{
  var %a = sockwrite -n $sockname
  %a $hget($sockname,method) $hget($sockname,request) HTTP/1.0
  %a Host: $hget($sockname,host)
  %a Connection: close
  if ($hget($sockname,data) != $null) {
    %a Content-Type: application/x-www-form-urlencoded
    %a Content-Length: $len($v1)
  }
  %a $+($crlf,$hget($sockname,data))
}

on *:sockread:strawpoll.*:{
  var %header
  var %headerfile = $hget($sockname,headerfile)
  var %datafile = $hget($sockname,datafile)

  if (!$hget($sockname,header.complete)) {
    sockread %header
    while (%header != $null) {
      write %headerfile %header
      sockread %header
    }
    if ($sockbr) hadd $sockname header.complete $true
  }
  if ($hget($sockname,header.complete)) {
    sockread &read
    while ($sockbr) {
      bwrite %datafile -1 -1 &read
      sockread &read
    }
  }
}

on *:sockclose:strawpoll.*:{
  var %header = $hget($sockname,headerfile)
  var %data = $hget($sockname,datafile)
  var %signal = $hget($sockname,signal)
  var %params = $hget($sockname,params)

  if (%signal) .signal %signal 0 $sockname %header %data %params
  else {
    hfree -w $sockname
    .remove %header | .remove %data
  }
}

alias urlencode return $regsubex($1-,/([^A-Z0-9])/gi,$+(%,$base($asc(\1),10,16)))


So, I was wondering if we could get this to work with a website that recently came up. Created by one of my close friends actually, we want mIRC to be able to call to it, create the script and force it to either "Sub" "Follower" or "Open" because those are the options on the site.

We want the bot to tell us the streamers name, so the #channel they are on, and that will tell the site which person they need to look at for the "Sub" and "follow" and also op on creating.

So, you would do something along the lines of

!poll QUESTION: ANSWER ONE, ANSWER TWO, ANSWER THREE (Sub)

With up to 30 answers, and either (sub) (follower) (open) or default open if not placed.

If it isn't possible, what would need to be changed on the site to allow it? Or to make it easier? The site is all PHP and the https://streampoll.tv/poll.php is the poll creator for the coding, you can't actually see that. And the JQuery is

Code:
if (isset($_POST['question'],$_POST['option1'],$_POST['option2'],$_POST['subfolevery']) && ($_POST['question'] != '')):


We want to make another way for streamers to make polls in chat, or even out of IRC. Because Strawpoll blocked us.
If you're going to write a script to do polls, why even use the 3rd party site?
So the chat can click the link and do it on the site. Our site is already there, it's easier making calls to it then it is spamming the chat with that and what not.
© mIRC Discussion Forums