| View previous topic :: View next topic |
| Author |
Message |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Wed Nov 14, 2018 6:48 pm Post subject: |
|
|
What "three different sets of commands are working"??
The script we are working with has a single trigger, calling a single process, and my bet is that is working as desired.
If you are running other code as well, and you want help with that other code, you will need to post that other code here. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
crymsun Voice
Joined: 13 Nov 2018 Posts: 33
|
Posted: Wed Nov 14, 2018 10:36 pm Post subject: |
|
|
Sorry I wasn't clear...
I tried (perhaps stupidly?) to replicate the code you provided into two additional scripts... one for !help and one for !admins... (in addition to the !rules script). I added the source lines to the config file.. restarted the bot...
But somehow that made only one of the scripts' text (the rules) appear no matter which of the three ! commands were typed.
For example:
!rules (rules text appears in PM)
!help (rules text appears in PM)
!admin (rules text appears in PM)
rules.tcl - for !rules
help.tcl - for !help
admin.tcl - for !admins
Used the same code - changing the text lines and instead of "chanrules" it would be "chanhelp" for one and "chanadmins" for the other.
Not sure how else to describe it?
(I did fix the chan vs pvt message issue... that was a simple mistake & fix on my part). |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Wed Nov 21, 2018 10:00 am Post subject: |
|
|
You should post your broken code here, All of it, if you want some help with it. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
crymsun Voice
Joined: 13 Nov 2018 Posts: 33
|
Posted: Sun Nov 25, 2018 10:07 pm Post subject: |
|
|
Here is what I am currently working with (having given up on trying to do !rules !help and !admin)..
| Code: | set chanrules {
"rules line 1"
"rules line 2"
}
bind pub - !rules <nick>
proc pub:t {nick uhost hand chan text} {
global chanrules
set rulenick [lindex [split $text " "] 0]
if {$text != "" && [onchan $rulenick $chan]} {
puthelp "NOTICE $rulenick :these are the rules of our channel. Pay attention!"
foreach line $chanrules { puthelp "NOTICE $rulenick :$line" }
return 0
}
foreach line $chanrules {puthelp "PRIVMSG $nick :$line" }
} |
It was working... then suddenly it wasn't working...
At first I tried to replicate the above, using !help and !admin instead of !rules, but again, any command preceded by "!" would prompt the rules script. I gave up and narrowed it back down to just the !rules. It worked for a bit, then it stopped working.
There are not enough stress balls on this planet to deal with this. LOL
Would love a script where I can fill in the rules list, help list and admin list so that when anyone in channel types !rules !help or !admin they get that corresponding list, privately. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Mon Nov 26, 2018 9:50 am Post subject: |
|
|
Please try this script based on caesar's previous post.
| Code: |
namespace eval say { variable say
set say(rules) {
"These are the rules of our channel. Pay attention!"
"rule line 1"
"rule line 2"
}
set say(help) {
"These are the help lines for our channel."
"help line 1"
"help line 2"
}
set say(admin) {
"These are the admin lines for our channel."
"admin line 1"
"admin line 2"
}
bind pub -|- !rules [namespace current]::rules
bind pub -|- !help [namespace current]::help
bind pub -|- !admin [namespace current]::admin
proc rules {nick uhost hand chan text} {
variable say
foreach line $say(rules) {
puthelp "NOTICE $nick :$line"
}
}
proc help {nick uhost hand chan text} {
variable say
foreach line $say(help) {
puthelp "NOTICE $nick :$line"
}
}
proc admin {nick uhost hand chan text} {
variable say
foreach line $say(admin) {
puthelp "NOTICE $nick :$line"
}
}
}
putlog "SayHelp ver 0.1 Loaded."
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Last edited by SpiKe^^ on Mon Nov 26, 2018 11:55 pm; edited 1 time in total |
|
| Back to top |
|
 |
