IceChat Forums

IceChat 7 => IceChat 7 Scripts => Topic started by: DocBeat on July 05, 2008, 07:53:49 PM

Title: Protection Scripts
Post by: DocBeat on July 05, 2008, 07:53:49 PM
Does anyone have any protection scripts for icechat?I've found some good for mIRC but they were too complicated to be converted.

Basically most handy protection scripts i found included op status protection making you able to counter
any deop or ban attempt against you by users with no higher level than yours and other less important -slap counters etc.

I'd love to have a complete script that does such tasks because icechat is far more friendly and attractive than mIRC everything is in the right place there i use it all the time except from times when things get rough in a channel and i need such scripts like the one i mentioned.

Thanks in advance anyone who may have such script and can post it.
Title: Re: Protection Scripts
Post by: TheCellist42 on July 19, 2008, 03:22:12 PM
ok.... Here Is An Op Status Protection Script. It Will Reop You On Deop, I Will Post 3 Depecding On Your Services. (By Snerf)

ChanServ Reop:
Code: [Select]
Sub ONOP(ModeSet,Nickname,Host,ModeSetter,ModeSetterHost,Channel,ServerNumber)
If ModeSet = "False" and NickName = MyNickname(ServerNumber) then
  SendCommand "/cs op " & channel,ServerNumber
End If
End Sub

BotServ !op:
Code: [Select]
Sub ONOP(ModeSet,Nickname,Host,ModeSetter,ModeSetterHost,Channel,ServerNumber)
If ModeSet = "False" and NickName = MyNickname(ServerNumber) then
  SendCommand "/msg " & channel & " !op",ServerNumber
End If
End Sub

BotServ !up:
Code: [Select]
Sub ONOP(ModeSet,Nickname,Host,ModeSetter,ModeSetterHost,Channel,ServerNumber)
If ModeSet = "False" and NickName = MyNickname(ServerNumber) then
  SendCommand "/msg " & channel & " !up",ServerNumber
End If
End Sub

Counter A Ban Attempt:
Code: [Select]
Sub ONBAN(NickName,Host,ModeSetter,ModeSetterHost,Channel,ServerNumber)
if ModeSet = "True" and NickName = MyNickName(ServerNumber) then
  'if your nickname was banned
  sendcommand "/mode " & channel & " -b " & NickName & "!*@*",servernumber
end if
end sub
Title: Re: Protection Scripts
Post by: DocBeat on July 21, 2008, 05:34:57 AM
Thanks a lot Cellist.

What about host mask banning how to counter that one - i already have this one from you:

Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)
myhost = GetIdentifier("$host",servernumber)
if mode="+b *!*@" & myhost & " " then
SendCommand "/mode " & channel & " -b *!*@" & MyHost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
if mode="+b " &mynickname & " !*@ " & myhost & " " then
SendCommand "/mode " & channel & " -b " &mynickname & " !*@ " & MyHost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
End Sub
(by TheCellist42 :))
can you test it (it didn't work for me) -it really comes in handy while in channels,peace is never quaranteed.
Title: Re: Protection Scripts
Post by: Morio on July 21, 2008, 11:13:54 PM
Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)
myhost = GetIdentifier("$host",servernumber)
if mode="+b *!*@" & myhost & " " then
SendCommand "/mode " & channel & " -b *!*@" & MyHost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
if mode="+b " &mynickname & " !*@ " & myhost & " " then
SendCommand "/mode " & channel & " -b " &mynickname & " !*@ " & MyHost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
End Sub

Right now that script is case-sensitive, you might wanna make these changes to it:

Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)

'if you do not have ops on the channel then the script does not need to run
If Not IsOp(GetIdentifier("$me"),Channel,ServerNumber) then Exit Sub

myhost = LCase(GetIdentifier("$host",servernumber))
if LCase(mode) = "+b *!*@" & myhost then
SendCommand "/mode " & channel & " -b *!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
if LCase(mode) = "+b " & LCase(mynickname) & "!*@" & myhost then
SendCommand "/mode " & channel & " -b " & mynickname & "!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
End Sub

also, this script won't work if multiple modes are set at once
Title: Re: Protection Scripts
Post by: DocBeat on July 22, 2008, 04:51:19 AM
Have you tested that script for the host mask ban counter because seriously it doesn't work - here's what i did:

(IrCQnet)

I registered a room lets say #room and added a nick in aop list then joined with that nick,lets say its hostmask is
xxxxxx.xxxxxx.xxxxxx.IP

Then i oped a user in that room and told him to ban me like this
/mode #room +b *!*@xxxxxx.xxxxxx.xxxxxx.IP,
nothing happened though.According to the script shouldn't he be kicked?

