mIRC Home    About    Download    Register    News    Help

Print Thread
need help with a twitch bot #247837
30/08/14 03:38 AM
30/08/14 03:38 AM
Joined: Aug 2014
Posts: 1
F
Fandydur Offline OP
Mostly harmless
Fandydur  Offline OP
Mostly harmless
F

Joined: Aug 2014
Posts: 1
I am working on an mIRC bot with a point system and a raffle give away feature where people can enter. I have everything working but the raffle part of it. I followed a youtube series for the code but it doesnt seem to be working. here is a copy of the code:

Code:
alias -l addPoints {
  if ($1 !isnum) { echo 2 -st $1 is not a number. It needs to be a number. | halt }
  var %topic $+($chan,.,$nick)
  var %points $calc($readini(Points.ini,%topic,Points) + $1)
  writeini -n Points.ini %topic Points %points
  return %points
}

alias -l lookUpPoints {
  var %topic $+($chan,.,$nick)
  var %points $readini(Points.ini,%topic,Points)
  return %points
}
alias doaddpoints {
  if ($3 !isnum) { echo 2 -st $3 is not a number. It needs to be a number. | halt }
  var %topic $+($1,.,$2)
  var %points $calc($readini(Points.ini,%topic,Points) + $3)
  writeini -n Points.ini %topic Points %points
  echo -a Added points for %topic
}

alias dorempoints {
  var %topic $+($1,.,$2)
  remini -n Points.ini %topic Points
  echo -a Removed points for %topic
}

on *:text:!points:#:{
  if ((%floodpoints) || ($($+(%,floodpoints.,$nick),2))) { return }
  set -u10 %floodpoints On
  set -u30 %floodpoints. $+ $nick On
  msg # $nick has $readini(Points.ini,$+(#,.,$nick),Points) total points.
}

on $*:text:/!points (add|remove)/Si:#:{
  if ($nick isop #) {
    if ($0 < 3) { msg # Insufficient parameters: Use !points <add|remove> <user> [number] | return }
    writeini -n Points.ini $+(#,.,$3) Points $calc($readini(Points.ini,$+(#,.,$3),Points) $iif($2 == add,+,-) $iif($4 isnum,$4,1))
    { msg $chan $3 now has $readini(Points.ini,$+(#,.,$3),Points) total points. }
  }
  else { msg $chan This command is only available to moderators. }
}
on !*:join:#:{
  $+(.timerpoints.,#,.,$nick) 0 300 add.pts $+(#,.,$nick)
  add.pts $+(#,.,$nick)
}
on !*:part:#:$+(.timerpoints.,#,.,$nick) off
alias -l add.pts {
  writeini -n Points.ini $1 Points $calc($readini(Points.ini,$1,Points) + 1)
}

on *:TEXT:!buyticket &:#:{
  if (%raffle == 1) {
    if ($2 > 10) {
      msg $chan Sorry $nick but you can only up to 10 tickets
    }
    if ($2 < 11) {
      var %i = 0
      var %ticket = $2
      var %topic = $+(#,.,$nick)
      var %user = $readini(Points.ini,%topic,Points)
      var %end = 10 * %ticket
      var %delete = %user - %end
      if (%delete > 0) {
        writeini -n Points.ini %topic Points %delete
        while (%i < %ticket) {
          write Raffle.txt $nick
          %i = %i + 1
        }
        msg $chan $nick you have bought %ticket tickets with %end points.
      }
      if (%delete < 0) {
        msg $chan Sorry $nick you don't have enough points to buy %ticket tickets!
      }
    }
  }
  if (%raffle == 0) {
    msg $chan Raffle is currently closed!
  }
}
on *:TEXT:!raffle open:#:{
  if ($nick isop #) {
    if (%raffle == 0) {
      msg $chan RAFFLE IS NOW OPEN!!
      set %raffle 1
      write -c Raffle.txt
    }
  }
}
on *:TEXT:!raffle close:#:{
  if ($nick isop #) {
    if (%raffle == 1)  {
      msg $chan RAFFLE IS NOW CLOSED!!
      set %raffle 0
      write -c Raffle.txt
    }
  }
}
on *:TEXT:!roll:#:{
  if ($nick isop #) {
    if (%raffle == 1) {
      var %user = $read(Raffle.txt, n)
      msg $chan RAFFLE IS NOW BEING ROLLED, GOOD LUCK!!
      .timerOne 1 1 msg $chan /me 5!
      .timerTwo 1 2 msg $chan /me 4!
      .timerThree 1 3 msg $chan /me 3!
      .timerFour 1 4 msg $chan /me 2!
      .timerFive 1 5 msg $chan /me 1!
      .timerSix 1 6 msg $chan AND THE WINNER IS:
      .timerSeven 1 7 msg $chan %chat
      set %raffle 0
      write -c Raffle.txt
    }
  }
}

Re: need help with a twitch bot [Re: Fandydur] #247895
04/09/14 07:50 AM
04/09/14 07:50 AM
Joined: Mar 2014
Posts: 20
R
raven124 Offline
Ameglian cow
raven124  Offline
Ameglian cow
R

Joined: Mar 2014
Posts: 20
here you go all you have to do is swap out what you have for the raffle part but make sure when someone goes to buy a ticket they put a number after it if they leave it blank and just do !buyticket it wont work.


on $*:TEXT:/!buyticket /Si:#:{
if ($2 isnum) {
if ($2 > 10) {
msg $chan Sorry $nick but you can only up to 10 tickets
}
if ($2 < 11) {
var %i = 0
var %ticket = $2
var %topic = $+(#,.,$nick)
var %user = $readini(Points.ini,%topic,Points)
var %end = 10 * %ticket
var %delete = %user - %end
if (%delete > 0) {
writeini -n Points.ini %topic Points %delete
while (%i < %ticket) {
write Raffle.txt $nick
%i = %i + 1
}
msg $chan $nick you have bought %ticket tickets with %end points.
}
if (%delete < 0) {
msg $chan Sorry $nick you don't have enough points to buy %ticket tickets!
}
}
}
if (%raffle == 0) {
msg $chan Raffle is currently closed!
}
}
on $*:TEXT:/!raffle /Si:#:{
if ($nick isop #) {
if ($2 == open) {
if (%raffle == 0) {
msg $chan RAFFLE IS NOW OPEN!!
/set %raffle 1
write -c Raffle.txt
}
}
}
if ($2 == close) {
if (%raffle == 1) {
msg $chan RAFFLE IS NOW CLOSED!!
/set %raffle 0
write -c Raffle.txt
}
}
}


on *:TEXT:!roll:#:{
if ($nick isop #) {
if (%raffle == 1) {
var %user = $read(Raffle.txt)
msg $chan RAFFLE IS NOW BEING ROLLED, GOOD LUCK!!
.timer1 1 1 msg $chan /me 5!
.timer2 1 2 msg $chan /me 4!
.timer3 1 3 msg $chan /me 3!
.timer4 1 4 msg $chan /me 2!
.timer5 1 5 msg $chan /me 1!
.timer6 1 6 msg $chan AND THE WINNER IS:
.timer7 1 7 msg $chan %user
.timer8 1 8 msg $chan TH RAFFLE IS NOW OVER
set %raffle 0
write -c Raffle.txt
}
}
}