|
Joined: May 2004
Posts: 132
Vogon poet
|
OP
Vogon poet
Joined: May 2004
Posts: 132 |
Can anyone tell me what i did wrong?
on *:text:!request*:#channel:{
if ($2 == $me) {
join $3
if ($calc($nick($chan,0)) < 5) {
.timer 1 3 msg $nick Request failed. You do not have the required amount of users in channel.
.timer 1 4 part $3
}
elseif ($calc($nick($chan,0)) >= 5) {
.timer 1 3msg $nick Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
}
}
}
if ($me != geek) { $life is $false } else { $life is $true } NoPleX
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
I dont know whats the problem.. but i spoted one error..
timer 1 3msg <<-- that wont work..
add a space.. timer 1 3 .. and a tip, use a . infront of the time, then you dont need to see it start and stop every time..
.timer 1 3
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: May 2004
Posts: 132
Vogon poet
|
OP
Vogon poet
Joined: May 2004
Posts: 132 |
Haha my bad.. well if the users on the chan is 5 or above it still says "Request failed. You do not have the required amount of users in channel." And parts the channel? btw. There is . infront of timer
if ($me != geek) { $life is $false } else { $life is $true } NoPleX
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Why are you using $calc? $nick($chan,0) already gives you the amount of people inside $chan.
[i]Edit: ($nick($chan,0) < 5) --> what channel is this one you want to get the number of users from? The !request channel ($3) or the channel where the !request text occurred?
Last edited by Zyzzyx26; 26/09/04 02:22 PM.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: May 2004
Posts: 132
Vogon poet
|
OP
Vogon poet
Joined: May 2004
Posts: 132 |
okay then what is $calc used for? I need it to check the amount of users on the channel it joins
if ($me != geek) { $life is $false } else { $life is $true } NoPleX
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
I've edit the post, please check it out $calc is used to make mathematics calculations. $calc(2 + 3) = 5; $calc(3^2) = 9 and so on.. You don't need $calc in the $nick() identifier. Zyzzyx
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: May 2004
Posts: 132
Vogon poet
|
OP
Vogon poet
Joined: May 2004
Posts: 132 |
The channel i need to count from is the one it joins $3 so is it just
($nick($chan,$3) < 5) then?
if ($me != geek) { $life is $false } else { $life is $true } NoPleX
|
|
|
|
Joined: Mar 2003
Posts: 1,271
Hoopy frood
|
Hoopy frood
Joined: Mar 2003
Posts: 1,271 |
Most likely you think the code does something when in fact you missed a step or so. What exactly do you want the code to do? Right now, it does the following: If anyone but you (why would you allow anyone to do that anyway - remember you cannot trigger your own on TEXT events!) types !request yournick #channelname, the code first checks if yournick matches your current nick. If so, it will join #channelname (personally I'd add a check to see if $3 is a valid channel name). Then it will check the amount of users in the channel the text was typed in (NOT the channel you just joined), and if the number is smaller than 5, it will prompt an error (not 100% sure this will actually work, since there is a $calc identifier used that doesn't actually calculate anything, so why is it even there). It will then also part the channel the command was typed in. If the amount of users in the channel the command was typed in is more than 4, you will stay in the channel the command was typed in. Now I imagine the whole checking and so is supposed to take place in the channel you just joined. That means most your code needs to be changed, as it fails there. Based on this assumption, you would need to change your code as follows (change the parts in blue as you see fit)
[color:green]; wait till anyone but you types !request yournick #channelname[/color]
on *:TEXT:!request*:[color:blue]#channelname[/color]: {
[color:green]; make sure they typed yournick and a valid channelname[/color]
[color:green]; if so - join the channel and save the requester's name[/color]
if ($2 == $me) && ($left($3,1) == $chr(35)) { join $3 | set $+(%,req,$3) $nick }
}
[color:blue] [/color]
[color:green]; after joining, wait for the /names list to complete, then check users[/color]
raw 366:*: {
[color:green]; check usercount[/color]
if ($nick($2,0) < 5) {
[color:green]; if there's not enough users, inform the requester[/color]
.msg $eval($+(%,req,$2),2) [color:blue]Request failed. You do not have the required amount of users in channel.[/color]
[color:green]; and leave[/color]
.part $2
}
[color:green]; otherwise, stay[/color]
else .msg $eval($+(%,req,$2),2) [color:blue]Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.[/color]
[color:green]; clean up your mess when you're done ![/color]
unset $+(%,req,$2)
}
Now this code could potentially get your bot into a lot of channels, which could cause serious problems....
DALnet #Helpdesk I hear and I forget. I see and I remember. I do and I understand. -Confucius
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
Hmm. not quite. If the bot (assuming its a bot) has joined the channel between join $3 and the IF statement, then yes. But that is very unlikely, since from the /join to the IF stat. it takes miliseconds Suggestion: on *:text:!request*:#channel: if ($2 == $me) { join $3 | set $+(%,request.,$3) $nick }
on me:*:join:#: {
if ($eval($+(%,request.,$3),2)) {
var %nick = $ifmatch
if ($nick($chan,0) < 5) {
.timer 1 3 msg %nick Request failed. You do not have the required amount of users in channel.
.timer 1 4 part $chan
}
elseif ($nick($chan,0) >= 5) {
.timer 1 3 msg %nick Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
}
unset $+(%,request.,$chan)
}
} The above should work. It creates a variable that, when combined with the ON Join, should have the effect you want. Hope this helps Zyzzyx. Edit: you might also use Raw 366, as LocutusofBorg did. In this case, replace the [i]on me:*:join event for raw 366:*: and, under that same ON Join, replace all $chan for $2's.
Last edited by Zyzzyx26; 26/09/04 02:38 PM.
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
i would add some type of "ignore".. if the bot been in a channel.. and user count is to low, then put that channel as a no no for X amount of time.. else it can be abused by !request many times in a row.. but thats me, im maybe a bit paranoid
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: May 2004
Posts: 132
Vogon poet
|
OP
Vogon poet
Joined: May 2004
Posts: 132 |
Workes fine Thanks guys
if ($me != geek) { $life is $false } else { $life is $true } NoPleX
|
|
|
|
Joined: Mar 2003
Posts: 1,271
Hoopy frood
|
Hoopy frood
Joined: Mar 2003
Posts: 1,271 |
I'm wondering if you tested it. You MUST use the raw, as in the on JOIN event, you cannot count nicks in the channel using $nick. That doesn't become available until after the /names has been processed.
DALnet #Helpdesk I hear and I forget. I see and I remember. I do and I understand. -Confucius
|
|
|
|
Joined: Feb 2004
Posts: 714
Hoopy frood
|
Hoopy frood
Joined: Feb 2004
Posts: 714 |
That is very true, I forgot :P
"All we are saying is give peace a chance" -- John Lennon
|
|
|
|
Joined: May 2004
Posts: 132
Vogon poet
|
OP
Vogon poet
Joined: May 2004
Posts: 132 |
Okay now this is what i got:
on *:TEXT:!request*:#channel:{
if ($2 == $me) && ($left($3,1) == $chr(35)) {
join $3
set $+(%,req,$3) $nick
}
}
raw 366:*:{
[color:red]if ($nick !isop $2) {
.timer 1 3 part $2
.timer 1 5 msg $eval($+(%,req,$2),2) You are not opped on channel $2 try again when you have op.[/color]
}
elseif ($nick($2,0) < 5) {
.timer 1 3 .msg $eval($+(%,req,$2),2) Request failed. You do not have the required amount of users in channel.
.timer 1 5 .part $2
}
else timer 1 3 .msg $eval($+(%,req,$2),2) Your channel meets the requirements and I will stay. Remember give me op or else my commands wont work.
unset $+(%,req,$2)
}
I have edit the line with the red colorNow there is just one problem. When i take the bot myself and type /j #channel it also parts and give this message: [5:00PM] -> *You* are not opped on channel #pik try again when you have op. And this when i use /hop: port80c.se.quakenet.org No such nick
if ($me != geek) { $life is $false } else { $life is $true } NoPleX
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
when you type join u do a input.. on 1:INPUT: { if ($1 == /join) { set %var 1 } if ($1 == /hop) { set %var 1 } if ($1 == /part) { set %var2 } } raw 366:*:{ if (%var == 1) { goto end } the rest of your code here. :end } thats one way to sove it.. mabe you can find bether ones tho, play with that and i think u find a way
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: May 2004
Posts: 132
Vogon poet
|
OP
Vogon poet
Joined: May 2004
Posts: 132 |
on me:*:INPUT:{ if ($1 == /j) || ($1 == /join) || ($1 == /hop) || ($1 == /part) { set %var 1 } }
raw 366:*:{ if (%var == 1) { goto end } the rest of your code here. :end }
you can use that aswell
if ($me != geek) { $life is $false } else { $life is $true } NoPleX
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
you have to change the %var somwhere too.. /part would be one place.. if it's set to 1 all the time, then the addon wont work..
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: May 2004
Posts: 132
Vogon poet
|
OP
Vogon poet
Joined: May 2004
Posts: 132 |
Ca´n't you do it like this then?
on me:*:INPUT:#:{
if ($1 == /j) { set %var 1 }
if ($1 == /join) { set %var 2 }
if ($1 == /hop) { set %var 3 }
if ($1 == /part) { set %var 4 }
}
}
raw 366:*:{
if (%var == 1) || (%var == 2) || (%var == 3) || (%var == 4) { goto end }
rest of code here.
:end
}
if ($me != geek) { $life is $false } else { $life is $true } NoPleX
|
|
|
|
Joined: Feb 2003
Posts: 3,432
Hoopy frood
|
Hoopy frood
Joined: Feb 2003
Posts: 3,432 |
shure.. but no need to have more then one value for all events..
if ($me != tired) { return } | else { echo -a Get a pot of coffee now $+($me,.) }
|
|
|
|
Joined: May 2004
Posts: 132
Vogon poet
|
OP
Vogon poet
Joined: May 2004
Posts: 132 |
But you said before that i needed to change some?
if ($me != geek) { $life is $false } else { $life is $true } NoPleX
|
|
|
|
|