|
Joined: Dec 2008
Posts: 1,483
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,483 |
Hello, I need some help here if anyone can help then please help, i am trying to make a gatherbot and i stuck in the !adminlist tigger, i had make an code but this return the total name's that is in the ops.ini file and i want to return for e.g: Game-admins: nick1 - nick2 - nick3 .... Head-admins: nick1 - nick2 - nick3 .... Root-admins: nick1 - nick2 - nick3 .... the code that i made is this
on *:TEXT:!adminlist:#prive: {
.var %i 1
.var %x 1
.var %z 1
.while (%i <= $ini(ini/ops.ini,0)) {
if ($calc($len(%adminlist. [ $+ [ %x ] ]) + $len($ini(ini/ops.ini,%i))) > 285) {
%x = $calc(%x + 1)
.set %adminlist. [ $+ [ %x ] ] %adminlist. [ $+ [ %x ] ] $ini(ini/ops.ini,%i)
}
else { .set %adminlist. [ $+ [ %x ] ] %adminlist. [ $+ [ %x ] ] $ini(ini/ops.ini,%i) }
.inc %i
}
.var %z 1
.while (%z <= $var(%adminlist.*,0)) {
.msg $chan $var(%adminlist.*,%z).value
.inc %z
}
.unset %adminlist.*
}
the levels are (10 = game-admin) - (20 = head-admin) - (30 = root-admin) , here is the ops.ini info:
[westor]
nick=westor
level=30
pass=12345
[test]
nick=test
level=20
pass=12345
[test1]
nick=test1
level=10
pass=12345
|
|
|
|
Joined: Aug 2005
Posts: 15
Pikka bird
|
Pikka bird
Joined: Aug 2005
Posts: 15 |
|
|
|
|
Joined: Nov 2006
Posts: 1,552
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,552 |
A basic version could be: on *:TEXT:!adminlist:#prive: {
var %ini = $mircdirini\ops.ini
var %root, %head, %game
; loop topics of ini
var %i = 1
while ($ini(%ini,%i)) {
var %topic = $v1
; the topic has an item "level" with numerical data...
if ($readini(%ini,%topic,level) isnum) {
var %level = $v1
; ...and the topic has an item "nick" with some nickname...
if ($readini(%ini,%topic,nick)) {
var %nick = $v1
; ...add the nick to the variable matching the required level:
; level is 30+ : add to %root
if (%level >= 30) { var %root = %root - %nick }
; level is 20-29 : add to %head
elseif (%level >= 20) { var %head = %head - %nick }
; level is 10-19 : add to %game
elseif (%level >= 10) { var %game = %game - %nick }
}
}
inc %i
}
; output of the variables, without the first token (because it's a "-")
msg $chan Game-admins: $iif((%game), $gettok($v1,2-,32), none)
msg $chan Head-admins: $iif((%head), $gettok($v1,2-,32), none)
msg $chan Root-admins: $iif((%root), $gettok($v1,2-,32), none)
} "basic" because: 1) The script has no flood protection or restriction of access. It heavily depends on the channel if you need one at all. 2) As variables are limited to aprox. 4100 chars, very long lists of nicknames will create "line too long" errors. Maybe you never will have so many nicks, and the current code is fine. Else it could be solved e.g. by storing the nicknames in multiple "slots" instead of a single variable (hash tables / hidden windows / dynamically named variables ...). 3) The length of channel messages is limited a lot more than the length of variables - very long lines will be trunctuated. Again, it depends of the expected ammount of nicknames per variable. If required, the problem could be solved by splitting the output message to multiple chunks (loop on output variables), but this will increase the need for 1) Edit: If the game/network allows nicknames with square brackets you will get problems, because you use the nicknames for topic. You could store the data instead like: [levels] nick1=level_of_nick1 nick2=level_of_nick2 nick3=level_of_nick3 [passwords] nick1=pass_of_nick1 nick2=pass_of_nick2 nick3=pass_of_nick3
Last edited by Horstl; 20/05/09 09:25 PM.
|
|
|
|
Joined: Jul 2006
Posts: 4,020
Hoopy frood
|
Hoopy frood
Joined: Jul 2006
Posts: 4,020 |
It seems to me that the last time I have heard about problem with [] and ini file, it was a mistake and that mIRC handle this case correctly.
#mircscripting @ irc.swiftirc.net == the best mIRC help channel
|
|
|
|
Joined: Nov 2006
Posts: 1,552
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,552 |
Yes, and no  Yes - if you "/writeini <ini> [mytopic] <item> <data>", "$readini(<ini>,[mytopic],<item>)" will return <data>. But, no - because the "~" char is used internally for both "[" and "]". All three chars ("~" "[" and "]") will be equivalent. In the concrete case with the ~-char left aside (rarely allowed in nicknames) the problem is the indifference of "[" vs "]": "[nick]" and "]nick[" - two separate nicknames in the IRC world - will share the same ini-topic.
//writeini test.ini [test] x a | writeini test.ini ]test[ x b | echo -a $readini(test.ini,[test],x) vs. $readini(test.ini,]test[,x) Edit: But my suggestion won't solve the problem either, it would create ~nick~ for item as well. Because rounded brackets usually are not allowed for nicknames the OP might use, as a workaround something like: alias -l sb.writeini { writeini $1 $sb.rep($2-3) $4- }
alias -l sb.readini { return $readini($1, $sb.rep($2),$sb.rep($3)) }
alias -l sb.rep { return $replace($1-,[,$chr(40),],$chr(41)) } And: - /sb.writeini instead of /writeini - $sb.readini() instead of $readini()
Last edited by Horstl; 20/05/09 11:27 PM.
|
|
|
|
Joined: Dec 2008
Posts: 1,483
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,483 |
First of all thank you very much for the code Horstl, I Tested that you posted and you are right that if a nickname has the [nick] the /writeini command automatic replace the [] with ~~ , Is possible to be an mIRC mistake that the Wims told before?
Last edited by westor; 21/05/09 11:15 AM.
|
|
|
|
Joined: Dec 2008
Posts: 1,483
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,483 |
Yes, and no  Yes - if you "/writeini <ini> [mytopic] <item> <data>", "$readini(<ini>,[mytopic],<item>)" will return <data>. But, no - because the "~" char is used internally for both "[" and "]". All three chars ("~" "[" and "]") will be equivalent. In the concrete case with the ~-char left aside (rarely allowed in nicknames) the problem is the indifference of "[" vs "]": "[nick]" and "]nick[" - two separate nicknames in the IRC world - will share the same ini-topic.
//writeini test.ini [test] x a | writeini test.ini ]test[ x b | echo -a $readini(test.ini,[test],x) vs. $readini(test.ini,]test[,x) Edit: But my suggestion won't solve the problem either, it would create ~nick~ for item as well. Because rounded brackets usually are not allowed for nicknames the OP might use, as a workaround something like: alias -l sb.writeini { writeini $1 $sb.rep($2-3) $4- }
alias -l sb.readini { return $readini($1, $sb.rep($2),$sb.rep($3)) }
alias -l sb.rep { return $replace($1-,[,$chr(40),],$chr(41)) } And: - /sb.writeini instead of /writeini - $sb.readini() instead of $readini() I test this too and saw that it works see what i mean:
alias ic {
; IC = Id check , $ic(nick)
if ($1) {
if (!$readini(ini\ops.ini,$1,nick)) { return Not-admin }
if ($readini(ini\ops.ini,$1,level) == 10) { return Game-admin }
if ($readini(ini\ops.ini,$1,level) == 20) { return Head-admin }
if ($readini(ini\ops.ini,$1,level) == 30) { return Root-admin }
}
}
on *:TEXT:*!admininfo*:#prive: {
if ($2) {
.msg $nick Stats: $ic($2)
}
else { .msg $chan Error, Wrong syntax! - !admininfo <nickname> }
}
OPS.ini FILE >
[~testuser~]
nick=[testuser]
level=20
pass=12345
i Did a test with this code see the resaults : [14:26:11] <westor> !admininfo [testuser] [14:26:13] <[TEST]-Gather> Stats: Head-admin P.S: So it is not an miRC bug because the resault was corrected!
|
|
|
|
Joined: Nov 2006
Posts: 1,552
Hoopy frood
|
Hoopy frood
Joined: Nov 2006
Posts: 1,552 |
It works in writing and reading, that was the "Yes" part.
But it will mix up "[nick]", "]nick[", "[nick[" and "]nick]". Now maybe that's no problem with this script, because you apparently use some kind of passwords and maybe you don't add users to the inifile automatically. In other circumstances, this can be a problem - ranging from annoying mix-ups to a serious "exploit" of a script.
I never regarded it a mIRC bug but caused by the ini file architecture. A hash table for example wouldn't require any workarounds (it has no such limitations) and may be prefered in cases like this one.
|
|
|
|
Joined: Dec 2008
Posts: 1,483
Hoopy frood
|
OP
Hoopy frood
Joined: Dec 2008
Posts: 1,483 |
It works in writing and reading, that was the "Yes" part.
But it will mix up "[nick]", "]nick[", "[nick[" and "]nick]". Now maybe that's no problem with this script, because you apparently use some kind of passwords and maybe you don't add users to the inifile automatically. In other circumstances, this can be a problem - ranging from annoying mix-ups to a serious "exploit" of a script. Yes but now still no having any problem's and reading - writing working perfect with the manual /writeini and $readini options.
|
|
|
|
|