Help plzz :(
Title: Re: Protection Scripts
Post by: Morio on July 22, 2008, 07:46:52 AM
it works fine for me, but note that it won't work for hidden hostmasks (mode +x)
Title: Re: Protection Scripts
Post by: DocBeat on July 22, 2008, 09:53:55 AM
IrCQnet has cloaked hostmasks (+x) can't anyone make ban counter script for such case?

I've seen it many times although it was a mIRC script and i have no idea how to make it work for icechat :(
Title: Re: Protection Scripts
Post by: Morio on July 22, 2008, 10:39:14 AM
use this to get your own host:
Code: [Select]
MyHost = GetIdentifier("$nick(" & Channel & "," & MyNickname & ").host",ServerNumber)
allthough that contains your ident too, so you need this to get rid of that
Code: [Select]
MyHost = Mid(MyHost,Len(GetIdentifier("$ident"),ServerNumber)+1)
Title: Re: Protection Scripts
Post by: DocBeat on July 25, 2008, 09:44:08 AM
Is this the way the script should be (it gives me an error)

Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)

'if you do not have ops on the channel then the script does not need to run
If Not IsOp(GetIdentifier("$me"),Channel,ServerNumber) then Exit Sub

MyHost = GetIdentifier("$nick(" & Channel & "," & MyNickname & ").host",ServerNumber)
MyHost = Mid(MyHost,Len(GetIdentifier("$ident"),ServerNumber)+1)
if LCase(mode) = "+b *!*@" & myhost then
SendCommand "/mode " & channel & " -b *!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
if LCase(mode) = "+b " & LCase(mynickname) & "!*@" & myhost then
SendCommand "/mode " & channel & " -b " & mynickname & "!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
End Sub
Title: Re: Protection Scripts
Post by: Morio on July 26, 2008, 12:41:05 AM
I didn't have access to icechat when writing the fix for the script so I wasn't able to test it, there's a couple small typos in the second line of my last post, and I found out that method doesn't work very well anyway, so use these three lines instead of the two lines I posted earlier instead:

Code: [Select]
MyNick = GetIdentifier("$me",ServerNumber)
MyHost = GetIdentifier("$nick(" & Channel & "," & MyNick & ").host",ServerNumber)
MyHost = Mid(MyHost,inStr(MyHost,"@")+1)
Title: Re: Protection Scripts
Post by: DocBeat on July 27, 2008, 07:36:05 AM
Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)

'if you do not have ops on the channel then the script does not need to run
If Not IsOp(GetIdentifier("$me"),Channel,ServerNumber) then Exit Sub

MyNick = GetIdentifier("$me",ServerNumber)
MyHost = GetIdentifier("$nick(" & Channel & "," & MyNick & ").host",ServerNumber)
MyHost = Mid(MyHost,inStr(MyHost,"@")+1)
if LCase(mode) = "+b *!*@" & myhost then
SendCommand "/mode " & channel & " -b *!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
if LCase(mode) = "+b " & LCase(mynickname) & "!*@" & myhost then
SendCommand "/mode " & channel & " -b " & mynickname & "!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
end if
End Sub

I used it like this and did the same test for it.Made someone ban me like this "/mode #channelname +b *!*@myhost" but nothing happened - any ideas?
Title: Re: Protection Scripts
Post by: Morio on July 27, 2008, 08:01:10 AM
try changing this line:
Code: [Select]
if LCase(mode) = "+b *!*@" & myhost then
to:
Code: [Select]
if LCase(mode) = "+b *!*@" & LCase(MyHost) then
Title: Re: Protection Scripts
Post by: DocBeat on July 27, 2008, 07:22:45 PM
I made the script like this using all the above:

Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)

'if you do not have ops on the channel then the script does not need to run
If Not IsOp(GetIdentifier("$me"),Channel,ServerNumber) then Exit Sub

MyNick = GetIdentifier("$me",ServerNumber)
MyHost = GetIdentifier("$nick(" & Channel & "," & MyNick & ").host",ServerNumber)
MyHost = Mid(MyHost,inStr(MyHost,"@")+1)

if LCase(mode) ="-o " & LCase(mynickname) then
SendCommand "/msg chanserv op " & channel & " " & MyNickName,ServerNumber
end if
if LCase(mode) ="+b " & LCase(mynickname) & "!*@*" then
SendCommand "/mode " & channel & " -b " & MyNickName &" !*@*",ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
        SendCommand "/mode " & channel & " +b " & modesetter &" !*@*",ServerNumber
