mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2014
Posts: 26
A
Ameglian cow
OP Offline
Ameglian cow
A
Joined: Dec 2014
Posts: 26
Could someone send me some code of a poll script
so i can do !poll {Option}|Option|{Option}
If someone could send me this that would be great!

Joined: Dec 2008
Posts: 1,515
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2008
Posts: 1,515
Have a look at this addon maybe will help you but first read the description and the hole commands what doing to understand the usage : http://hawkee.com/snippet/16067/


Need Online mIRC help or an mIRC Scripting Freelancer? -> https://irc.chathub.org <-
Joined: Jan 2014
Posts: 107
M
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
Try this out:

Code:
on *:text:!strawpoll *:#:{
  if ($nick !isop #) return
  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)))


With this code, you should be able to use your bot for Strawpolls...

The syntax is as follows (you can add as many options as you want): !strawpoll <title>; <option>,<option>,<option>

Example:
!strawpoll RandomTitleHere; RandomOption1,RandomOption2,RandomOption3

Joined: Aug 2014
Posts: 42
K
Ameglian cow
Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Sadly the Strawpoll script isn working anymore.
Has to do something with cloudflare ddos protection i guess.

Joined: Jan 2014
Posts: 107
M
Vogon poet
Offline
Vogon poet
M
Joined: Jan 2014
Posts: 107
Originally Posted By: Krawalli
Sadly the Strawpoll script isn working anymore.
Has to do something with cloudflare ddos protection i guess.


Ah, that sucks.. perhaps one of the geniuses here could figure out how to make it work again.


Link Copied to Clipboard