mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jul 2015
Posts: 42
J
Joveice Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jul 2015
Posts: 42
i found this site http://albinstuff.net/twitch2.php?id=joveice&follows=am3ricanjackal who post True or False
and i want to make a command !check $nick and i want it to say If he is follower or not
http://albinstuff.net/twitch2.php?id=$NameTocheckiffollows&follows=$Channeltofollow

anyone that could help with socketopen and all this?

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Code:
on *:text:!check &:#:{
  var %n 1,%s
  while ($sock(isfollowing $+ %n)) inc %n
  %s = isfollowing $+ %n
  sockclose %n
  sockopen %n albinstuff.net 80
  sockmark %n $2 $chan 
}
on *:sockopen:isfollowing*:{
  tokenize 32 $sock($sockname).mark
  if ($sockerr) msg $2 Can't connect to website
  else {
    var %s sockwrite -n $sockname
    %s GET /twitch2.php?id=joveice&follows= $+ $urlencode($1)
    %s Host: albinstuff.net
    %s
  }
}

on *:sockread:isfollowing*:{
  var %a
  tokenize 32 $sock($sockname).mark
  if ($sockerr) msg $2 An error occured while reading.
  else {
    if (!$3) {
      sockread %a
      if (!$sockbr) return
      if (%a == $null) sockmark $sockname $1-2 1
    }
    else {
     sockread -f %a
     if ($sockbr) msg $2 Result for $1: %a
    }
  }
}
alias -l urlencode return $regsubex($1, /(\W)/g, $+(%, $base($asc(\t), 10, 16, 2)))

I didn't try it.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2015
Posts: 42
J
Joveice Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jul 2015
Posts: 42
Does not look like it works
tryed !check , !check joveice !check am3ricanjackal
it does not output any text in mirc or the channel, tho it does not have any error messages in mirc
Originally Posted By: Wims
Code:
on *:text:!check &:#:{
  var %n 1,%s
  while ($sock(isfollowing $+ %n)) inc %n
  %s = isfollowing $+ %n
  sockclose %n
  sockopen %n albinstuff.net 80
  sockmark %n $2 $chan 
}
on *:sockopen:isfollowing*:{
  tokenize 32 $sock($sockname).mark
  if ($sockerr) msg $2 Can't connect to website
  else {
    var %s sockwrite -n $sockname
    %s GET /twitch2.php?id=joveice&follows= $+ $urlencode($1)
    %s Host: albinstuff.net
    %s
  }
}

on *:sockread:isfollowing*:{
  var %a
  tokenize 32 $sock($sockname).mark
  if ($sockerr) msg $2 An error occured while reading.
  else {
    if (!$3) {
      sockread %a
      if (!$sockbr) return
      if (%a == $null) sockmark $sockname $1-2 1
    }
    else {
     sockread -f %a
     if ($sockbr) msg $2 Result for $1: %a
    }
  }
}
alias -l urlencode return $regsubex($1, /(\W)/g, $+(%, $base($asc(\t), 10, 16, 2)))

I didn't try it.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
I made an unfortunate typo
Code:
sockclose %n
sockopen %n albinstuff.net 80
sockmark %n $2 $chan 
Change %n by %s

Also, what should !check, without a name (or two) after it, do?
I didn't realize you wanted the id= parameter to be dynamic
You need to describe how you want the on text event to work, because it looks like you want to be able to omit some parameters.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jul 2015
Posts: 42
J
Joveice Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jul 2015
Posts: 42
Ok what i want is on !check <name> it will check <name> with $chan if it follows it so it works on the channel its on, Etc im in my channel and i do !check test, if test now follows me it will output test is a follower if not: test does not follow and i do want it to be if true then it makes %istrue = true or %istrue = false. so i can add stuff like if (%istrue == false {
somthing
}
Let me know if you need more info or that i need to explain it on another way
Originally Posted By: Wims
I made an unfortunate typo
Code:
sockclose %n
sockopen %n albinstuff.net 80
sockmark %n $2 $chan 
Change %n by %s

Also, what should !check, without a name (or two) after it, do?
I didn't realize you wanted the id= parameter to be dynamic
You need to describe how you want the on text event to work, because it looks like you want to be able to omit some parameters.

Last edited by Joveice; 28/07/15 11:38 AM.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Code:
on *:text:!check &:#:{
  var %n 1,%s
  while ($sock(isfollowing $+ %n)) inc %n
  %s = isfollowing $+ %n
  sockclose %s
  sockopen %s albinstuff.net 80
  sockmark %s $2 $chan 
}
on *:sockopen:isfollowing*:{
  tokenize 32 $sock($sockname).mark
  if ($sockerr) msg $2 Can't connect to website
  else {
    var %s sockwrite -n $sockname
    %s GET $+(/twitch2.php?id=,$urlencode($1),&follows=,$urlencode($2))
    %s Host: albinstuff.net
    %s
  }
}

