| View previous topic :: View next topic |
| Author |
Message |
Draknon Voice
Joined: 01 Apr 2018 Posts: 30
|
Posted: Sun Apr 01, 2018 8:29 am Post subject: voice for nick with non Cap 1st letter |
|
|
I currently have this for an mIRC bot.. would like to have it for eggdrop bot so need it in tlc. any help would be appreciated..
| Code: |
alias -l _c return #The-Dungeon
alias startwithupper {
if ( $1 ) {
return $isupper($left($regsubex($$1,/\W+/g,$null),1))
}
else return $false
}
on @*:JOIN:#The-Dungeon:{
if ( $startwithupper($nick) == $false ) {
mode $_c +v $nick
}
}
on @*:NICK:{
if ( ( $startwithupper($newnick) == $false ) && ( $newnick !isvoice $_c ) ) {
; New nick is with upper case and previous is unvoiced
mode $_c +v $newnick
}
if ( ( $startwithupper($newnick) == $true ) && ( $newnick isvoice $_c ) ) {
; New nick is with lower case and previous is voiced
mode $_c -v $newnick
}
}
|
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Mon Apr 02, 2018 12:54 am Post subject: |
|
|
| Code: |
namespace eval NickCase {
set channel "#The-Dungeon"
bind join - * [namespace current]::joined
bind nick - * [namespace current]::nick
proc joined {nick uhost hand chan} {
if {[isbotnick $nick] || [botisop $chan]} return
variable channel
if {![string match -nocase $chan $channel]} return
if {![string equal $nick [string totitle $nick]]} {
pushmode $chan +v $nick
}
}
proc nick {nick uhost hand chan newnick} {
if {[isbotnick $nick] || [botisop $chan]} return
variable channel
if {![string match -nocase $chan $channel]} return
if {[isvoice $newnick $chan]} {
if {[string equal $newnick [string totitle $newnick]]} {
pushmode $chan -v $newnick
}
} else {
if {![string equal $newnick [string totitle $newnick]]} {
pushmode $chan +v $newnick
}
}
}
}
|
Haven't tested anything so let me know if doesn't work. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Draknon Voice
Joined: 01 Apr 2018 Posts: 30
|
Posted: Tue Apr 03, 2018 6:26 am Post subject: you are awesome |
|
|
but, unfortunately it doesn't work at all
I am trying to learn, but it isn't easy for me so I'm not sure where the issue is. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Apr 04, 2018 1:42 am Post subject: |
|
|
Here's the updated and tested code.
| Code: |
namespace eval NickCase {
set channel "#The-Dungeon"
bind join - * [namespace current]::joined
bind nick - * [namespace current]::nick
proc joined {nick uhost hand chan} {
if {[isbotnick $nick] || ![botisop $chan]} return
variable channel
if {![string match -nocase $chan $channel]} return
if {![string equal $nick [string totitle $nick]]} {
pushmode $chan +v $nick
}
}
proc nick {nick uhost hand chan newnick} {
if {[isbotnick $nick] || ![botisop $chan]} return
variable channel
if {![string match -nocase $chan $channel]} return
set match [string equal [string index $newnick 0] [string index [string totitle $newnick] 0]]
if {[isvoice $nick $chan]} {
if {$match} {
pushmode $chan -v $newnick
}
} else {
if {!$match} {
pushmode $chan +v $newnick
}
}
}
}
|
The main issue was because of botisop part in:
| Code: |
if {[isbotnick $nick] || [botisop $chan]} return
|
that basically means if the bot is channel operator then it would stop executing anything past this line, when in fact wanted to stop the execution only if the bot wasn't channel operator, hence the ! in front of the [botisop $chan] in above "updated" code.
The second issue I've discovered is that string totitle on it's own wasn't enough because it turns SomeNick into Somenick and the previous test:
| Code: |
if {[string equal $newnick [string totitle $newnick]]} {
|
basically will test if SomeNick is now equal with Somenick and will fail. So, instead I now take the first letter of the new nick and compare it with the first letter from string totitle result.
An alternative to:
| Code: |
set match [string equal [string index $newnick 0] [string index [string totitle $newnick] 0]]
|
could be:
| Code: |
set match [expr [regexp -all {[A-Z]} $newnick]]
|
but in a 1000 iterations test the string equal one seems slightly faster, even if it's ugly.
| Code: |
% time {for {set i 0} {$i < 1000} {incr i} { append mylist [regexp -all {[A-Z]} $newnick] }}
1731 microseconds per iteration
% time {for {set i 0} {$i < 1000} {incr i} { append mylist [string equal [string index $newnick 0] [string index [string totitle $newnick] 0]] }}
1425 microseconds per iteration
|
_________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
Draknon Voice
Joined: 01 Apr 2018 Posts: 30
|
Posted: Wed Apr 04, 2018 9:56 pm Post subject: |
|
|
ok, I copy and pasted the new and it is still not working..
I think I kinda understand what some things are supposed to do..
can we just get rid of the ...
| Code: | | if {[isbotnick $nick] || ![botisop $chan]} return |
and just expect that the bot is an op, because it is.
and sorry, I didn't explain what the original actually does...
if someone comes into channel and the nick first letter is lowercase then that person gets the +v and if they have a Capped nick then nothing and if a nick changes the upper/lower case of the first letter than either +v or -v depending on which they do.. and if nick starts with a non alpha like { or [ or some such then it looks for the first actual alpha character and works from that. |
|
| Back to top |
|
 |
Draknon Voice
Joined: 01 Apr 2018 Posts: 30
|
Posted: Sun Apr 08, 2018 3:41 am Post subject: |
|
|
ok, new information ...
| Code: | #
# Script: sub voice
#
namespace eval NickCase {
set channel "#The-Dungeon"
bind join - * [namespace current]::joined
bind nick - * [namespace current]::nick_chk
proc joined {nick uhost hand chan} {
variable channel
if {![string match -nocase $chan $channel]} return
if {![string equal $nick [string totitle $nick]]} {
pushmode $chan +v $nick
}
}
proc nick_chk {nick uhost hand chan newnick} {
variable channel
if {![string match -nocase $chan $channel]} return
set match {expr [regexp -all {[A-Z]} $newnick]}
if {[isvoice $nick $chan]} {
if {$match} {
pushmode $chan -v $newnick
}
} else {
if {!$match} {
pushmode $chan +v $newnick
}
}
}
}
putlog "sub voice loaded"
|
Error msg is .. | Quote: | | Tcl error [::NickCase::nick_chk]: expected boolean value but got "expr [regexp -all {[A-Z]} $newnick]" |
on top of fixing this can someone please explain to me what the error means?? |
|
| Back to top |
|
 |
Draknon Voice
Joined: 01 Apr 2018 Posts: 30
|
Posted: Mon Apr 09, 2018 1:55 am Post subject: |
|
|
| got this all set and working .. thanks for all the help |
|
| Back to top |
|
 |
|