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.

A problem with a channel named #x²

Old posts that have not been replied to for several years.
Locked
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

A problem with a channel named #x²

Post by Alchera »

This one really defeats me. lol

I am using a channel join/kick counter in a bot I have loaned and the script is having dramas with the channel name. I've tried a few things and still cannot resolve the problem.

Code: Select all

proc dcounter_join {nick host hand chan} {
global dcounter
set chan [string tolower $chan] ; set counter 0
if {[isvalidchan $chan] == 1} {return 0}
if {[isbotnick $nick] || [matchattr $hand b]} {return}
set fx [open $dcounter(joinfile) r] ; set fx2 [open $dcounter(tmpfile) w]
while {![eof $fx]} {
set tmp [gets $fx]
if {$tmp != ""} {
if {[lindex $tmp 0] == "$chan"} {set counter [expr [lindex $tmp 1] +1] ; puts $fx2 "$chan $counter"} else {puts $fx2 $tmp}
}
}
if {$counter == 0} {set counter 1 ; puts $fx2 "$chan $counter"}
close $fx ; close $fx2
exec rm -f $dcounter(joinfile) ; exec mv $dcounter(tmpfile) $dcounter(joinfile)
if {$dcounter(njoin) == 1} {puthelp "NOTICE $nick :Vous êtes la [convert $counter] personne à joindre $chan."}
return 0
}

proc dcounter_kick {nick host hand chan target reason} {
global dcounter
set chan [string tolower $chan] ; set counter 0
if {[isvalidchan $chan] == 1} {return 0}
set fx [open $dcounter(kickfile) r] ; set fx2 [open $dcounter(tmpfile) w]
while {![eof $fx]} {
set tmp [gets $fx]
if {$tmp != ""} {
if {[lindex $tmp 0] == "$chan"} {set counter [expr [lindex $tmp 1] +1] ; puts $fx2 "$chan $counter"} else {puts $fx2 $tmp}
}
}
if {$counter == 0} {set counter 1 ; puts $fx2 "$chan $counter"}
close $fx ; close $fx2
exec rm -f $dcounter(kickfile) ; exec mv $dcounter(tmpfile) $dcounter(kickfile)
if {$dcounter(nkick) == 1} {puthelp "NOTICE $target :Vous êtes la [convert $counter] personne kicker de $chan"}
if {$dcounter(nonotice) == 1} {puthelp "NOTICE @$chan :$target est la [convert $counter] personne à être kicker de $chan"}
return 0
}

proc dcounter_see {nick host hand chan text} {
global dcounter
set chan [string tolower $chan] ; set joins 0 ; set kicks 0
if {[isvalidchan $chan] == 1} {puthelp "NOTICE $nick :I don't save join/kick stats for this channel" ; return 0}
set fx1 [open $dcounter(joinfile) r] ; set fx2 [open $dcounter(kickfile) r]
while {![eof $fx1]} {
set tmp [gets $fx1]
if {$chan == "[lindex $tmp 0]"} {set joins [lindex $tmp 1] ; break}
}
while {![eof $fx2]} {
set tmp [gets $fx2]
if {$chan == "[lindex $tmp 0]"} {set kicks [lindex $tmp 1] ; break}
}
puthelp "NOTICE $nick :$chan have $joins joins and $kicks kicks"
return 0
}
It's not a new script (2 yrs old) and the author cannot be contacted. :(

The problem is the saved join/kick data files have never ending lines of #x? 1 (in this particular case).

Except for channels with unusual characters in their name this script works perfectly for any channel a bot is in.

Any assistance will be greatly appreciated. :)

*Edited*
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

I would suggest the file name of the kick/join counter files not to be the channel name, x² which can cause problems. Secondly I see this script is very messy and long if you want I can give you my kick counter script just a few lines of code. (writes to a file on bind kick, and reads it when ever you want, e.g. in a kick msg showing the total no of kicks etc)

And if you have the kick counter, you can simply do a duplicate of it for join, by changing bind kick to bind join and changing necessary variables.

If you want a channel stat script which shows on the channel how many joins, parts, kicks, mode changes, topic changes, ops, voices were in the channel (seperate for each channel) I have the script for you! Let me know if you need it, I download it from somewhere I remember. :)
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Thanks for the response awyeah :)

