mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Sep 2009
Posts: 52
Z
ziv Offline OP
Babel fish
OP Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
I'm trying to make a bot I would be able to re-script remotely, but it's giving me trouble...

This is a section of the code that seats in mIRC:
Code:

;;The Support commands, for internal use.

alias exc $replace($reptok($reptok($reptok($reptok($reptok($1-,var,_set,0,32),set,_set,0,32),unset,_unset,0,32),inc,_inc,0,32),dec,_dec,0,32),<&>,$chr(36),<!>,%zBOT_)
alias reval $return $eval($replace($1-,<&>,$chr(36),<!>,$chr(37)),1)

alias _set set %ZBOT_ $+ $1 $2-
alias _unset unset %ZBOT_ $+ $1
alias _inc inc %ZBOT_ $+ $1 $2-
alias _dec dec %ZBOT_ $+ $1 $2-

;;Built-in event section;;

on *:text:*:*:{
  var %file = $mircdirzBOT\ $+ $event 
  var %i = 1
  while %i <= $lines(%file) && $read($mircdirmSS\Config,5) == 1 {
    var %line = $read(%file,%i)
    tokenize 32 %line
    if $1 == <&>if {
      tokenize 32 $eval($replace(%line,<&>,$chr(36),<!>,%zBOT_),1)
      if $2- {
        inc %i
        var %line = $eval($replace($read(%file,%i),<&>,$chr(36),<!>,%zBOT_),1)
        var %i = %line
      }
      else {
        inc %i 2
        var %line = $eval($replace($read(%file,%i),<&>,$chr(36),<!>,%zBOT_),1)
        var %i = %line         
      }
    } 
    elseif $1 == <&>goto {
      var %i = $2
    }
    else {
      exc $1-
      inc %i
    }
  }
}




This code is from $mircdirzBOT\Text:

Code:
#1:<&>if <&>left(<&>1,1) == &
#2:4
#3:17
#4:<&>if <&>read(<&>mircdirzBOT\users,s,<&>address(<&>nick,10)) >= <&>gettok(<&>read(<&>mircdirzBOT\commands,s,<&>mid(<&>1,2,<&>calc(<&>len(<&>1)-1))),2,32)
#5:7
#6:17
#7:set <!>i 1
#8:<&>if <!>i <= <&>lines(<&>mircdirzBOT\command_ <&>+ <&>mid(<&>1,2,<&>calc(<&>len(<&>1)-1)))
#9:11
#10:15
#11:set <!>line <&>reval(<&>read(<&>mircdirzBOT\command_ <&>+ <&>mid(<&>1,2,<&>calc(<&>len(<&>1)-1)),<!>i))
#12:exc <!>line
#13:inc <!>i
#14:<&>goto 8
#15:unset <!>i
#16:unset <!>line
#17:noop



It just gives me
7 Unknown command
8 Unknown command
VAR Unknown command

And those are when it doesn't freeze mIRC up...

Edit: And yes, I am aware of the slight changes you can make to the 'inc %i's, I felt that was not important enough for now.
Edit#2: Added line number indicators to the second code.
Edit#2: Added the $reval alias.

Edit#3: Ok, this is the up-to-date code. Now it just starts an infinite loop... smirk
I stopped the loop, thanks to that "&& $read($mircdirmSS\Config,5) == 1", this is what I saw:
1) A ton load of "EXC Unknown Command" in the status window.
2) The vars:
%ZBOT_i 2351
%ZBOT_line $reval($read($mircdirzBOT\command_ $+ $mid($1,2,$calc($len($1)-1)),i))

Edit#4: Made some changes with places where there's a %zBOT_ $+, basically addind [[]]s. Now that ",i))" turned into %zBOT_i.
Still get an infinite loop of "Exc Unknown command" -_-


Any help would be appreciated!
ziv.

Last edited by ziv; 26/06/10 10:28 AM.
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
not sure about ur problem but look into $read(file,np,N)
n = text isn't evaluated
p = | is seen as plain text


I am SReject
My Stuff
Joined: Apr 2010
Posts: 969
F
Hoopy frood
Offline
Hoopy frood
F
Joined: Apr 2010
Posts: 969
Not sure exactly what you are trying to do to be honest. But here's a few ideas:
1) Use mIRC's built in fileserver/DCC to get, edit, then send back to your bot. Then have a !load command

2) Have a "!start <filename>" command, paste your script, with "EOF" as the last line of code. (Inwhich your bot would load it automatically)

3) Explain WHAT you're trying to do with more details. Not just a little description telling us in broad details then a snippet that doesn't work. Explain it to us as if we are 5 year olds smile


