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

Simple, simple, idiot proof !rules script

Post by crymsun »

Yes, I have read every imaginable manual, readme, sample script, eggdrop doc, etc. I've scoured this site. Even tried some samples but I think they were really old... So I swear I'm not being lazy! Just putting that out there...

I have downloaded a number of scripts regarding setting chan rules. The closest I have gotten - to something that works on Eggdrop 1.8 - is this:

Code: Select all

# rules1.0.tcl inspired by `Dracu|a`
# rewritten from tell1.1.tcl (Lassi Lahtinen lahtinen.lassi@nic.fi) by Wanderer|
# final debug by ShadowLord 
# email me @: jjmacgregor@kscable.com
# version 1.0 a simple and to the point TCL :)

# You can ask help: 
# 1. by emailing me
# 2. I'm on Dalnet in #VladTepes
# 3. Wanderer| is on UnderNET in #TCL
# thanks a lot to Wanderer| and ShadowLord!

# you can start to use rules1.0.tcl after you change "line1" and "line2" (btw 
# you can add lines "line 3" "line 4" etc it's not restricted) to your 
# channel's rules and write public command !rules or !rules <nick> on your chan!

# commands: !rules pastes the rules on open channel !rules <nick> will /notice a 
# individual person the channel rules.

set chanrules { 
  "line 1" 
  "line 2" 
}
 
bind pub o !rules pub:t 

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 $chan :$line" } 
} 
Unfortunately, that results in only certain users (i.e. me the bot owner) being able to use !rules - and it is posted in channel. Only I can use the !rules or !rules <nick>.

I would like the following:
- anyone in chan #ABC to type !rules
- rules are shown them in a /query or somehow privately
- would prefer to do this without files

Just bare bones script, nothing fancy. Thank you!!!
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Try replace existing bind and proc with this..

Code: Select all

bind pub - !rules pub:t

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

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

thank you

Post by crymsun »

Thank you SO much!!! That worked perfectly. I have been pulling my hair out for two weeks trying to learn the code on the fly and edit the scripts.

Thank you again... truly appreciate you taking the time. My blood pressure also thanks you.
c
crymsun
Voice
Posts: 33
Joined: Tue Nov 13, 2018 8:24 pm

Post by crymsun »

One quick question... If I wanted to someday add other text commands, such as !help, could you point out what I would need to change in the script, other than the text list?
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) {
		"rule 1"
		"rule 2"
	}

	set say(help) {
		"help line 1"
		"help line 2"
	}

	bind pub o !rules [namespace current]::rules
	bind pub o !help [namespace current]::help

	proc rules {nick uhost hand chan text} {
		variable say
		if {[scan $text {%s} who] != 0 && [onchan $chan $who]} {
				puthelp "NOTICE $rulenick :These are the rules of our channel. Pay attention!"
				foreach line $say(rules) {
					puthelp "NOTICE $who :$line"
				}
		} else {
			foreach line $say(rules) {
				puthelp "PRIVMSG $chan :$line"
			}
		}
	}
	
	proc help {nick uhost hand chan text} {
		variable say
		if {[scan $text {%s} who] != 0 && [onchan $chan $who]} {
				puthelp "NOTICE $rulenick :These are the help lines for our channel."
				foreach line $say(help) {
					puthelp "NOTICE $who :$line"
				}
		} else {
			foreach line $say(help) {
				puthelp "PRIVMSG $chan :$line"
			}
		}
	}
}
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 »

Caesar

The error I'm getting is:

Tcl error [::say::rules]: can't read "who": no such variable
Last edited by crymsun on Wed Nov 14, 2018 2:09 pm, edited 1 time in total.
c
crymsun
Voice
Posts: 33
Joined: Tue Nov 13, 2018 8:24 pm

Post by crymsun »

Spike - really appreciate how quickly you replied, thank you. The difficulty I am having is that it creates an "i" command - so the rules would be sent to the user no matter what followed the "i" (e.g. when they type !help or !anyword they would still only be sent the rules).
Last edited by crymsun on Wed Nov 14, 2018 12:09 pm, edited 1 time in total.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Re: Simple, simple, idiot proof !rules script

Post by willyw »

crymsun wrote:Yes, I have read every imaginable ....
Found this one yet?

http://tclarchive.org/search.php?str=ho ... =0&sub.y=0

It is described as a "news" script.
Big deal.
What it does is: on command, it reads the contents of a text file out to the channel.
:)

