egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple, simple, idiot proof !rules script
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
crymsun
Voice


Joined: 13 Nov 2018
Posts: 16

PostPosted: Tue Nov 13, 2018 8:34 pm    Post subject: Simple, simple, idiot proof !rules script Reply with quote

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:

# 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!!!
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 583
Location: Tennessee, USA

PostPosted: Tue Nov 13, 2018 9:47 pm    Post subject: Reply with quote

Try replace existing bind and proc with this..

Code:

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
.
Back to top
View user's profile Send private message Visit poster's website
crymsun
Voice


Joined: 13 Nov 2018
Posts: 16

PostPosted: Tue Nov 13, 2018 11:40 pm    Post subject: thank you Reply with quote

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.
Back to top
View user's profile Send private message
crymsun
Voice


Joined: 13 Nov 2018
Posts: 16

PostPosted: Wed Nov 14, 2018 12:00 am    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
caesar
Ass Kicker


Joined: 14 Oct 2001
Posts: 3516
Location: Top Secret

PostPosted: Wed Nov 14, 2018 1:55 am    Post subject: Reply with quote

Code:

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.
_________________
You may say anything about me, but at least don't misspell my name. xD
Back to top
View user's profile Send private message
crymsun
Voice


Joined: 13 Nov 2018
Posts: 16

PostPosted: Wed Nov 14, 2018 8:57 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
crymsun
Voice


Joined: 13 Nov 2018
Posts: 16

PostPosted: Wed Nov 14, 2018 10:42 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
willyw
Owner


Joined: 15 Jan 2009
Posts: 975

PostPosted: Wed Nov 14, 2018 10:55 am    Post subject: Re: Simple, simple, idiot proof !rules script Reply with quote

crymsun wrote:
Yes, I have read every imaginable ....


Found this one yet?

http://tclarchive.org/search.php?str=holm-news&cb1=t&cb2=a&cb3=d&sub.x=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.
Smile

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:

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

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 !
Back to top
View user's profile Send private message
crymsun
Voice


Joined: 13 Nov 2018
Posts: 16

PostPosted: Wed Nov 14, 2018 12:11 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 583
Location: Tennessee, USA

PostPosted: Wed Nov 14, 2018 12:18 pm    Post subject: Reply with quote

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

_________________
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 Wed Nov 14, 2018 12:25 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
crymsun
Voice


Joined: 13 Nov 2018
Posts: 16

PostPosted: Wed Nov 14, 2018 12:25 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 583
Location: Tennessee, USA

PostPosted: Wed Nov 14, 2018 12:28 pm    Post subject: Reply with quote

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
.
Back to top
View user's profile Send private message Visit poster's website
willyw
Owner


Joined: 15 Jan 2009
Posts: 975

PostPosted: Wed Nov 14, 2018 12:31 pm    Post subject: Reply with quote

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

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

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 !
Back to top
View user's profile Send private message
SpiKe^^
Owner


Joined: 12 May 2006
Posts: 583
Location: Tennessee, USA

PostPosted: Wed Nov 14, 2018 12:33 pm    Post subject: Reply with quote

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

Code:

# 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
.
Back to top
View user's profile Send private message Visit poster's website
crymsun
Voice


Joined: 13 Nov 2018
Posts: 16

PostPosted: Wed Nov 14, 2018 6:25 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber