mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2014
Posts: 18
D
DvD_cD Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 18
I write one code for my twitch chat bot.
Code:
on *:TEXT:!mod*:#: {
  if ($nick isop #) {
    if ($2 == giw) {
      if ($3 == start) {
        msg $chan Giveaway start!
        set %giw on
        } elseif ($3 == stop) {
        msg $chan Giveaway was closed.
        set %giw off
        }  { return } elseif ($3 == pauseon) {
        if (%giw == off) {
          msg $chan Giveaway is currently paused.
          } else {
          msg $chan Giveaway was paused.
          set %giw off
        }
      }
      { return } { return } elseif ($3 == pauseoff) {
        if (%giw == on) {
          msg $chan Giveaway is currently unpaused.
          } else {
          msg $chan Giveaway was unpaused.
          set %giw on
        }
      }
      { return } { return } else ($3 == status) {
        if (%giw == on) {
          msg $chan Giveaway status: ON
          } else (%giw == off) {
          msg $chan Giveaway status: OFF
        }
      }
    } 
  }
}


Where is the problem:

Quote:
Me: !mod giw start
Bot: Giveaway start!

Me: !mod giw stop
Bot: Giveaway was closed.

Me: !mod giw pauseon
Bot: Giveaway was closed.



And this with all:
  • !pauseon
  • !pauseoff
  • !status

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
See http://en.wikichip.org/wiki/Introduction_-_mIRC, specifically the part about block of code

You cannot put elseif on the same line right after the }, or you need a pipe character: '|'
The way you use { return } is also wrong


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Mar 2014
Posts: 18
D
DvD_cD Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 18
But if i don't use { return }, the bot says all commands like that:
Quote:
Giveaway start!
Giveaway was closed.
Giveaway is currently paused.
Giveaway was paused.


It just fires them all off.
Show me how its done.

Joined: Feb 2011
Posts: 448
K
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 448
Code:
on *:TEXT:!mod*:#: {
  if ($nick isop #) {
    if ($2 == giw) {
      if ($3 == start) {
        msg $chan Giveaway start!
        set %giw on
      } 
      elseif ($3 == stop) {
        msg $chan Giveaway was closed.
        set %giw off
      } 
      elseif ($3 == pauseon) {
        if (%giw == off) {
          msg $chan Giveaway is currently paused.
        } 
        else {
          msg $chan Giveaway was paused.
          set %giw off
        }
      }
      elseif ($3 == pauseoff) {
        if (%giw == on) {
          msg $chan Giveaway is currently unpaused. 
        } 
        else {
          msg $chan Giveaway was unpaused.
          set %giw on
        }
      }
      elseif  ($3 == status) {
        if (%giw == on) { msg $chan Giveaway status: ON } 
        elseif (%giw == off) { msg $chan Giveaway status: OFF }
      }
    }
  }
}


Skimmed though and kinda fixed it. I didn't want to mess with your `return` attempts, so I just removed it for my own sanity.


<@KindOne> !mod giw start
<bot> Giveaway start!
<@KindOne> !mod giw stop
<bot> Giveaway was closed.
<@KindOne> !mod giw status
<bot> Giveaway status: OFF
<@KindOne> !mod giw start
<bot> Giveaway start!
<@KindOne> !mod giw status
<bot> Giveaway status: ON

Start reading the wiki and run this. It will show syntax issues. http://www.msldev.com/

Joined: Mar 2014
Posts: 18
D
DvD_cD Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 18
10x dude <3

Joined: Mar 2014
Posts: 18
D
DvD_cD Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 18
New problem... frown

Quote:
on *:TEXT:!mod*:#: {
if ($nick isop #) {
if ($2 == giw) {
if ($3 == start) {
msg $chan The giveaway has started!
set %giw on
}
elseif ($3 == clear) {
msg $chan Nobody is in the giveaway now.
set %giw off
/white -c giw.ini
}
elseif ($3 == pause) {
if (%giw == off) {
msg $chan Giveaway is currently paused.
}
else {
msg $chan Giveaway was paused.
set %giwpause off
}
}
elseif ($3 == unpause) {
if (%giw == on) {
msg $chan Giveaway is currently unpaused.
}
else {
msg $chan Giveaway was unpaused.
set %giwpause on
}
}
else ($3 == status) {
if (%giw == on) { msg $chan Giveaway status: ON }
elseif (%giw == off) { msg $chan Giveaway status: OFF }
}
}
elseif ($2 == cmd) {
if ($3 == giw) {
msg $chan start, clear, pause, unpause, status
}
elseif ($3 == bug) {
msg $chan show, clear
}
}
elseif ($2 == lottery) {
if ($3 == start) {
msg $chan The lottery has started! Type <!enter lotter> to join. Cost 25 points, and you can get $4 points!
}
}
elseif ($2 == bug) {
if ($3 == show){
msg $chan $read(bugreport.txt)
}
elseif ($3 == clear) {
/white -c bugreport.txt
msg $chan Bug reports was cleared.
/write bugreport.txt No bug reports.
}
}
}
else {
msg $chan You must to be mod to use this command.
}
}



Now everyting without !mod giw (!mod cmd/bug/lottery) dont work :(( I can't understand why ;?

Joined: Feb 2011
Posts: 448
K
Pan-dimensional mouse
Offline
Pan-dimensional mouse
K
Joined: Feb 2011
Posts: 448
Just quickly looked it it.. well, used mSLDev

Open the script in mSLDev. It will make this EXTREMELY easy to fix.

You will see issues at lines 31 and 50.

Line 31 is suppose to be `elseif` not `else`.

Line 50 is kinda self explanatory.

`/white` what? Typo...


http://www.msldev.com
http://en.wikichip.org/wiki/MIRC

Joined: Mar 2014
Posts: 18
D
DvD_cD Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 18
This mSLDev realy help a lot o.o
Btw, how to make symbol for noting?
I mean:
if ($2 == "noting")

Like:
on *:TEXT:!test*:#: {
if ($2 == 1)
msg $chan Number is $2
}
elseif (2$ == "noting") {
smg $chan Invalid command. !test <number> is right.
}

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
$null

Joined: Mar 2014
Posts: 18
D
DvD_cD Offline OP
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 18
Originally Posted By: Loki12583
$null




Ok tanks, and what is the opposite of this?
If i use only this:
Quote:
on *:TEXT:!bugreport*:#: {
if ($2 == $null) {
msg $chan Type <!bugreport info> for more information.
}
elseif ($2 == info) {
msg $chan If you found a bug, you can report it with this command: !bugreport <something>
}
/write -il1 bugreport.txt $2-
msg $chan The bug report was sended! 60 second delay for next report.
}


and somebody type only <!bugreport>, bot says this:
Quote:
Bot: Type <!bugreport info> for more information.
Bot: The bug report was sended! 60 second delay for next report.

Last edited by DvD_cD; 08/03/14 03:46 PM.

Link Copied to Clipboard