The code is a little hard to fathom but it's the only one I've yet stumbled across that has an option to set multiple channels that you don't want to save information for. It simply notifies on entry the count and records kicks which is stored in 2 files (one for joins and one for kicks). I think the problem with the unusual channel names comes about because a temporary file is written, the original deleted, and the temp file is moved back.

Code: Select all

exec rm -f $dcounter(joinfile) ; exec mv $dcounter(tmpfile) $dcounter(joinfile)
The script hase proved popular with the channel founders I've loaned bots to because of the join count and kick counts:
Almy was the 5191st person to get kicked from #Ballarat
Magoo- You're the 4778th person to join #absar.
So, if you've got something along those lines I'll gladly use it. Just give me the link to it. :D
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Why do you need a temp file? Just write no of kicks and joins into a file and overwrite it each time, that is pretty simple.

You can use 1 file for both the kick and join numbers, or you can use 2 files, meaning seperate for each. Alternatively you can set an arrays to incr for the kick and join seperately, for bind join and bind kick, and it wouldn't reset even if the bot restarts. :)
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

awyeah wrote:Why do you need a temp file? Just write no of kicks and joins into a file and overwrite it each time, that is pretty simple.
Ummm .... That's because I didn't write it? :lol:
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Okay then use this: (for kick only)

Code: Select all

### KICK COUNTER INTIALIZATION ###

# In what file do you want the kicks to be stored?
set kickno "kicknum.dat"

if {![file exists $kickno]} {
 putlog "KICK COUNTER:\002 $kickno \002file \002does not exist\002, *creating file*: \002$kickno\002"
 set file [open $kickno "w"]; puts $file 0; close $file
}

proc kick:counter {nick uhost handle chan victim arg} {
 global botnick kickno
  if {[string equal -nocase $victim $botnick]} { return 0 }
  if {[isbotnick $nick]} {
  if {![file exists $kickno]} {
   putlog "KICK COUNTER: $kickno file does not exist, creating file $kickno."
   set file [open $kickno w]
   puts $file 0
   close $file
   }
   set file [open $kickno r]
   set currentkicks [gets $file]
   close $file
   set file [open $kickno w]
   puts $file [expr $currentkicks + 1]
   close $file
   }
 return 0
}


#To read the total number kicks you can use these:

#Set the variable to global in the proc
global kickno

#Open the file, read it and close
set file [open $kickno r]
set currentkicks [gets $file]
close $file

#Total kicks stored in the file
set totalkicks [expr $currentkicks]
You can do the same for join by storing number of joins in another file, by replacing bind kick with bind join and modifying a bit here and there. You can also store both of them in the same file and retrieve them via lindex.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

Thanks, you just saved me a lot of bother. LOL

I've been busy with two scripts of mine (one a bit complex and the other dealing with regexp and consonant nicks) past few days and I've had little time for much else. :)
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

if you intent to use channames as filenames next time, you should phrase the channel name with something like:

Code: Select all

set chanfile [string trim $chan "\\/:*?\"<>|"]
you can expand the list as neccessary to erase all trouble making characters :). These file name will still be unique as long as you are not in #x and #x² at the same time :D.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Yeew are seckzi De Kus :p I mean the avatar!
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
User avatar
Alchera
Revered One
Posts: 3344
Joined: Mon Aug 11, 2003 12:42 pm
Location: Ballarat Victoria, Australia
Contact:

Post by Alchera »

De Kus wrote:if you intent to use channames as filenames next time, you should phrase the channel name with something like:

Code: Select all

set chanfile [string trim $chan "\\/:*?"<>|"]
you can expand the list as neccessary to erase all trouble making characters :). These file name will still be unique as long as you are not in #x and #x² at the same time :D.
This particular script doesn't create seperate data files for each channel it stores the joins all in one file as it does for kicks but it copies the originals to a temp file, deletes the original, alters the data as needed and then moves it all back to a permanent file and this is where the channel name(s) get screwed up. :)

***Edited***
You can get the full version of dcounter from here if you want to look at it in its' entirety.
Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

Alchera wrote:This particular script doesn't create seperate data files for each channel it stores the joins all in one file as it does for kicks but it copies the originals to a temp file, deletes the original, alters the data as needed and then moves it all back to a permanent file and this is where the channel name(s) get screwed up. :)
De Kus wrote:if you intent to use channames as filenames next time,...
reading rulez :).
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
Locked