This block:
if ($nick isop #) {
var %randmods = $rand(1,1)
if (%randmods == 1) msg $chan Nazi mods are only released upon spam DansGame you know that $nick ...
}
Is essentially just:
if ($nick isop #) msg $chan Nazi mods are only released upon spam DansGame you know that $nick ...
I'm not sure if that's what you want, or you're just saving that block for more options later, but anyway.
You're missing a { after if (%randnumber == 1), and you will need to close the event with a third } at the end. The else in else (%randnumber == 3) should also be changed to elseif. Finally, you're missing the (I presume) msg command before $chan for both /timeouts
Based on your excerpt, it looks to me like you'll cut about 2/3rds of your script by removing all of the:
if ((%general) || ($($+(%,general.,$nick),2))) { return }
set -u10 %general On
set -u1800 %general. $+ $nick On
And checking that neither of the vars are set at the top of the script, and putting everything within that block instead:
(Also, I'm assuming you're using * as the matchtext for the event rather than trying to match every possible trigger, so if you want those vars to only be set if someone enters something that triggers a response by the bot, you can just add an else after all the text match conditions that unsets them)
on *:TEXT:*:#whatever:{
if !%general && !%general. [ $+ [ $nick ] ] {
set -u10 %general On
set -u1800 %general. $+ $nick On
; TEXT MATCH CONDITIONS AND RESPONSES HERE
else unset %general %general. $+ $nick
}
}
Note - There's no need to return, either.
By the way, depending on how you use timers, you may want to be wary of some issues mentioned this... This becomes especially important if your bot relays some part of the triggering text in its responses...
Also, this is not too important but in the following condition:
(*how are you* iswm $1-) || (*how are you? iswm $1-) || (*how are you ? iswm $1-)
Only the first would ever be met, so you could omit the other two... Additionally, ? would actually be considered a wildcard character here for a single (non-null) character... so something like *how are you? iswm $1- would be true for how are youa, how are you!, etc.
I'm also trying to think of with a better method for storing the responses and possible triggers, so I'll let you know when I come up with something.
You can place regex directly in the matchtext parameter of an event by placing a $ before the level (in this case, *) -- This will prevent the script from trying to trigger when it shouldn't, and also help avoid conflicts with other on text events in the same file:
*on $:TEXT:/^!(go|leave)$/Si:#: {**
I'd recommend changing the if condition from $me isin $1- to $istok($1-,$me,32), otherwise, the script could trigger on false positives... example: if your nick is "Mark", somebody else's nick is "Mark12345", and someone ("John") slaps Mark12345, you'll end up dodging a slap that wasn't aimed at you and subsequently punching John in the face for no reason.
You could also use regex for better matching , but I'd have to check which characters aren't allowed in nicks first.
o_O @Arigateaux - What error are you getting?
I've added a video demonstrating this script in action above.
Nah, all that would really happen in these cases by using $2- is that the remaining tokens would work their way into the notices and kick message. "Aha2y Drarqua 5, Aha2y Drarqua 4, Aha2y Drarqua 3, Aha2y Drarqua 2 ,Aha2y Drarqua 1". Probably not what you'd want, and of course $2 is better, but $2- shouldn't prevent the script from working.
Meta inconspicuously points at his tags and code description. (KilllerX)
Btw, I have made some improvements over the last couple of days, so expect an update soon. Hopefully some of the major bugs will be completely fixed (if anyone was able to test this and find any) and hopefully the script will be more reliable as a result.
Hmm... something might've happened to the code while I was pasting it. I'll look at it and try to fix it when I get home. I should probably mention that this script (currently) relies almost entirely on custom CTCPs. so make sure that the person you are challenging can recieve them. I'll add error alerts for these things as well when I get home. Spoof, this script is still pretty much in the alpha phase, which is why I'm calling it v0.1 rather than v1.0
First, I think I see what you are attempting to do with the long $replace, and I'll show you a trick I learned to make your job so much easier:
$!decode( $encode($reptok($strip($1-),$me,$nick,0,32),m) ,m)
*
The spaces here are necessary, as is the ! in $!decode, so don't omit them. What this will do is first encode the raw input with whatever encryption the m switch provides**, then decode that once the timer executes, returning the original string with nothing evaluated.
*I've decided to use $reptok rather than $replace, and I'll explain why later on.
**there was a specific reason for this, I think it has to do with parentheses and other such characters...
Second, the 'isin' check is an inefficient method for something like this because it runs the risk of false positives:
Say, for example, your nick is 'ger', and three other people in the channel are named "liger' 'gerbil' and 'lingerer'. (or something, I don't know)... If somebody, e.g., 'mel', slaps liger, gerbil, or lingerer, the script will trigger and you will slap mel for no reason...
Let me make a minor adjustment to that.
Because your script uses $replace, it will take any instance of 'ger' (or - your nick) in the string and replace it with 'mel'... So when mel slaps gerbil, the script will react and you will slap some person named melbil for no reason. Poor melbil! He/she's not even in the channel!
The best way to avoid these problems is to use something that only matches your nick exactly. Token identifiers work well, as can regex. Here's one regex-free way to do this:
on *:ACTION:*slaps*:#: {
if ($istok($strip($1-),$me,32)) && (!%f1) {
inc -u10 %f1
.timer 1 2 describe # $!decode( $encode($reptok($strip($1-),$me,$nick,0,32),m) ,m)
}
}
This should work for our purpose, and problems will only arise if your nick happens to be 'slaps'. However, it requires that your nick be a token exactly as is, so if you want to take it a step further, you can use regex - replace the $istok(...) with:
$regex($1-,/(?<![][}{a-z0-9^`|-])(Q $+ $me $+ E)(?![][}{a-z0-9^`|-])/gSi)
and the $reptok can be replaced with a similar $regsubex:
$regsubex($1-,/(?<![][}{a-z0-9^`|-])(Q $+ $me $+ E)(?![][}{a-z0-9^`|-])/gSi,$nick)
What these will do is not only check to see if your nick is a token within the string, but also match if your nick is immediately surrounded by characters that can't be used in nicks (at least according to someone).
So the code becomes something like this - (And I'll set a var to the regex match pattern to make things shorter):
on *:ACTION:*slaps*:#: {
var %rgx /(?<![][}{a-z0-9_^`|-])(Q $+ $me $+ E)(?![][}{a-z0-9_^`|-])/gSi
if ($regex($1-,%rgx)) && (!%f1) {
inc -u10 %f1
.timer 1 2 describe # $!decode( $encode($regsubex($1-,%rgx,$nick),m) ,m)
}
}
The on JOIN event triggers before any modes are set, so you will need to use a timer in order to check if the person joining is an op or similar. I'd recommend creating an alias to perform the commands, and then call that with a timer in the event.
As for the rest of the script, you might want to be careful about calling your timer "timer1" as well as using the on open event for this...
Also, quick idea: maybe you could set a temporary storage system so that the bot doesn't ask the same person over and over whether or not they have a facebook every time they join the/a channel..?
The on TEXT's can be combined:
on $*:TEXT:/^([+-])TK$/i:#: {
mode # $+($regml(1),smiljnut) 1
msg # 12Lockdown $iif($regml(1) == -,de) Active
}
PuNkTuReD is correct though, to an extent, though technically speaking, anyone will be able to lock down the channel, but only voices up will be able to unlock it.
Pictures?
/meta is confused.
By the way, the alignment of stuff is better in this dialog compared to your channel modes one, especially in the sense that nothing is overlapping or being cut off.
what is the "..." button for anyways? Also, a small suggestion -- maybe make an option to save the hash table, since they are deleted as soon as mIRC is closed.