end if
if LCase(mode) = "+b *!*@" & LCase(MyHost) then
SendCommand "/mode " & channel & " -b *!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
        SendCommand "/mode " & channel & " +b " & modesetter &" !*@*",ServerNumber
end if
if LCase(mode) = "+b " & LCase(mynickname) & "!*@" & myhost then
SendCommand "/mode " & channel & " -b " & mynickname & "!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
        SendCommand "/mode " & channel & " +b " & modesetter &" !*@*",ServerNumber
end if
End Sub

Thanks Morio and TheCellist42,it works perfectly now.Do you have any other suggestions ;
I have two requests on it if possible,
1)In case one kicks me i'd like the script to make me rejoin the channel and also check first if i am banned,unban me and then join back (i use '/msg ChanServ unban #channelname username' for that purpose)
2)Right now this script counters any -o effort.Can i set it so that i can deop myself and if possible to let my buddies (ppl on my buddies list) deop me too?

Thnx for the help provided already.
Title: Re: Protection Scripts
Post by: Morio on July 27, 2008, 11:09:02 PM
1) use the OnKick sub to get the rejoin. No need to check for bans, just send the unban command every time, it shouldn't cause any problems. you might wanna add a timer for the rejoin though, so the unban command has enough time to get through
2) add this line right after the onmode line
Code: [Select]
If ModeSetter = GetIdentifier("$me") then exit sub
Title: Re: Protection Scripts
Post by: DocBeat on July 28, 2008, 03:07:24 AM
1)I added this Sub under the Sub ONMODE :

Code: [Select]
Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber)
SendCommand "/msg chanserv unban " & channel & " " & MyNickName,ServerNumber
SendCommand "/join " & channel,ServerNumber
SendCommand "/mode " & channel & " +b " & WhoKicked &" !*@*",ServerNumber
End Sub

It works,unbans me and makes me rejoin but it usually doesn't have time to ban the one who kicked me(i get the msg 'you are not channel operator' because it casts the ban command before i get the +o) -
how do i set those timers?

2)The "If ModeSetter = GetIdentifier("$me") then exit sub" line works but i was wondering if i could add this check to the
"if LCase(mode) ="-o " & LCase(mynickname) then" if ,using a NOT operator (-if the modesetter isn't me-) but i am newbie in VB and i don't know how that is.

Also is there a way to let only my buddies deop me besides myself?
Sorry for the hussle and thnx
Title: Re: Protection Scripts
Post by: DocBeat on July 28, 2008, 03:17:26 AM
Sorry forget what i said about the NOT operator,the "If ModeSetter = GetIdentifier("$me") then exit sub"
is very convenient thnx.
Title: Re: Protection Scripts
Post by: DocBeat on July 30, 2008, 08:39:21 AM
Lets say my ident and host mask (cloaked +x) is like this: myident @ 61ACE7BC.B769553C.3D50937B.IP

With what code do i get my ident?

Also if someone bans me like this +b *!*@*.B769553C.3D50937B.IP can i counter the ban somehow or even counter an atempt of another operator to ban my domain?

Code: [Select]
if LCase(mode) = "+b *!*@" & LCase(MyHost) then
SendCommand "/mode " & channel & " -b *!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
        SendCommand "/mode " & channel & " +b " & modesetter &" !*@*",ServerNumber
end if

this works perfectly if they ban me like this *!*@61ACE7BC.B769553C.3D50937B.IP which is the most common host mask ban but i'd like to counter more sofisticated efforts  8-) .Does anyone know how?
Title: Re: Protection Scripts
Post by: Morio on July 30, 2008, 10:33:48 AM
look at the $mask identifier in the scripting section of this site, then make a 'for' loop check all the alternatives
Title: Re: Protection Scripts
Post by: Snerf on July 30, 2008, 10:59:01 AM
When this script gets completed, let me know please, and I can place it in the Downloads Section on the website.

Thanks
Title: Re: Protection Scripts
Post by: DocBeat on July 30, 2008, 02:16:00 PM
Okkie i made something in an attempt to counter all kinds of bans.I'll test it later but i'm complete noob with VB and icechat identifiers...So before i get a dozen of errors i'd like some opinion or corrections.

Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)

'if you do not have ops on the channel then the script does not need to run
If Not IsOp(GetIdentifier("$me"),Channel,ServerNumber) then Exit Sub

Dim N as integer
FullMask = GetIdentifier("$fullhost",ServerNumber)
For N = 0 To 10
MyHost = $mask(FullMask,N)
if LCase(mode) = "+b *!*@" & LCase(MyHost) then
SendCommand "/mode " & channel & " -b *!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
        SendCommand "/mode " & channel & " +b " & modesetter &" !*@*",ServerNumber
end if
Next N

