mIRC Home    About    Download    Register    News    Help

Print Thread
How to i add polls to my IRC chat? #249706
11/12/14 11:30 PM
11/12/14 11:30 PM
Joined: Dec 2014
Posts: 26
A
Athenlayjoshr Offline OP
Ameglian cow
Athenlayjoshr  Offline OP
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!

Re: How to i add polls to my IRC chat? [Re: Athenlayjoshr] #249709
12/12/14 10:04 AM
12/12/14 10:04 AM
Joined: Dec 2008
Posts: 1,511
Greece
westor Offline
Hoopy frood
westor  Offline
Hoopy frood

Joined: Dec 2008
Posts: 1,511
Greece
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? -> http://westor.ucoz.com/contact <-
Re: How to i add polls to my IRC chat? [Re: Athenlayjoshr] #249863
20/12/14 01:00 PM
20/12/14 01:00 PM
Joined: Jan 2014
Posts: 101
MN, USA
M
Majeye Offline
Vogon poet
Majeye  Offline
Vogon poet
M

Joined: Jan 2014
Posts: 101
MN, USA
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

Re: How to i add polls to my IRC chat? [Re: Majeye] #249870
20/12/14 08:48 PM
20/12/14 08:48 PM
Joined: Aug 2014
Posts: 42
K
Krawalli Offline
Ameglian cow
Krawalli  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.

Re: How to i add polls to my IRC chat? [Re: Krawalli] #249891
22/12/14 08:37 AM
22/12/14 08:37 AM
Joined: Jan 2014
Posts: 101
MN, USA
M
Majeye Offline
Vogon poet
Majeye  Offline
Vogon poet
M

Joined: Jan 2014
Posts: 101
MN, USA
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.