So instead of you putting your rules in the script itself, you simply put them in a text file. This also means that when you change them, you don't even have to rehash the bot.

As for the command:
!news
just find this line:

Code: Select all

bind pub - !news holm-pub_news
and change !news to !rules or whatever you want the command to be (must be unique in your bot though, same as all commands must be unique)

Yes, it is old.
Who cares? ... it works. :)

I hope this helps.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
c
crymsun
Voice
Posts: 33
Joined: Tue Nov 13, 2018 8:24 pm

Post by crymsun »

Thanks willyw.. but I really wanted to avoid the use of other files.

I am SUCH a newbie... and learning the script plus learning all the putty and shell commands/directories. My brain hurts.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

crymsun,

Explain completely what that script is doing now, and what you wish it would do differently.

To me, the patched code seems to address all of your initial requests...
crymsun wrote:I would like the following:
- anyone in chan #ABC to type !rules
- rules are shown them in a /query or somehow privately
- would prefer to do this without files
Last edited by SpiKe^^ on Wed Nov 14, 2018 12:25 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 »

SpiKe^^ wrote:crymsun,

Explain completely what that script is doing now, and what you wish it would do differently.
Using the script you provided, any user that types an i<word> command, gets sent the rules as listed in the rules script.

So... when someone types !rules, they get the rules... unfortunately, when someone types "ihelp" they get the rules (instead of help msg). When someone types "iadmin" they get the rules (instead of admin list).

It appears that the "i" not the "irules" is what triggers the private message of the rules.

What I need to do, is create a few i<word> commands. One for rules, one for help, and one to list current admins. Which would be !rules, !help and !admin. Each of these is simply a text list in its respective script. Could also put all three in one script, if that's easier.
Last edited by crymsun on Wed Nov 14, 2018 12:29 pm, edited 1 time in total.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

That code binds Nothing to "i".
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
w
willyw
Revered One
Posts: 1196
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

crymsun wrote:... all the putty and shell commands/directories. My brain hurts.
Can't say about "putty" commands.

As for working on the shell command line though - I can understand that if you are new to this stuff that it seems like a lot. Please trust though, that nothing is actually hard. There is just a lot of little details. That's why it feels "hard", it's not... it is just overload.
And most of them - like often used shell commands - don't take long to get used to at all. Repetition does it.

There are a zillion shell commands. I doubt that anybody knows them all.
But a few of them? ... you will use them so often that you don't even think, your fingers just fly. :)

What helps sometimes is some direction. So you don't waste time trying to find the right command to do whatever it is you want/need to do.

For example, for editing plain text files - like .tcl files - online, typically an editor named
nano
is available.
Just do: nano filename
and it will open filename if it already exists, and if not, it will created it when you save.
Easy. :)

Good luck with it all.
Learn those basic command line commands ... ask for help if you need it.
Have fun with your bot.
For a fun (and popular) Trivia game, visit us at: irc.librairc.net #science-fiction . Over 300K Q & A to play in BogusTrivia !
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Let us post the Entire Patched Version of the script here...

Code: Select all

# rules1.0.tcl inspired by `Dracu|a`
# rewritten from tell1.1.tcl (Lassi Lahtinen lahtinen.lassi@nic.fi) by Wanderer|
# final debug by ShadowLord 
# email me @: jjmacgregor@kscable.com
# version 1.0 a simple and to the point TCL :)

# You can ask help: 
# 1. by emailing me
# 2. I'm on Dalnet in #VladTepes
# 3. Wanderer| is on UnderNET in #TCL
# thanks a lot to Wanderer| and ShadowLord!

# you can start to use rules1.0.tcl after you change "line1" and "line2" (btw 
# you can add lines "line 3" "line 4" etc it's not restricted) to your 
# channel's rules and write public command !rules or !rules <nick> on your chan!

# commands: !rules pastes the rules on open channel !rules <nick> will /notice a 
# individual person the channel rules.

set chanrules { 
  "line 1" 
  "line 2" 
}
 
bind pub - !rules pub:t

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

Kill your bot entirely and restart it new to remove all existing binds, or Use .restart (Not .rehash)
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 »

So... still only one set of text responds to any ! command... and another problem is that they are displaying to everyone in the channel.. rather than a notice or priv msg.

I did a full kill/restart prior to test. It DID load the one text, no errors coming back at me...

(many, many thanks, Spike for all your help.. truly appreciated!)
Last edited by crymsun on Wed Nov 14, 2018 6:56 pm, edited 1 time in total.
Post Reply