mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 3 1 2 3
#108020 16/01/05 08:43 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
i recently went ahead and made a help system for my bot
while it isnt very complex its pretty long i was looking for suggestions to shorten it
sigh deep breath
-----------------------------code----------------------------------------
#help on
on *:text:!help:*:{
if (%i = on) { halt }
else { msg $nick $read(help.txt,n,1) }
{ msg $nick $read(help.txt,n,2) }
{ msg $nick $read(help.txt,n,3) }
{ msg $nick $read(help.txt,n,4) }
{ msg $nick $read(help.txt,n,5) }
{ msg $nick $read(help.txt,n,6) }
{ msg $nick $read(help.txt,n,7) }
{ msg $nick $read(help.txt,n,8) }
{ msg $nick $read(help.txt,n,9) }
{ msg $nick $read(help.txt,n,10) }
{ msg $nick $read(help.txt,n,11) }
{ set -s %i on }
{ timer 1 20 unset -s %i }
}
on *:text:!help !qme:*:{
if (%j = on) { halt }
else { msg $nick $read(help.txt,n,12) }
{ set -s %j on }
{ timer 1 20 unset -s %j }
}
on *:text:!help !say:*:{
if (%k = on) { halt }
else { msg $nick $read(help.txt,n,13) }
{ set -s %k on }
{ timer 1 20 unset -s %k }
}
on *:text:!help !die:*:{
if (%l = on) { halt }
else { msg $nick $read(help.txt,n,14) }
{ set -s %l on }
{ timer 1 20 unset -s %l }
}
on *:text:!help !join:*:{
if (%m = on) { halt }
else { msg $nick $read(help.txt,n,15) }
{ set -s %m on }
{ timer 1 20 unset -s %m }
}
on *:text:!help !part:*:{
if (%n = on) { halt }
else { msg $nick $read(help.txt,n,16) }
{ msg $nick $read(help.txt,n,17) }
{ set -s %n on }
{ timer 1 20 unset -s %n }
}
on *:text:!help !cycle:*:{
if (%o = on) { halt }
else { msg $nick $read(help.txt,n,18) }
{ set -s %o on }
{ timer 1 20 unset -s %o }
}
on *:text:!help !enable:*:{
if (%p = on) { halt }
else { msg $nick $read(help.txt,n,19) }
{ msg $nick $read(help.txt,n,20) }
{ set -s %p on }
{ timer 1 20 unset -s %p }
}
on *:text:!help !disable:*:{
if (%q = on) { halt }
else { msg $nick $read(help.txt,n,21) }
{ set -s %q on }
{ timer 1 20 unset -s %q }
}
on *:text:!help !ruser:*:{
if (%r = on) { halt }
else { msg $nick $read(help.txt,n,22) }
{ msg $nick $read(help.txt,n,23) }
{ set -s %r on }
{ timer 1 20 unset -s %r }
}
on *:text:!help !pass:*:{
if (%s = on) { halt }
else { msg $nick $read(help.txt,n,21) }
{ set -s %s on }
{ timer 1 20 unset -s %s }
}
#help end
----------------------------------code----------------------------------