crymsun Voice
Joined: 13 Nov 2018 Posts: 33
|
Posted: Mon Nov 26, 2018 11:06 pm Post subject: |
|
|
THANK YOU!!!!
Thank you, thank you a hundred times thank you. It worked. Got others to come in and test it out... works wonderfully.
Cannot thank you enough, truly... I was ready to chuck the whole thing, channel and all. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Nov 27, 2018 3:18 pm Post subject: SayHelp ver 1.01 |
|
|
I like this one better. Code hasn't been tested yet.
New in ver 1.01
- Now add unlimited triggers/replies with no code editing.
- Now supports send reply to target nick (can be disabled).
| Code: |
namespace eval say { variable say ; array unset say "*"
################ Begin Settings ################
variable cmdchar "!" ;# Every command starts with this One Character #
## Add as many commands as you want:) ##
## - name each one uniquely, the name is also the trigger ##
## - add as many reply lines as you want to each command ##
set say(rules) {
"These are the rules of our channel. Pay attention!"
"rule line 1"
"rule line 2"
}
set say(help) {
"These are the help lines for our channel."
"help line 1"
"help line 2"
}
set say(admin) {
"These are the admin lines for our channel."
"admin line 1"
"admin line 2"
}
variable dotarget 1 ;# 1 = target nick enabled # 0 = disabled #
################ End of Settings (Don't edit below) ################
foreach sayname [array names say] {
bind pubm - "?%~\\${cmdchar}${sayname}*" [namespace current]::sayit
}
proc sayit {nk uh hn ch tx} { variable cmdchar ; variable say
lassign [split $tx] cmd target ; variable dotarget
if {[string index $cmd 0] ne $cmdchar} { return 0 }
set match [lsearch -nocase -inline [array names say] [string range $cmd 1 end]]
if {$match eq ""} { return 0 }
if {$dotarget eq "0" || $target eq "" || ![onchan $target $ch]} {
set target $nk
}
foreach line $say($match) { puthelp "NOTICE $target :$line" }
return 0
}
}
putlog "SayHelp ver 1.01 Loaded."
|
_________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Thu Nov 29, 2018 10:48 am Post subject: |
|
|
I could sure use someone to test this script and report back here please:) _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Nov 30, 2018 4:56 am Post subject: |
|
|
| Code: |
namespace eval say {
set say(rules) {
"These are the rules of our channel. Pay attention!"
"rule line 1"
"rule line 2"
}
set say(help) {
"These are the help lines for our channel."
"help line 1"
"help line 2"
}
set say(admin) {
"These are the admin lines for our channel."
"admin line 1"
"admin line 2"
}
# don't edit past this line
foreach ele [binds [namespace current]::*] {
if {[scan $ele {%s%s%s%d%s} type flags cmd hits func] != 5} continue
unbind $type $flags $cmd $func
}
foreach name [array names say] {
bind pub - !${name} [namespace current]::say
}
proc say {nick uhost hand chan text} {
variable say
if {[scan $text {%s} who] != 1} {
set who $nick
}
if {![onchan $chan $who]} return
set cmd [string tolower [lindex [split $::lastbind !] 1]]
if {[lsearch [array names say] $cmd] > -1} {
foreach line $say($cmd) {
puthelp "NOTICE $who :$line"
}
}
}
}
|
Just add another block like:
| Code: |
set say(something) {
"line 1"
"line 2"
"line 3"
}
|
and the !something is automatically created when bot is rehashed, just make sure the trigger word is in lower case.
If you say !rules nick will send the rules (or any of the other commands) to that nick if it's on the channel else won't do anything. If no nick is given then the result will be sent to the person that issued the command.
PS: Haven't tested anything. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
crymsun Voice
Joined: 13 Nov 2018 Posts: 33
|
Posted: Sat Dec 01, 2018 12:13 pm Post subject: |
|
|
| SpiKe^^ wrote: | | I could sure use someone to test this script and report back here please:) |
I didn't want to try it, since the other one you provided worked perfectly. After weeks of hair-pulling insanity, I'm not changing a thing until I become much more fluent in tcl!
Once that happens.. I think I'd like to be able to dictate which ! commands are sent as Notice and which are sent as a query/private message. |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Sun Dec 02, 2018 7:58 pm Post subject: SayHelp ver 1.02 |
|
|
Once we start adding "trigger specific settings" to this script, we quickly get away from the original theme of "Simple, simple, idiot proof !rules script"
With that said, Here is a my first try at keeping it as simple as possible.
This version adds 2 new trigger specific settings. They are both optional.
| Code: |
######################################
## SayHelp ver 1.02 02Dec2018 ##
######################################
namespace eval say { variable say ; variable how ; variable who
array unset say "*" ; array unset how "*" ; array unset who "*"
################ Begin Script Settings ################
variable cmdchar "!" ;# All commands start with this One Character #
## Add as many commands as you want:) ##
## - name each one uniquely, the name is also the trigger ##
## - add as many reply lines as you want to each command ##
## The default reply method is PrivateNotice (send by notice to nick). ##
## There is an optional per-trigger setting available to change that Method. ##
## - add the following line to any command we Don't want send PrivateNotice. ##
## set how(<CommandName>) "<ReplyMethod>" ##
## - 3 valid reply methods: msg =PrivMsg || pub =PubNotc || pubmsg =PubMsg ##
## ex. set how(help) "msg" =send the !help reply by PrivateMessage. ##
## The default commands permissions are: Reply to Everyone on All triggers. ##
## There is an optional per-trigger setting available to limit cmd access. ##
## - add the following line to any command we Don't want Reply to Everyone. ##
## set who(<CommandName>) "<Flags/Modes>" ##
## - Flags can be any valid Eggdrop userfile flags. ##
## ex. set who(admin) "o|o" =check userfile for global or chan o flag. ##
## - Modes can be any of these: +o and/or: +v and/or: +h ##
## ex. set who(admin) "+o" =check for user has +o in the channel. ##
## Advanced example: set who(admin) "ov|ov +o +v" :Flags 1st, space sep. ##
set say(help) {
"These are the help lines for our channel."
"help line 1"
"help line 2"
}
set say(rules) {
"These are the rules of our channel. Pay attention!"
"rule line 1"
"rule line 2"
}
set how(rules) "msg"
set say(admin) {
"These are the admin lines for our channel."
"admin line 1"
"admin line 2"
}
set how(admin) "msg"
set who(admin) "+o"
variable dotarget 1 ;# 1 = target nick enabled # 0 = disabled #
################ End of Settings (Don't edit below) ################
foreach aname [array names say] {
bind pubm - "?%~\\${cmdchar}${aname}*" [namespace current]::sayit
if {[info exists how($aname)] && ![regexp -- {^(pubmsg|msg|pub)$} $how($aname)]} {
unset how($aname)
}
if {[info exists who($aname)]} {
set who($aname) [split [string trim $who($aname)]]
if {[string index [lindex $who($aname) 0] 0] eq "+"} {
set who($aname) [linsert $who($aname) 0 ""]
}
}
}
proc sayit {nk uh hn ch tx} { variable cmdchar ; variable say
lassign [split $tx] cmd target
if {[string index $cmd 0] ne $cmdchar} { return 0 }
set m [lsearch -nocase -inline [array names say] [string range $cmd 1 end]]
if {$m eq ""} { return 0 }
variable dotarget ; variable how ; variable who ; set ok 0
if {[info exists who($m)]} { set mode [lassign $who($m) flag]
if {$flag ne "" && $hn ne "*" && [matchattr $hn $flag $ch]} { set ok 1
} elseif {[lsearch $mode "+o"] >= 0 && [isop $nk $ch]} { set ok 1
} elseif {[lsearch $mode "+h"] >= 0 && [ishalfop $nk $ch]} { set ok 1
} elseif {[lsearch $mode "+v"] >= 0 && [isvoice $nk $ch]} { set ok 1 }
if {$ok == 0} { return 0 }
}
set tgt $nk ; set hows "NOTICE"
if {[info exists how($m)]} {
if {[string match "pub*" $how($m)]} { set tgt $ch }
if {[string match "*msg" $how($m)]} { set hows "PRIVMSG" }
}
if {$dotarget eq "0" || $target eq "" || ![onchan $target $ch]} {
set target $tgt
}
foreach line $say($m) { puthelp "$hows $target :$line" }
return 0
}
}
putlog "SayHelp ver 1.02 Loaded."
|
Edited: Fixed the "Missing Close Bracket" error found below. Thanks Dominatez. _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
Last edited by SpiKe^^ on Tue Jan 15, 2019 9:31 pm; edited 2 times in total |
|
| Back to top |
|
 |