End Sub

I searched some stuff for VB and i just let my imagination do the rest  :lol:
Sorry for such an eyesore...
Title: Re: Protection Scripts
Post by: Snerf on July 30, 2008, 03:18:03 PM
The $mask identifier actually adds the *!* and such in front of the host, so there is no need to add that in there, to check for it.

Title: Re: Protection Scripts
Post by: DocBeat on July 30, 2008, 05:22:07 PM
I've removed the *!*@ from lines 10 and 11.

So far i get an error:1025:Expected end of line:line #4 -- Dim N as integer
I don't know if this code is needed for the $mask(FullMask,N)
and if it is i don't know how to end it in VB...
Title: Re: Protection Scripts
Post by: Snerf on July 30, 2008, 09:47:31 PM
You can not dim as integer, because VB Script does not have variable 'types'
You simply "Dim N"
Title: Re: Protection Scripts
Post by: DocBeat on July 31, 2008, 06:49:42 AM
I removed "as integer" and simply used 'Dim N' now i get this:

-- Script Engine Error:1032:The character isn't valid: Line #7 -- MyHost = $mask(FullMask,N)
Title: Re: Protection Scripts
Post by: Snerf on July 31, 2008, 08:27:50 AM
Because you did not use GetIdentifier. Look at the others.

MyHost = GetIdentifier("$mask(" & FullMask & "," & N & ")")

You can not use straight $identifiers like that, you need to parse them with GetIdentifier.
Title: Re: Protection Scripts
Post by: DocBeat on July 31, 2008, 09:06:48 AM
Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)

'if you do not have ops on the channel then the script does not need to run
If Not IsOp(GetIdentifier("$me"),Channel,ServerNumber) then Exit Sub

Dim N
FullMask = GetIdentifier("$fullhost",ServerNumber)
For N = 0 To 10
MyHost = GetIdentifier("$mask(" & FullMask & "," & N & ")",ServerNumber)
if LCase(mode) = "+b " & LCase(MyHost) then
SendCommand "/mode " & channel & " -b " & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
        SendCommand "/mode " & channel & " +b " & modesetter &" !*@*",ServerNumber
end if
Next N
End Sub

This is it so far:-- Script Engine Error:1025:Expected end of line: Line #13 -- Next N
Title: Re: Protection Scripts
Post by: Morio on July 31, 2008, 11:31:16 AM
the line should say just 'Next' not 'Next N'
Title: Re: Protection Scripts
Post by: Snerf on July 31, 2008, 11:39:49 AM
Lol, I guess I should have taken more then 5 seconds to look at it quickly and gone through the whole thing, but all in all, it's good to make mistakes, because then you learn for next time.  :mrgreen:
Title: Re: Protection Scripts
Post by: DocBeat on July 31, 2008, 12:04:40 PM
It's ok  :-P i am learning - (at least i think so  :-D) - i'll check that baby again
Title: Re: Protection Scripts
Post by: DocBeat on July 31, 2008, 01:15:56 PM
Okkie i removed the N next to "Next".
Now the script doesn't have any errors,
it doesn't work though.

It's supposed to counter all kinds of bans,
i tested it for the most simple but nothing happened.
-any ideas  :?
Title: Re: Protection Scripts
Post by: Morio on August 01, 2008, 01:05:37 AM
try viewing the MyHost variable inside the for loop (that is, echo it to the screen) to see what it returns, from then you can try to figure out what might be wrong
Title: Re: Protection Scripts
Post by: DocBeat on August 01, 2008, 09:06:47 AM
I used
Code: [Select]
SendCommand "/echo -s " & myhost,ServerNumber
accidentally between
MyHost = GetIdentifier("$mask(" & FullMask & "," & N & ")",ServerNumber)
and
if LCase(mode) = "+b " & LCase(MyHost) then,
so the command is send in any case- it returns $null   (x10times)
i don't understand why it doesn't have some value  :?

After that, i put it in the IF statement under the line
'if LCase(mode) = "+b " & LCase(MyHost) then' i had one to ban me
and it didn't return anything at all
so i guess the IF code isn't executed lol i wonder why...

Title: Re: Protection Scripts
Post by: DocBeat on August 01, 2008, 09:11:46 AM
Correction:(x11times) :-D...not that it matters any  :-P
Title: Re: Protection Scripts
Post by: Snerf on August 01, 2008, 02:38:33 PM
Looks like the big guy (That would be Mr Snerf) is going to have to step in, and make this script himself :)