The Kodokan will move you, one way or another.
#108021 16/01/05 09:22 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
#help on
on *:text:!help:*:     { if (%i != on) { sendhelp $nick 1 11  | set -su20 %i on }
on *:text:!help !qme:*:{ if (%j != on) { sendhelp $nick 12 12 | set -su20 %j on }
on *:text:!help !say:*:{ if (%k != on) { sendhelp $nick 13 13 | set -su20 %k on }
on *:text:!help !die:*:{ etc etc etc
...
on *:text:!help !pass:*:{ if (%s != on) { sendhelp $nick 21 21 | set -su20 %s on }

alias -l sendhelp { 
  var %i = $2
  while (%i <= $3) {
    msg $1 $read(help.txt,n,%i)
    inc %i
  }
}


if u wanted to reformat your help.txt file to like this
[help]
old line1
old line2
old line3
...
old line11
[!qme]
old line12
[!say]
old line13

etc etc
you could now use this
Code:
#help on
on *:text:!help:*:     { if (%i != on) { play -thelp $nick 0  | set -su20 %i on }
on *:text:!help !qme:*:{ if (%j != on) { play -t!qme $nick 0  | set -su20 %j on }
on *:text:!help !say:*:{ if (%k != on) { play -t!say $nick 0  | set -su20 %k on }
on *:text:!help !die:*:{ etc etc etc
...
on *:text:!help !pass:*:{ if (%s != on) { play -t!pass $nick 0  | set -su20 %s on }


This is heaps better as it allows you to add lines with out the code needing adjustment.

#108022 16/01/05 09:27 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Oh my... I'm amazed the parser allows { as the first character in a line!
  • Who told you that you have to put every command between braces { } ? like

    { msg $nick $read(help.txt,n,1) }
    { msg $nick $read(help.txt,n,2) }

    The way to use if-then-else is like this:

    if (condition) {
    commands
    }
    elseif (another condition) {
    other commands
    }
    else {
    commands to do when no conditions have been met
    }

    And of course the if-then-else can be nested in other if then else constructs.

    You see how each condition starts with an opening brace { and ends that part of the code with a closing brace } ?

    Note that the else part isn't mandatory, if you don't have default commands, then you just leave it, instead of what some people do, which is totally obsolete: else { halt }


  • Note that braces are only needed to group multiple commands together.

    In the case of single commands, you don't need them, but you can use them. Always use either brackets ( ), or braces { }, or preferably both of them together ( ) { }, unless if you really know what you are doing.

    Example:

    Code:
    alias myalias {
    [color:red]  [/color] 
      if ($1 == !test) echo -a only brackets 
    [color:red]  [/color] 
      elseif $1 == !help { echo -a only braces }
    [color:red]  [/color] 
      elseif ($1 == !add) { echo -a both brackets and braces }
    [color:red]  [/color] 
      elseif $1 == !info {
    [color:red]  [/color] 
        echo -a first command
        echo -a second command
        echo -a third command
    [color:red]  [/color] 
      }
    
      else { echo -a Unknown command: $1 }
    
    }


  • The if, elseif, else construct has as benefit that if one condition matches, mirc will discard the following "elseifs" and "else" and goes to the end of the elseif/else conditions. This speeds up processing, as otherwise mIRC would go through each of those "if" lines to look if $1 matches, but that is completely obsolete, since it already matched exclusively.

    For example, in that alias I just provided, if you do: /myalias !test, mirc will do the following:

    1. it matches: if ($1 == !test)
    2. it performs the commands that go with that match: echo -a only brackets
    3. it sees that the rest of the if conditions are elseif's and an else, so the alias is finished.


    In some cases, it's needed to do multiple if's without making mIRC stop the script after having 1 match.

    Example:
    Code:
    alias alphabet {
    [color:red]  [/color] 
      if (*a* iswm $1) { echo -a found an "a" }
      if (*b* iswm $1) { echo -a found a "b" }
      ...
      if (*z* iswm $1) { echo -a found a "z" }
    [color:red]  [/color] 
    }
    
    


    Now if we do: /alphabet azerty

    What does mIRC do?

    1. it matches: if (*a* iswm $1)
    2. it performs the command associated with the match: echo -a found an "a"
    3. it matches: if (*e* iswm $1)
    4. it performs the command associated with the match: echo -a found an "e"
    ...

    In this case, we don't want to use elseif's, because after finding 1 match, mirc would skip all the elseif's and else, while we want to actually check each condition.
  • The examples provided are solely for educational purposes, and to get a point accross.

  • I didn't look at the rest, because I would have ended up rewriting your whole script. There is a lot of room to improve ricky, good luck!

Greeits

Last edited by FiberOPtics; 16/01/05 10:26 AM.

Gone.
#108023 16/01/05 10:04 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
it works fine actually
i was just looking to shorten it


The Kodokan will move you, one way or another.
#108024 16/01/05 10:20 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well, if you remove all those excessive braces, it will already be half as long :tongue:


Gone.
#108025 16/01/05 10:41 PM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
i actuallydid that
ill still need a modular alias for that global antiflood thing

and if dave could swoop in and clarify that bit of code he provided after the alias section
i couldnt quite follow it


The Kodokan will move you, one way or another.
#108026 16/01/05 10:52 PM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
A note before I do anything else, for some reason a closing } are missing off all my lines for some reason, i thought it was the cut and paste but now i think i might have deleted them by accident, oh well hope it didnt cuase confusion.

lines such as
on *:text:!help:*: { if (%i != on) { sendhelp $nick 1 11 | set -su20 %i on }
should have been
on *:text:!help:*: { if (%i != on) { sendhelp $nick 1 11 | set -su20 %i on } }

but anyway.... what bit didnt uou understand?
was it the alias -l sendhelp or the suff about the reformating and using /play ?


Oh PS: this was formated baddly
Code:
on *:text:!help:*:{
  if (%i = on) { halt }  
  else { msg $nick $read(help.txt,n,1) }
  { msg $nick $read(help.txt,n,2) }
  ...
  { msg $nick $read(help.txt,n,11) }
  { set -s %i on }
  { timer 1 20 unset -s %i }
}

it just happened to do what u wanted, only line 1 was part of the ELSE construct, the rest were always going to be executed by the event, its just that you had used HALT to stop the other condition from procedding to the line following the IF's construct, being this line ... { msg $nick $read(help.txt,n,2) }

[edit]

EEEEEEK omg i stuffed up the /play commands as well
they all should be like this play -thelp $nick help.txt 0 with the help.txt file specified after the $nick

Last edited by DaveC; 16/01/05 10:56 PM.
#108027 16/01/05 11:24 PM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
the alias
and im unclear of the suggested reformat
do you want me to make each section its own txt
or what
thats alot of switches on play you might want to include what they do if we are to learn anything

Last edited by ricky_knuckles; 16/01/05 11:26 PM.

The Kodokan will move you, one way or another.
#108028 17/01/05 12:00 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
ok the alias, but first...

on *:text:!help !pass:*:{ if (%s != on) { sendhelp $nick 21 21 | set -su20 %s on } }
When someone says "!help !pass" u want to msg them line 21 of the file IF %s is not "on", so i check %s not = to "on" and if so, then i call my alias passing it who to send to in $1, starting line to send in $2, ending line in $3, aka "$nick 21 21", then i set %s to "on" with the auto unset option in 20 seconds.
So now u know what the event does, but more specificly what my alias is ment to do.

Code:
alias -l sendhelp { 
  var %i = $2
  while (%i <= $3) {
    msg $1 $read(help.txt,n,%i)
    inc %i
  }
}

The -l stops something else calling sendhelp besides your events, liekly not needed but who knows.
ok I set %i to the starting line to send
i then start a while loop that keeps going whilel %i is less or = to the ending line, in that loop, i send $1 (the $nick) said %i line from the file, then add one to %i, it then repeats untill %i is greater than the ending line (which happens to be the starting line also in !pass)

The second option i gave you, you must reformat the help.txt file, its still text, but u need section headers in [ ], then u can use the /play command to just play (msg) all the lines in that section to the $nick
the file might look like this...
[help]
this is my help on my bot there are a buch of commands it can do.
you can get help on each of them by doing
!help !qme
!help !say
!help !die
[!qme]
The !qme command well it doesnt work on tuesdays
Unless your blonde and good looking and interested in me.
[!die]
The !die command makes you drop dead right there at your pc.
[!say]
The !say command well it doesnt say much right now
[!bobthemagicdragon]
The command makes bob the dragon appear, ps hes magic


doing a " /play -t!qme $nick help.txt 0 " well play (msg) $nick the following 2 lines.....
The !qme command well it doesnt work on tuesdays
Unless your blonde and good looking and interested in me.

becuase they were under the heading !qme the bit follwoing the -t

For more help on /play, just type /HELP /PLAY in mirc.

#108029 17/01/05 12:07 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
ok well i understand the play formatted one now i dont think ill ever be able to follow the first one
thanks,


The Kodokan will move you, one way or another.
#108030 17/01/05 12:19 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
i just read the that u said soemthing about a modualr alias to stop it flooding? was that it.

Well the /play command is your option of choice, I set 0 (zero) on the end, becuase i thought u wanted it that fast, but if u set that to another number it delays by that long in 1/1000ths of a second, so 500 is 1/2 second, its defualt is 1000 if u leave it out.

#108031 17/01/05 12:20 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Jusr a note about the /play model. I would not use it with a delay of 0 unless you like being flooded off. try 1000 or 1500. smile

#108032 17/01/05 12:39 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
aliases
/flooda {
set -s %i on
timer 1 5 unset -s %i
}
aliases
remotes
#help on
on *:text:!help:*:{
if (%i != on) { play -t!help $nick help.txt 2000
flooda
}
}
on *:text:!help !qme:*:{
if (%i != on) { play -t!qme $nick help.txt 2000
flooda
}
}
on *:text:!help !say:*:{
if (%i != on) { play -t!say $nick help.txt 2000
flooda
}
}
on *:text:!help !die:*:{
if (%i != on) { play -t!die $nick help.txt 2000
flooda
}
}
on *:text:!help !join:*:{
if (%i != on) { play -t!join $nick help.txt 2000
flooda
}
}
on *:text:!help !part:*:{
if (%i != on) { play -t!part $nick help.txt 2000
flooda
}
}
on *:text:!help !cycle:*:{
if (%i != on) { play -t!cycle $nick help.txt 2000
flooda
}
}
on *:text:!help !enable:*:{
if (%i != on) { play -t!enable $nick help.txt 2000
flooda
}
}
on *:text:!help !disable:*:{
if (%i != on) { play -t!disable $nick help.txt 2000
flooda
}
}
on *:text:!help !ruser:*:{
if (%i != on) { play -t!ruser $nick help.txt 2000
flooda
}
}
on *:text:!help !pass:*:{
if (%i != on) { play -t!pass $nick help.txt 2000
flooda
}
}
#help end

Last edited by ricky_knuckles; 17/01/05 01:17 AM.
#108033 17/01/05 12:43 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Every single one of those if (%i = on) { halt }'s are pointless.


New username: hixxy
#108034 17/01/05 12:49 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
thats true
i put them in because i originally didnt have the != line
but thnks for pointing that out
you failed to mention all the other error that i caught but thanks
like after the 3rd line down play became plat and != became =


The Kodokan will move you, one way or another.
#108035 17/01/05 12:49 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Also half of the time play is mispelt plat
and many of these
  • f (%i = on) { halt }
    if (%i = on) { plat -t!pass $nick help.txt 2000


Code:
  if (%i [color:red]![/color]= on) { pla[color:red]y[/color] -t!pass $nick help.txt 2000 

#108036 17/01/05 12:52 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
already fixed both of those
but good eye


The Kodokan will move you, one way or another.
#108037 17/01/05 12:56 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
I noticed, I just presumed you'd left all of the !'s out because you got bored of typing them. wink


New username: hixxy
#108038 17/01/05 12:58 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
None of these events can work properly, because you are not using an opening and closing brace, to group multiple code constructs, as I've told you in that long post.

on *:text:!help !pass:*: {
if (%i != on) {
play -t!pass $nick help.txt 2000
flood
}
}

I don't know what "flood" is, i suppose it's an alias you are triggerin, so I grouped it like that.

Greets


Gone.
#108039 17/01/05 01:00 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
/flood:
Quote:
-
* Flood protection is off
* Ctcp protection is on
-


New username: hixxy
#108040 17/01/05 01:02 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Ah ok, never had to use that smile and glad about it too might i add!

Oh it turns out he had made a custom alias after all: check:

aliases
/flood {
set -s %i on
timer 1 5 unset -s %i
}


Greets

Last edited by FiberOPtics; 17/01/05 01:03 AM.

Gone.
#108041 17/01/05 01:08 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
thanks for the wisdom on shortening my whole code
ill try to carry this through my whole script
which should half its size

ill keep working on those brackets smile


The Kodokan will move you, one way or another.
#108042 17/01/05 01:14 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
[edit]
just added them outer most { }, thanks for the pointout FiberOPtics
/me is making mistakes becuase hes to lazy to make the help.txt file, and clone in to trigger the events, to check his code frown


Code:
#help on
on *:text:!help:*:{
  if (%i != on) { 
    play -t!help $nick help.txt 2000 
    set -su5 %i on
  }
}
on *:text:!help !*:*:{
  if ((%i != on) && ($istok(!say !die !join !part !cycle !enable !disable !ruser !pass,$2,32))) { 
    play -t $+ $2 $nick help.txt 2000
    set -su5 %i on
  }
}
#help end

1st event does !help
2nd event does !help !* and then checks if $2 being the !* matches one of your options, if so plays it, the SET needs no timer unset becuase the -u5 unsets it in 5 seconds


Im sure theres a method of getting if a section header exists in an INI but i cant think of what it is, maybe someone else can adjust the code for it. as well

Last edited by DaveC; 17/01/05 01:57 AM.
#108043 17/01/05 01:20 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
fixed
anything else?


The Kodokan will move you, one way or another.
#108044 17/01/05 01:27 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
mildly confused about
"Oh my... I'm amazed the parser allows { as the first character in a line!}
is that reffering to the on *:text:*:*: {
that you later told me to use


The Kodokan will move you, one way or another.
#108045 17/01/05 01:28 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
$ini()

//if $ini(mirc.ini,text) { echo -a $ini(mirc.ini,$v1) is the $ord($v1) header in the file containing $ini(mirc.ini,$v1,0) items }

#108046 17/01/05 01:30 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
on *:text:*:*: {

the brace isn't the first on the line, the first on the line there is "on" :tongue:

Opening braces never go alone on a line as the first char...ever.


Opening chars are only used when:
  • The start of an alias, right after the alias name (although its not necessary, if the commands or constructs are either all piped on one full line, or if there's simply only one command)

    alias myalias {
    do things
    }
  • For opening an event, whether that is a regular event, raw event, ctcp event etc.

    on *:TEXT:*:*: {
    do things
    }

    Same comments as with the alias, they are only needed to group multiple commands or if then else constructs
  • For creating popup menu's for nicklist, channel, etc;

    menu channel {
    popups
    }
  • For ordering if then else constructs:

    if (condition) {
    stuff
    }
    elseif (other condition) {
    do other stuff
    }
    else {
    do default stuff
    }

    A while condition is actually an if condition (or multiple ones) in a while loop, so they go with this category.

    while (condition) {
    do things
    }
  • Opening a dialog (thanks tidy smile):

    dialog mydialog {
    dialog code
    }


    There could be more, but to be honest, I have been up for 24 hours and 42 minutes now, a person tends to forget things at that time :tongue:

Greets

Last edited by FiberOPtics; 17/01/05 01:56 AM.

Gone.
#108047 17/01/05 01:31 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well Dave accidentally misused the brackets as well, but Im sure he'll fix em up in a minute.

It has evolved pretty far huh from your original way? I know some ways that could do it with even less code, but that's irrelevant at this point. It looks good.

You could add some small things here and there, but for now, is more than good, and soooo much shorter.

Cya around!


Gone.
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
I believe it was about these ones
on *:text:!help:*:{
if (%i = on) { halt }
else { msg $nick $read(help.txt,n,1) }
{ msg $nick $read(help.txt,n,2) }
{ msg $nick $read(help.txt,n,3) }
{ msg $nick $read(help.txt,n,4) }
...
...

#108049 17/01/05 01:49 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
well now i have to run around and get all the brackets off the start of lines


The Kodokan will move you, one way or another.
#108050 17/01/05 01:52 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
The only other thing I can think of is a dialog table:

Code:
dialog name {
  controls and stuff
}


New username: hixxy
#108051 17/01/05 01:53 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well, only the opening brackets but yeah, it would be a good idea to go over all your code that you have, to check that out.

Cya!


Gone.
#108052 17/01/05 01:56 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Hehe thanks I added it...hmm any others? I'm blank at this point lol.


Gone.
#108053 17/01/05 02:03 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
They can actually be used pretty much anywhere, i've seen people use them where they have absolutely no use at all, but the code works fine, eg:

Code:
alias test {
  goto test
  return
  :test {
    echo -a test
    echo -a 1 2 3
  }
}


In fact, I suppose you could use that to name or describe blocks of code without using comments:

Code:
alias test {
  :echo some numbers {
    echo -a 1
    echo -a 2
  }
  :message a few channels {
    msg #chan1 hi
    msg #chan2 there.
  }
}


New username: hixxy
#108054 17/01/05 02:10 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
#help on
on *:text:!help:*:{
  if (%i != on) { 
    play -t!help $nick help.txt 2000 
    set -su5 %i on
  }
}

on *:text:!help !*:*:{
  if ((%i != on) && ($ini(help.txt,$2))) { 
    play -t $+ $2 $nick help.txt 2000
    set -su5 %i on
  }
}
#help end

2nd on uses the HELP.TXT file to make sure u have help for that topic, then displays it
you could incoperate the 1st event into it, but i think it would make the code more complexe than its worth.

Thanks for $ini Iori

/me looks around sheepishly becuase he couldn't think of the indentifier for INI file data

#108055 17/01/05 02:11 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
Well ok, though the examples I gave him are the ones that are used with a purpose.

I know you can do: on *:TEXT:!test:#:{ { { { msg # matched !test } } } }

As long as the opening brackets match the opening ones, all is good, but they are obsolete.

Nice to mention it though, I hadn't seen it used in a goto like that, even though they don't serve a purpose there at all.

Cya tidy

Edit: lol that commenting is nice, I never really use goto statements though, aside for a select statement.

Last edited by FiberOPtics; 17/01/05 02:13 AM.

Gone.
#108056 17/01/05 02:12 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
its done no brackets on starts
no openers any ways
plently of closers
my code dropped about 20 lines
and almost half that is just
}
}
so altogether no too shabby
im glad my topic could inspire so much conversation among u guys
thanks again

Last edited by ricky_knuckles; 17/01/05 02:13 AM.

The Kodokan will move you, one way or another.
#108057 17/01/05 02:18 AM
Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
Code:
#help on
on *:text:!help*:#:{
  if ($1 == !help) {
    if ($2 == $null) { tokenize 32 $1 $1 }
    if ($ini(help.txt,$2)) && (%i != on) {  
      play -t $+ $2 $nick help.txt 2000
      set -su5 %i on
    }
  }
}
#help end


New username: hixxy
#108058 17/01/05 02:24 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
Q. Why does %i exist? The code is inside a #group. If the group is 'on' the code executes, if the group is 'off' it won't. You could enable|disable the group from wherever it is you set "%i" and eliminate that condition check. smile

#108059 17/01/05 02:43 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
yeah its more complexe than its worth, but what the heck.

try this.

Code:
#help on
on *:text:!help*:#:{
  if (%i != on) && ($1 == !help) {
    if ($2 == $null) { tokenize 32 - Help }
    if ($ini(help.txt,$2)) {  
      play -t $+ $2 $nick help.txt 2000
      set -su5 %i on
    }
  }
}
#help end


checked %i first since if its ON you never do anything anyway
tokenize 32 - Help , since $1 isnt needed and its fractionally faster to uses a hardcoded filler also default help section was [help] (but that could have been changed in the text file),

#108060 17/01/05 02:46 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
set -su5 %i on

^ its in the event, its his anti flooder, makes the bot only answer one request every 5 seconds

#108061 17/01/05 02:47 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
just a simple little antiflood timer deal
everytime one of the help commands is used it sets it to on
and a timer that unsets it after 5 seconds
so you cant call something from the help section faster than every 5 seconds
im sure this isnt the best way but i have to stay with what i can understand

Last edited by ricky_knuckles; 17/01/05 02:48 AM.

The Kodokan will move you, one way or another.
#108062 17/01/05 02:51 AM
Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
What Iori means is this:

Instead of this:

Code:
#help on
on *:text:!help*:#:{
  if (%i != on) && ($1 == !help) {
    if ($2 == $null) { tokenize 32 - Help }
    if ($ini(help.txt,$2)) {  
      play -t $+ $2 $nick help.txt 2000
      set -su5 %i on
    }
  }
}
#help end


We do this:

Code:
#help on
on *:text:!help*:#:{
  if ($1 == !help) {
    if ($2 == $null) { tokenize 32 - Help }
    if ($ini(help.txt,$2)) {  
      play -t $+ $2 $nick help.txt 2000
      .disable #help
      .timer 1 5 .enable #help   
    }
  }
}
#help end

This provides the same function, without having the if check for %i

You could put it in an alias:

alias nohelp .disable #help | .timer 1 5 .enable #help

and then simply specify "nohelp" after that play command.

Greets


Gone.
#108063 17/01/05 02:57 AM
Joined: Aug 2003
Posts: 1,831
I
Hoopy frood
Offline
Hoopy frood
I
Joined: Aug 2003
Posts: 1,831
OK, but /play queues requests, mIRC won't /play more than one request at a time. There is also the -qN and -mN switches whch limit the amount of requests that can be queued. smile

#108064 17/01/05 03:13 AM
Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
OK, but /play queues requests, mIRC won't /play more than one request at a time. There is also the -qN and -mN switches whch limit the amount of requests that can be queued. smile


Thats my fault he originally was messaging all of it instantly, so i set the plays using 0 delay, so didnt do any -m or -q, but since the lines are short, he could still get caught flooding with a -m1 he would need to put minimal of 3 lines for each section (not a hard feat i guess)

#108065 17/01/05 04:22 AM
Joined: Nov 2004
Posts: 332
R
Fjord artisan
OP Offline
Fjord artisan
R
Joined: Nov 2004
Posts: 332
if (%i != on) && ($1 == !help) {
if ((%i != on) && ($1 == !help))
edit
certainly was that bit of code is cursed
cursed i tell you

Last edited by ricky_knuckles; 17/01/05 05:42 AM.
#108066 17/01/05 05:06 AM
Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Was those red braces symbolize mistakes? Because that is still wrong.

if ((%i != on) && ($1 == !help))

Page 1 of 3 1 2 3

Link Copied to Clipboard