This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

what`s wrong in this script ?

Old posts that have not been replied to for several years.
Locked
P
Pitchat
Op
Posts: 122
Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:

what`s wrong in this script ?

Post by Pitchat »

hi
this is suppose to be a script that warn if the bot is been deop by somebody but it doesnt work at all

bind mode - * modedeop

proc modedeop {nick host hand chan mode who} {
global botnick botname

if { $mode == "-o" && $who == $botnick && [strlwr $botnick] != [strlwr $nick] } { putbot "Precieuse" "msgbot $nick ($host) m'a déopé sur $chan" ; return 0 }

set banhost "*!*[string range $who [string first @ $who] e]"
set bothost "*!*[string range $botname [string first @ $botname] e]"

if { $mode == "+b" && $banhost == $bothost} { putbot "Precieuse" "msgbot $nick ($host) m'a banni sur $chan" }
return 0 ;
}

bind kick - * kickmsg
proc kickmsg {nick host hand chan knick reason } {
global botnick
if {[strlwr $knick] == [strlwr $botnick] } { putbot "Precieuse" "msgbot $nick ($host) m'a kické sur $chan (raison invoquée : $reason)"}
}

putlog "deop check script lancé - Date: 4-02-01"


thanks
Pitchat[/code]
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

well, well

Post by De Kus »

there are really a few misstakes.
fot comparing the banhostmark i would try using string match comparing "$botnick![getchanhost $botnick]" with "$who". i hope string match can compare with wildcards, i think it can, but im not sure. but i am sure there is a way to do that.
then i dunno if you can use ; to end command lines, ussually you start a new line :). but if you use elseif instead of if in the second time, you dont need the first return 0 at all.
if you pray, perhaps it works:

Code: Select all

bind mode - * modedeop

proc modedeop {nick host hand chan mode who} {
  global botnick botname
  if { $mode == "-o" && $who == $botnick && [strlwr $botnick] != [strlwr $nick] } {
    putbot "Precieuse" "msgbot $nick ($host) m'a déopé sur $chan" 
  } elseif { $mode == "+b" && [string match [string tolower "$botnick![getchanhost $botnick]"] [string tolower $who]] } {
    putbot "Precieuse" "msgbot $nick ($host) m'a banni sur $chan"
  }
}

bind kick - "* $botnick" kickmsg

proc kickmsg {nick host hand chan knick reason } {
  putbot "Precieuse" "msgbot $nick ($host) m'a kické sur $chan (raison invoquée : $reason)"
}
eh btw, does strlwr the same the string tolower?! if not and strlwr is called a not availbe function, replace it :)..
Last edited by De Kus on Sat Feb 22, 2003 3:09 pm, edited 2 times in total.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

'strlwr' is a proc from alltools.tcl and stands for 'string tolower', so it's correct :)
Once the game is over, the king and the pawn go back in the same box.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

And a simple sugestion, replace:

Code: Select all

  } elseif { $mode == "+b" && [string match "$botnick![getchanhost $botnick]" $who] } {
with:

Code: Select all

  } elseif { $mode == "+b" && [string match "$who" "$botname"]} { 
Once the game is over, the king and the pawn go back in the same box.
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

bad suggestion, i think. because $who will not be a nick, but a hostmark in case of a +b chanmode ;).
but you are right, i should tolower the string! :D

lets show it in an example. lets say we are on an irc server having a bot called "StarZ|Clan" on hostmark "ben1@server4.phoenix-shells.de". someone sets the ban "*!*@server4.phoenix-shells.de". i am sure "*!*@server4.phoenix-shells.de" != "StarZ|Clan". but a ban "s*|clan!*@*.*" woudnt match "StarZ|Clan!ben1@server4.phoenix-shells.de", either, but would be a legal ban against the bot. its time we really need tolower again :).
so [string match "$botnick![getchanhost $botnick]" $who] must be replaced with

Code: Select all

[string match [string tolower "$botnick![getchanhost $botnick]"] [string tolower $who]]
P
Pitchat
Op
Posts: 122
Joined: Tue Feb 18, 2003 11:24 pm
Location: Hebertville Quebec Canada
Contact:

Post by Pitchat »

thanks alll it works fine :lol:
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

hmmm

Post by De Kus »

means the [string match m*h muh] expression works? great, ill remember that :D.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

It might be easier to say

string match -nocase "$botnick![getchanhost $botnick]" $who
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Humm.. yes, that will be usefull only for the +b bind.
Once the game is over, the king and the pawn go back in the same box.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

stdragon wrote:It might be easier to say

string match -nocase "$botnick![getchanhost $botnick]" $who
And I thought better of you :P

Why use a matching function, when theres no wildcards. "string equal" is more suited gfor this.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Actually since this is from a +b, $who may have wildcards.

But I should have read more carefully instead of copy and pasting, because the arguments are in the wrong order.

string match -nocase $who "$botnick![getchanhost $botnick]"

(the pattern comes before the string to match against)
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

ppslim wrote:Why use a matching function, when theres no wildcards. "string equal" is more suited gfor this.
if i want to make a equal check i would simply use $who == "$botnick![getchanhost $botnick]" :D.

but thx stdragon for correcting the expression for string match, i knew only seen it somewhere like this ^.^.
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Not to nitpick but using == still makes it case sensitive.

% expr {"asdf" == "asdf"}
1
% expr {"asdf" == "ASDF"}
0

The best way to check that is as ppslim said,
if {[string equal -nocase $string1 $string2]} {
blah
}
Locked