I will see what I can muster up.
Title: Re: Protection Scripts
Post by: SniperPro on August 02, 2008, 10:32:57 AM
Can you make this where it doesen't matter what level I am (% threw ~) I -b myself and ban+kick the user who did it saying "Don't ban me"?
Title: Re: Protection Scripts
Post by: DocBeat on August 02, 2008, 11:42:16 AM
Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)
If ModeSetter = GetIdentifier("$me") then exit sub
if LCase(mode) ="-o " & LCase(mynickname) then
SendCommand "/msg chanserv op " & channel & " " & MyNickName,ServerNumber
end if
End Sub

Code: [Select]
Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber)
if Nickname = GetIdentifier("$me") then
SendCommand "/msg chanserv unban " & channel & " " & MyNickName,ServerNumber
SendCommand "/timer 1 1 2 /join " & channel,ServerNumber
SendCommand "/timer 2 1 3 /mode " & channel & " +b " & WhoKicked &" !*@*",ServerNumber
end if
End Sub

Together with the anti-ban don't forget the anti-deop and anti-kick  :-D.Those two above work fine - too bad i can't make them allow my buddies to deop or kick meh if they want but since you are warmed up  :lol:
Title: Re: Protection Scripts
Post by: Morio on August 05, 2008, 12:21:24 AM
Quote
MyHost = GetIdentifier("$mask(" & FullMask & "," & N & ")",ServerNumber)

that's the problem right there I think. You don't need the ',ServerNumber'
Title: Re: Protection Scripts
Post by: DocBeat on August 05, 2008, 08:19:33 AM
It still returns null for it
Title: Re: Protection Scripts
Post by: Morio on August 05, 2008, 10:01:41 AM
Hmm, it seems like the $fullhost identifier is a bit buggy. It returns odd stuff on some networks.
Title: Re: Protection Scripts
Post by: Snerf on August 05, 2008, 10:03:02 AM
I tested the script on Quakenet and had no problems with it.
Title: Re: Protection Scripts
Post by: Morio on August 05, 2008, 10:12:10 AM
that's the thing, it works on quakenet, because that network returns the $fullhost identifier as it should. But ircnet returns only your nick, and irc.nexuswar.com returns "services."
Title: Re: Protection Scripts
Post by: DocBeat on August 05, 2008, 10:51:16 AM
I mostly go to IrCQnet (irc.icq.com),
where the host mask is cloaked (mode +x).

this works for me there (the one Morio suggested):

Code: [Select]
MyNick = GetIdentifier("$me",ServerNumber)
MyHost = GetIdentifier("$nick(" & Channel & "," & MyNick & ").host",ServerNumber)
MyHost = Mid(MyHost,inStr(MyHost,"@")+1)
if LCase(mode) = "+b *!*@" & LCase(MyHost) then
SendCommand "/mode " & channel & " -b *!*@" & myhost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
        SendCommand "/mode " & channel & " +b " & modesetter &" !*@*",ServerNumber
end if

,it counters only one type of ban so i tried the $fullhost identifier.Till now it returns null value for me  :|
Title: Re: Protection Scripts
Post by: Morio on August 05, 2008, 11:16:16 AM
use this to get your host:
Code: [Select]
MyNick = GetIdentifier("$me",ServerNumber)
MyHost = GetIdentifier("$nick(" & Channel & "," & MyNick & ").host",ServerNumber)
MyHost = Mid(MyHost,inStr(MyHost,"@")+1)

then use the 'For' loop with the $mask identifier
Title: Re: Protection Scripts
Post by: DocBeat on August 05, 2008, 11:37:20 AM


Sorry i don't understand where and y to use the $mask identifier if i already got MyHost with other code.

MyHost = GetIdentifier("$mask(" & FullMask & "," & N & ")",ServerNumber)
This one you mean?-i guess not since i already get MyHost with the code you gave me.
Also what will the FullMask be if the $fullhost identifier is buggy for icq server  :?
Title: Re: Protection Scripts
Post by: Morio on August 05, 2008, 11:51:22 AM
the $mask identifier only modifies the host you pass through it

Code: [Select]
MyNick = GetIdentifier("$me",ServerNumber)
MyHost = MyNick & "!" & GetIdentifier("$nick(" & Channel & "," & MyNick & ").host",ServerNumber)
For i = 0 to 10
CurrentHost = GetIdentifier("$mask(" & MyHost & "," & i & ")")
SendCommand "/echo -a " & CurrentHost
Next
Title: Re: Protection Scripts
Post by: DocBeat on August 05, 2008, 12:56:00 PM
Thnx Morio everything works perfectly now   :-D (at least for the server i go to)
i don't think it needs anything else unless you guys have any suggestions on it:

anti-ban & anti-kick
Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)

