Creates a straw poll and echo's out the URL to it
Win 2k or later
mIRC 7.x or later
In mIRC, create a new remotes' script file(alt+r -> file -> new)
Copy the code from below into the new script file
Click "Ok"
/strawpoll -mp title options:optionA,optionB,...
Creates the straw poll
-m
: Makes the straw poll multi-select-p
: Disables permissive mode
title
: title of the straw poll (required)options
: a comma seperated list of options to use for the straw poll
#strawpoll_creator on
alias strawpoll {
if ($strawpoll.parse($1-)) {
tokenize 32 $v1
if (!$1) {
echo 04 -a * /strawpoll: $2-
}
else {
echo -a $chr(3) $+ 03[Strawpoll] $+ $chr(15) $+ : $2-
}
}
}
#strawpoll_creator end
on *:START:strawpoll.init
alias -l strawpoll.init {
var %err, %cls = $false, %com = strawpoll_creator, %js
%js = (function(){strawpoll=function(){throw new Error("Unable to locate a valid HTTP request object")};var x=['MSXML2.SERVERXMLHTTP.6.0','MSXML2.SERVERXMLHTTP.3.0','MSXML2.SERVERXMLHTTP'],xo,i;for(i=0;i<x.length;i+=1){try{xo=new ActiveXObject(x[i]);xo=x[i];strawpoll=function(d){var z=new ActiveXObject(xo),c,i;z.open("GET","http://strawpoll.me",false);z.send();if(z.status!==200)throw new Error("Server Error: "+z.status);c=z.getResponseHeader("Set-Cookie").split(";")[0];if(!c)throw new Error("No Cookie Recieved");z=new ActiveXObject(xo);z.open("POST","http://strawpoll.me/api/v2/polls",false);z.setRequestHeader("Cookie",c);z.setRequestHeader("Origin","http://strawpoll.me");z.setRequestHeader("Referer","http://strawpoll.me/");z.setRequestHeader("Accept","application/json,text/plain,*/*");z.setRequestHeader("Content-Type","application/json;charset=utf-8");z.setRequestHeader("Content-Length",d.length.toString(10));z.send(d);if(z.status!==201)throw new Error("Poll Not Created");i=eval('('+z.responseText+')');if(i.hasOwnProperty("id"))return"http://strawpoll.me/"+i.id;throw new Error("Poll id not returned")};break}catch(e){}}}());
if (!$com(strawpoll_creator)) {
.disable #STRAWPOLL_CREATOR
.comopen %com MSScriptControl.ScriptControl
if (!$com(%com)) {
%err = Unable to create an instance of MSScriptControl.ScriptControl
}
else {
%cls = $true
if ($comerr) {
%err = Unable to create an instance of MSScriptControl.ScriptControl
}
elseif (!$com(%com, language, 4, bstr, jscript) || $comerr) {
%err = Unable to set the MSScriptControl.ScriptControl instance's language to jscript
}
elseif (!$com(%com, ExecuteStatement, 1, bstr, %js) || $comerr) {
%err = Unable to add jscript to the MSScriptControl.ScriptControl instance
}
else {
.enable #STRAWPOLL_CREATOR
}
}
}
:error
%err = $iif($error, $v1, %err)
reseterror
if (%err) {
if (%cls && $com(%com)) {
.comclose %com
}
.disable #STRAWPOLL_CREATOR
echo 04 -s * /Strawpoll: %err
}
}
alias -l strawpoll.try {
var %js = (function(){try{return"1 "+strawpoll('_data_')}catch(e){return"0 "+e.message}}())
%js = $replacecs(%js, _data_, $2-)
if (!$com($1, eval, 1, bstr, %js) || $comerr) {
return 0 com error - $com($1).errortext
}
else {
return $com($1).result
}
}
alias -l strawpoll.parse {
var %reg = /^(?:(-[mp]*) )?(.+?) options:(.+)$/i, %n, %switches, %title, %options, %multi, %permissive, %v
if ($regex($1-, %reg)) {
%n = 1
%switches = -
if (-* iswm $regml(1)) {
%switches = $v2
inc %n
}
%title = "title":" $+ $replace($regml(%n), \,\\, ", \") $+ "
%options = $regml($calc(%n +1))
%multi = "multi": $+ $iif(m isincs %switches, true, false)
%permissive = "permissive": $+ $iif(p isincs %switches, true, false)
tokenize 44 %options
%options = $null
%n = 0
while (%n < $0) {
inc %n
%v = $regsubex($($ $+ %n, 2), /(?:^[\s\r\n\t]+)|([\s\r\n\t]+$)/g, )
if ($len(%v)) {
%options = $addtok(%options, " $+ $replace(%v, \, \\, ", \") $+ ", 44)
}
}
if ($numtok(%options,44) > 1) {
return $strawpoll.try(strawpoll_creator, $replace($+($chr(123),%title,$chr(44),"options":[,%options,],$chr(44),%multi,$chr(44),%permissive,$chr(125)), \, \\, ', \'))
}
}
}
on a new line between
#strawpoll_creator on
andalias strawpoll {
paste the following code: