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.

Simple, simple, idiot proof !rules script

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
c
crymsun
Voice
Posts: 33
Joined: Tue Nov 13, 2018 8:24 pm

Post by crymsun »

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).
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
c
crymsun
Voice
Posts: 33
Joined: Tue Nov 13, 2018 8:24 pm

Post by crymsun »

Here is what I am currently working with (having given up on trying to do !rules !help and !admin)..

Code: Select all

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.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Please try this script based on caesar's previous post.

Code: Select all

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."

Last edited by SpiKe^^ on Mon Nov 26, 2018 11:55 pm, edited 1 time in total.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
c
crymsun
Voice
Posts: 33
Joined: Tue Nov 13, 2018 8:24 pm

Post by crymsun »

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.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

SayHelp ver 1.01

Post by SpiKe^^ »

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: Select all

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
.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

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
.
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

Code: Select all

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: Select all

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.
c
crymsun
Voice
Posts: 33
Joined: Tue Nov 13, 2018 8:24 pm

Post by crymsun »

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.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

SayHelp ver 1.02

Post by SpiKe^^ »

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: Select all

######################################
## 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.
Last edited by SpiKe^^ on Tue Jan 15, 2019 9:31 pm, edited 2 times in total.
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Post by Dominatez »

Missing Close Bracket on The following code.

Code: Select all

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
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

SayHelp ver 1.02

Post by SpiKe^^ »

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
.
User avatar
Dominatez
Halfop
Posts: 50
Joined: Mon Jan 14, 2019 5:08 pm
Location: United Kingdom

Re: SayHelp ver 1.02

Post by Dominatez »

Hi SpiKe^^ : Yes it's working great thanks.

SpiKe^^ wrote:Dominatez:

Other than the missing bracket, is this script functioning as intended?
Post Reply