'if you do not have ops on the channel then the script does not need to run
If Not IsOp(GetIdentifier("$me"),Channel,ServerNumber) then Exit Sub

Dim N
MyNick = GetIdentifier("$me",ServerNumber)
MyHost = MyNick & "!" & GetIdentifier("$nick(" & Channel & "," & MyNick & ").host",ServerNumber)
For N = 0 to 10
CurrentHost = GetIdentifier("$mask(" & MyHost & "," & N & ")",ServerNumber)
if LCase(mode) = "+b " & LCase(CurrentHost) then
SendCommand "/mode " & channel & " -b " & CurrentHost,ServerNumber
SendCommand "/kick " & channel & " " & modesetter & " Do Not Ban Me",servernumber
        SendCommand "/mode " & channel & " +b " & modesetter &" !*@*",ServerNumber
end if
Next

End Sub
Sub ONKICK(Nickname,Host,Channel,WhoKicked,Reason,ServerNumber)
if Nickname = GetIdentifier("$me") then
SendCommand "/msg chanserv unban " & channel & " " & MyNickName,ServerNumber
SendCommand "/timer 1 1 1 /join " & channel,ServerNumber
SendCommand "/timer 2 1 2 /mode " & channel & " +b " & WhoKicked &" !*@*",ServerNumber
end if
End Sub

I used echo for the CurrentHost and it returned:

*!ident@83F6219B.5AFFE6DD.2C7D40D.IP
*!*ident@ 83F6219B.5AFFE6DD.2C7D40D.IP
*!*@83F6219B.5AFFE6DD.2C7D40D.IP
*!*ident@*.2C7D40D.IP
*!*@*.2C7D40D.IP
DocBeat!ident@83F6219B.5AFFE6DD.2C7D40D.IP
DocBeat!*ident@ 83F6219B.5AFFE6DD.2C7D40D.IP
DocBeat!*@83F6219B.5AFFE6DD.2C7D40D.IP
DocBeat!*ident@*.2C7D40D.IP
DocBeat!*@*.2C7D40D.IP
DocBeat!*@*

It doesn't counter any type there is
(for example:DocBeat!*ident@*.5AFFE6DD.2C7D40D.IP),
but i don't think it matters since it covers a good variety of types.

A final request if possible  :oops:
Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)
If ModeSetter = GetIdentifier("$me") then exit sub
if LCase(mode) ="-o " & LCase(mynickname) then
SendCommand "/msg chanserv op " & channel & " " & MyNickName,ServerNumber
end if
End Sub
I want my buddies to be able to deop me.Is it possible?
Title: Re: Protection Scripts
Post by: Snerf on August 05, 2008, 01:45:44 PM
If the Mode was DocBeat!*ident@*.5AFFE6DD.2C7D40D.IP tho, you could parse out your nickname quit easily tho.

That may be the 1st thing you could do, is simply check for a nick name match, by getting everything before the "!" character.
In any case, I was working on a solution this weekend, but got side tracked, as it will also work when multiple bans are set, which the current one does not.
Title: Re: Protection Scripts
Post by: Morio on August 06, 2008, 01:17:33 AM
When I was working on a bot, I made a function that parses the modes that are set and can be used to counter any mode changes (except if you deop the bot). It separates every mode and the possible parameters for the mode. If you wan't I could post it here when I get home
Title: Re: Protection Scripts
Post by: DocBeat on August 06, 2008, 08:45:44 AM
That would be cool with me.I'd love to check it out when i get back home too.
(going holidays tomorrow  :mrgreen:)
Title: Re: Protection Scripts
Post by: DocBeat on August 16, 2008, 03:31:54 AM
 :-D Holidays were awesome  :mrgreen:

Can you send that function sometime Morio  :lol:
Title: Re: Protection Scripts
Post by: DocBeat on August 20, 2008, 04:42:14 AM
It just came to my mind that it would be a good idea if i could protect my buddies besides myself.

Is there any way to get the nicknames of my buddies - and maybe place them in an array
 (so that when someone sends a ban,kick or deop command i will just check the array to see if the command refered to any of my friends).
Title: Re: Protection Scripts
Post by: DocBeat on October 19, 2008, 04:03:20 PM
I was wondering if anyone will ever make a more functional or better version of the current script (working for multiple modes like Snerf said etc...)
Title: Re: Protection Scripts
Post by: Morio on October 20, 2008, 08:34:50 AM
Here is a script that parses modes and puts the modes that require a parameter in an array together with the parameter

Code: [Select]
Sub ONMODE(Channel,ModeSetter,Mode,ServerNumber)
ModeParser Mode,Channel,ServerNumber
End Sub