Dominatez Halfop

Joined: 14 Jan 2019 Posts: 46 Location: United Kingdom
|
Posted: Tue Jan 15, 2019 4:22 pm Post subject: |
|
|
Missing Close Bracket on The following code.
| Code: | variable dotarget ; variable how ; variable who ; set ok 0
if {[info exists who($m)]} { set mode [lassign $who($m) flag]
if {$flag ne "" && $hn ne "*" && [matchattr $hn $flag $ch} { set ok 1
} elseif {[lsearch $mode "+o"] >= 0 && [isop $nk $ch]} { set ok 1
} elseif {[lsearch $mode "+h"] >= 0 && [ishalfop $nk $ch]} { set ok 1
} elseif {[lsearch $mode "+v"] >= 0 && [isvoice $nk $ch]} { set ok 1 }
if {$ok == 0} { return 0 }
} |
if {$flag ne "" && $hn ne "*" && [matchattr $hn $flag $ch} { set ok 1
Should be
if {$flag ne "" && $hn ne "*" && [matchattr $hn $flag $ch]} { set ok 1
Or it will throw an error when you do !admin |
|
| Back to top |
|
 |
SpiKe^^ Owner

Joined: 12 May 2006 Posts: 792 Location: Tennessee, USA
|
Posted: Tue Jan 15, 2019 9:37 pm Post subject: SayHelp ver 1.02 |
|
|
Dominatez:
Other than the missing bracket, is this script functioning as intended? _________________ SpiKe^^
Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
. |
|
| Back to top |
|
 |
Dominatez Halfop

Joined: 14 Jan 2019 Posts: 46 Location: United Kingdom
|
Posted: Mon Jan 21, 2019 5:42 pm Post subject: Re: SayHelp ver 1.02 |
|
|
Hi SpiKe^^ : Yes it's working great thanks.
| SpiKe^^ wrote: | Dominatez:
Other than the missing bracket, is this script functioning as intended? |
|
|
| Back to top |
|
 |
|