I am SReject
My Stuff
Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
One mistake you've made is that in your /exc command you're trying to $replace() a string with %zBOT_, so it will try to evaluate a variable called "%zBOT_", not replace <!> with the string "%zBOT_" as you were hoping.

Change %zBOT_ to % $+ zBOT_

Joined: Sep 2009
Posts: 52
Z
ziv Offline OP
Babel fish
OP Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
I tried a $eval(,0) for that...didn't solve it...your idea might be better...

I'd like to note that DCC is not an option...for reasons beyond me, the bot seats on a mIRC client in a comp that's un-DCC-able. smirk

I'll try to just have it write it down with $eval(,0) and /load -rs it...except they'd all have to go on the same file, can't have a hundred files loaded after all...

The goal was a bot that I could add commands and events to remotely.
The first code goes in mIRC to act uppon certain events,
the second one goes in a file mIRC will scan to perform it's commands when ever an event/command is triggered.

Let's say a user type "&cominfo comadd", this will trigger the OnText event in mIRC, which will the perform all the lines in $mircdirzBOT\Text, in the code there is the check for commands.
The code in "Text" should trigger by the &cominfo, and perform the code in $mircdirzBOT\command_cominfo, which in tern will send the user a notice with information on a command called "comedit".

I hope that helps...
ziv.

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I'm not sure why you're trying to do all of this advanced parsing malarky when you could just write plain mIRC script to the file like this:

Code:
alias -l botflood {
  if (%botflood) noop
  inc -u5 %botflood
  return $v1
}
alias -l botfile return $qt($scriptdirbotfile.mrc)
on admin:text:!bot *:*:{
  if ($1-2 == add script) { write $botfile $3- }
  if ($1-2 == reload script) { reload -rs $botfile } 
  if ($1-2 == run script) { $($3-,2) }
}


Add yourself to the "admin" user level, then just type:

To add an extra line of code - !bot add script <code>
To reload the script when you're done - !bot reload script
To run a script you've added - !bot run script <code>

Not tested but I'm confident it should work laugh

Joined: Nov 2009
Posts: 295
P
Fjord artisan
Offline
Fjord artisan
P
Joined: Nov 2009
Posts: 295
Here is some code I use for a bot I admin. The only access I have to this bot is ftp into it's directory and query/dcc chat. This script uses dcc chat to load/unload scripts that are placed in the scripts directory under mirc.

Code:
on *:chat:~script*:{
  if ($address($nick,7) !isin %loadnicks) halt
  if ($2 == -help) { .msg =$nick ~script -load script_name.mrc | .msg =$nick ~script -unload script_name.mrc | .msg =$nick ~script -list }
  elseif ($2 == -load) && ($exists($+(",scripts/,$3-,"))) { .timer -m 1 500 load -rs $+(",scripts/,$3-,") | set %scriptload $nick | .msg =$nick script loading }
  elseif ($2 == -unload) && ($exists($+(",scripts/,$3-,"))) { .timer -m 1 500 unload -rs $+(",scripts/,$3-,") | set %scriptunload $nick | .msg =$nick script unloading }
  elseif (!$exists($+(",scripts/,$3-,"))) msg =$nick Warning file doesn't exist
  elseif ($2 == -list) {
    set -l %script $script(0)
    while %script > 0 {
      .msg =$nick $script(%script)
      dec %script
    }
    .msg =$nick 4End list
  }
}

;Place this in each script and it will msg you when loaded/unloaded

on *:load: if (%scriptload) { .msg = $+ %scriptload $gettok($script,$numtok($script,92),92) 4loaded | unset %scriptload }
on *:unload: if (%scriptunload) { .msg = $+ %scriptunload $gettok($script,$numtok($script,92),92) 4unloaded | unset %scriptunload }


All you'd need to do i change it to use query rather than dcc so remove = from =$nick and change to on *:text:~script*:?:{

There is also something "extra" that will message you when the script is loaded/unloaded. It sets a variable when you load/unload and the respective script will then message you.

Also forget it warns if you give an invalid file and can list all the loaded scripts. If you change this to use query it'd be best to add a timer to that loop.

If you like this idea and have any questions about my script please just ask

Last edited by pball; 30/06/10 04:00 AM.

http://scripting.pball.win
My personal site with some scripts I've released.
Joined: Sep 2009
Posts: 52
Z
ziv Offline OP
Babel fish
OP Offline
Babel fish
Z
Joined: Sep 2009
Posts: 52
Thank for the help, although I had already not only corrected the code, but ended up opting for an old code I found on the bot's PC which was far simpler, and involved something suggested here, being writing it plainly to the file and then loading it.

Albeit I run my bot via a socket connection method I developed for it back at the time... x>

Thanks a lot anyways!
ziv.


Link Copied to Clipboard