Sub ModeParser(Mode,Channel,ServerNumber)
Dim ModesWithParameters,ParameterModes(),ParameterModeNumber,OtherModes(),OtherModeNumber,ChangePosition,lFound
ModesWithParameters = "voblkeIfLj" 'modes that can (usually will) be followed by a parameter
ParameterModeNumber = 0
OtherModeNumber = 0
lFound = False


If InStr(Mode," ") > 0 then 'there are parameters
Modes = Left(Mode,InStr(Mode," ")-1)
Parameters = Mid(Mode,InStr(Mode," ")+1)

If InStr(Parameters," ") then
ParameterArray = Split(Parameters," ")
Else
Dim ParameterArray(0)
ParameterArray(0) = Parameters
End If


If Left(Modes,1) = "+" then 'no modes have been removed

For i = 1 to Len(Modes)

If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then
ParameterModeNumber = ParameterNumber + 1
ElseIf Mid(Modes,i,1) <> "+" then
OtherModeNumber = OtherModeNumber + 1
End If
Next

ReDim ParameterModes(ParameterModeNumber-1)
ReDim OtherModes(OtherModeNumber-1)
ParameterModeNumber = 0
OtherModeNumber = 0

For i = 1 to Len(Modes)
If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then
ParameterModes(ParameterModeNumber) = "+" & Mid(Modes,i,1)
ParameterModeNumber = ParameterModeNumber + 1
ElseIf Mid(Modes,i,1) <> "+" then
OtherModes(OtherModeNumber) = "+" & Mid(Modes,i,1)
OtherModeNumber = OtherModeNumber + 1
End If
Next

For i = 0 to UBound(ParameterModes)
ParameterModes(i) = ParameterModes(i) & " " & ParameterArray(i)
Next

ElseIf Left(Modes,1) = "-" And InStr(Modes,"+") = 0 then 'modes have been removed but no modes have been added

ModesWithParameters = "vobkeIfLj" 'the mode l doesn't take a parameter when it is removed
For i = 1 to Len(Modes)
If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then
ParameterModeNumber = ParameterNumber + 1
ElseIf Mid(Modes,i,1) <> "-" then
OtherModeNumber = OtherModeNumber + 1
End If
Next

ReDim ParameterModes(ParameterModeNumber-1)
ReDim OtherModes(OtherModeNumber-1)
ParameterModeNumber = 0
OtherModeNumber = 0

For i = 1 to Len(Modes)
If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then
ParameterModes(ParameterModeNumber) = "-" & Mid(Modes,i,1)
ParameterModeNumber = ParameterModeNumber + 1
ElseIf Mid(Modes,i,1) <> "-" then
OtherModes(OtherModeNumber) = "-" & Mid(Modes,i,1)
OtherModeNumber = OtherModeNumber + 1
End If
Next

For i = 0 to UBound(ParameterModes)
ParameterModes(i) = ParameterModes(i) & " " & ParameterArray(i)
Next

ElseIf Left(Modes,1) = "-" And InStr(Modes,"+") > 0 then 'some modes have been removed and some have been added
For i = 1 to Len(Modes)
If lFound = False then
ModesWithParameters = "vobkeIfLj"
Else
ModesWithParameters = "voblkeIfLj"
End If

If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then
ParameterModeNumber = ParameterModeNumber + 1
ElseIf Mid(Modes,i,1) <> "-" And Mid(Modes,i,1) <> "+" then
OtherModeNumber = OtherModeNumber + 1
ElseIf Mid(Modes,i,1) = "+" then
lFound = True
End If
Next

ReDim ParameterModes(ParameterModeNumber-1)
ReDim OtherModes(OtherModeNumber-1)
ParameterModeNumber = 0
OtherModeNumber = 0


lFound = False

For i = 1 to Len(Modes)

If lFound = False then
ModesWithParameters = "vobkeIfLj"
Else
ModesWithParameters = "voblkeIfLj"
End If

If InStr(ModesWithParameters,Mid(Modes,i,1))>0 then

If lFound = False then
ParameterModes(ParameterModeNumber) = "-" & Mid(Modes,i,1)
ParameterModeNumber = ParameterModeNumber + 1
Else
ParameterModes(ParameterModeNumber) = "+" & Mid(Modes,i,1)
ParameterModeNumber = ParameterModeNumber + 1
End If

ElseIf Mid(Modes,i,1) <> "-" And Mid(Modes,i,1) <> "+" then

If lFound = False then
OtherModes(OtherModeNumber) = "-" & Mid(Modes,i,1)
OtherModeNumber = OtherModeNumber + 1
Else