on *:sockread:isfollowing*:{
  var %a
  tokenize 32 $sock($sockname).mark
  if ($sockerr) msg $2 An error occured while reading.
  else {
    if (!$3) {
      sockread %a
      if (!$sockbr) return
      if (%a == $null) sockmark $sockname $1-2 1
    }
    else {
      sockread -f %a
      if ($sockbr) {
        if (%a == true) msg $2 $1 is a follower
        else msg $2 $1 is not a follower
      }
    }
  }
}
alias -l urlencode return $regsubex($1, /(\W)/g, $+(%, $base($asc(\t), 10, 16, 2)))

That should do it, however I didn't set any %istrue variable because it wouldn't make sense to do so (or it doesn't make sense to me), because that true/false value could change with the next check I suppose.
If you want to do more than sending a message to the channel according to the result, do so in the on sockread event:
Code:
if (%a == true) {
 msg $2 $1 is a follower
 set %istrue true
}
else {
 msg $2 $1 is not a follower
 set %istrue false
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: May 2010
Posts: 29
P
Ameglian cow
Offline
Ameglian cow
P
Joined: May 2010
Posts: 29
I suspect that theres still a small detail that OP left out (not sure if I am remembering twitches IRC incorrectly though). The channel on twitch IRC has a # prepended to it. So you may need to change:

Code:
%s GET $+(/twitch2.php?id=,$urlencode($1),&follows=,$urlencode($2))


To:

Code:
%s GET $+(/twitch2.php?id=,$urlencode($1),&follows=,$urlencode($right($2,$calc($len($2) - 1))))


If Wims code doesnt work.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Good point, I'm lucky that http://albinstuff.net/twitch2.php?id=joveice&follows=am3ricanjackal and http://albinstuff.net/twitch2.php?id=joveice&follows=#am3ricanjackal return the same, the removal of the # is handled by the website :p


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: May 2010
Posts: 29
P
Ameglian cow
Offline
Ameglian cow
P
Joined: May 2010
Posts: 29
Originally Posted By: Wims
Good point, I'm lucky that http://albinstuff.net/twitch2.php?id=joveice&follows=am3ricanjackal and http://albinstuff.net/twitch2.php?id=joveice&follows=#am3ricanjackal return the same, the removal of the # is handled by the website :p


Aha! Fair enough :P Just thought I'd put in a mention just in case. Nice work anyhow.

Joined: Jul 2015
Posts: 42
J
Joveice Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jul 2015
Posts: 42
I might have been unclear, if so im sorry.
when i do !check test2 i want it to check if test2 follows my channel, (the channel the command is triggered in)
Right now the !check returns Is following to what ever i put in to it, so im not sure whats wrong, could you please look over it ?:)

Joined: Jul 2015
Posts: 42
J
Joveice Offline OP
Ameglian cow
OP Offline
Ameglian cow
J
Joined: Jul 2015
Posts: 42
Originally Posted By: Plornt
I suspect that theres still a small detail that OP left out (not sure if I am remembering twitches IRC incorrectly though). The channel on twitch IRC has a # prepended to it. So you may need to change:

Code:
%s GET $+(/twitch2.php?id=,$urlencode($1),&follows=,$urlencode($2))


To:

Code:
%s GET $+(/twitch2.php?id=,$urlencode($1),&follows=,$urlencode($right($2,$calc($len($2) - 1))))


If Wims code doesnt work.

ok thank you this works!


Link Copied to Clipboard