OtherModes(OtherModeNumber) = "+" & Mid(Modes,i,1)
OtherModeNumber = OtherModeNumber + 1
End If

ElseIf Mid(Modes,i,1) = "+" then
lFound = True
End If


Next

For i = 0 to UBound(ParameterModes)
ParameterModes(i) = ParameterModes(i) & " " & ParameterArray(i)
Next

End If

For i = 0 to UBound(ParameterModes)
SendCommand "/echo -a " & ParameterModes(i)
Next
For i = 0 to UBound(OtherModes)
SendCommand "/echo -a " & OtherModes(i)
Next

End If

End Sub

The script doesn't do anything else than parse the modes, and right now it does nothing if a mode without parameters is set (which you won't need anyway) but I'll add that at some point. I did some testing, and it seems to work, but there might still be some bugs.

This part:
Code: [Select]
For i = 0 to UBound(ParameterModes)
SendCommand "/echo -a " & ParameterModes(i)
Next
For i = 0 to UBound(OtherModes)
SendCommand "/echo -a " & OtherModes(i)
Next

prints the arrays to the screen.

To pick out only bans, loop through all modes and only do something when you find a mode that starts with '+b' or '-b'

Load the script and play around with the modes and you'll see what the script actually does
Title: Re: Protection Scripts
Post by: Snerf on October 20, 2008, 11:22:15 AM
You know, as the 2nd msg in this topic had shown, there are ONOP, ONVOICE events that you can use, to really simplify this.

They should be as follows.

Code: [Select]
Sub ONOP(ModeSet,Nickname,Host,ModeSetter,ModeSetterHost,Channel,ServerNumber)

End Sub

The ModeSet variable will "True" if it is set (+o) and "False" if it is not (-o).

There is also an ONBAN event, except there is no ModeSet variable.
There is no ONUNBAN event.
Code: [Select]
Sub ONBAN(Nickname,Host,ModeSetter,ModeSetterHost,Channel,ServerNumber)

End Sub

Each of these are run individually, so 1 event for each nick/ban, and op/deop, voice, halfop, etc.
You can check the hosts with a banmask if you need to as well, as you had before.
Title: Re: Protection Scripts
Post by: DocBeat on October 20, 2008, 06:50:08 PM
Thnx Morio i will play with that one to see how it works  :-)

About the ONBAN event:

Does it get triggered (Assuming that it checks whether it was me who got banned using
"if Nickname = GetIdentifier("$me") then") no matter which way the modesetter used the ban
command on me?

I mean, is it built in a way capable of detecting all the different types of banning or do i have to use
a loop for getting my host like i did before:

...
MyNick = GetIdentifier("$me",ServerNumber)
MyHost = MyNick & "!" & GetIdentifier("$nick(" & Channel & "," & MyNick & ").host",ServerNumber)
For N = 0 to 10
CurrentHost = GetIdentifier("$mask(" & MyHost & "," & N & ")",ServerNumber)
...

sorry to be asking silly stuff Snerf i'm still trying to figure some scripting things out  :oops:
Title: Re: Protection Scripts
Post by: DarkStar on October 20, 2008, 10:58:32 PM
Lets try this using the underused Regular expressions, to make things easier.

Code: [Select]
Function MaskMatch(mask,match)
  Set MaskRegex = new RegExp
  MaskRegex.IgnoreCase = True
  MaskRegex.pattern = replace(replace(match,"?","."),"*",".*")
  MaskMatch = MaskRegex.Test(mask)
End Function

Now, we can simply do..

Code: [Select]
if MaskMatch(MyHost, banned_host) then SendCommand "/mode " & channel & " -b " & banned_host,ServerNumber
Edit:

Completed, the code looks like:

Code: [Select]
Sub ONBAN(Nickname,Host,ModeSetter,ModeSetterHost,Channel,ServerNumber)
MyNick = GetIdentifier("$me",ServerNumber)
MyHost = MyNick & "!" & GetIdentifier("$nick(" & Channel & "," & MyNick & ").host",ServerNumber)
if MaskMatch(MyHost,Nickname & "!" & Host) then SendCommand "/mode " & channel & " -b " & Nickname & "!" & Host,ServerNumber
End Sub
Title: Re: Protection Scripts
Post by: DarkStar on October 22, 2008, 10:40:05 AM
Morio caught a bug in my regular expression example, when there were question marks used in the banmask. I updated my previous post to include the fix.
Title: Re: Protection Scripts
Post by: clEEn on December 15, 2008, 04:11:41 AM
nice script i will use this but, can u make it like if i type !addowner <nick> it will add a owner on the bot and if the "new owner" will ban/kick or something likes that, the bot wont ban him. thx  :mrgreen: