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.

Verification Option Are you sure Y/N?

Help for those learning Tcl or writing their own scripts.
Post Reply
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Verification Option Are you sure Y/N?

Post by juanamores »

Is it possible in TCL, generates an option to warn the user if it is sure to perform a task?

If the user types 'Y', the task is performed.
If the user types 'N', will not perform the task.
While the user does not enter 'Y' or 'N',the process stops, waiting for an option.

This we have achieved in mSL, but Tcl I understand very little, a few days I started learn this language.
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

Yes it is possible, BogusTrivia uses this exact concept in its /msg bot .add command for adding questions to the database.

Code: Select all

6. Add Questions to Create the Database:

    Using the /msg command, message your bot with one of the .add commands.
    .add is sufficient if you're adding the included question file or files
    with *triv* in the filename(s). Follow the message window as the script may
    ask for user input. It may have you verify by sending you 3 examples from
    the file you're adding.
    You will need to answer yes or no  {or: y or n}. 

    Note: If you are adding multiple question files and you're sure they ALL
          follow the same format, you may answer using "yes all"  {or:  y a}.
          The script provides error correction and creates a file called t2.badqes,
          these are broken Q&A and may later be edited or discarded as you wish.
I did this by making two processes, NOT by "the process stops, waiting for an option".

The first proc accepts the initial command, and sets a few global variables, to save the users nick and any needed info from his command.
1st proc also must make binds for 'Y' and 'N' to the second proc.
You may also wish to set a timer or bind time to remove the variables/binds if user doesn't finish the command (may require a 3rd proc).

The second proc just waits for one of the bound answers to call it.
When called, it confirms the nick, and does as the user has answered, then removes the associated binds/variables.
Make sure if you timer called a 3rd cleanup proc earlier, that it does not error out trying to remove things the 2nd proc already did:)
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

Thanks Spike^^ for your help.

I find it too much work, perhaps for the upload files function is justified, but I just wanted to warn the user when deleting a list.

In mSL can be done easily with a few lines of code :)

The other thing I find difficult is the issue of flags for permits (bind), when executing a command.

In mSL which has a higher level can do everything that you can make someone of lower level, in Tcl I have encountered difficulties.

For example: I have three user levels that identify with the flags: +v local and global +o and +a (besides owner +n).

If I have this:
bind pub o|v !command pub:process
bind pub o|v !command2 pub:process2
Means that only users with channel flag +v and global +o can do it?

How I can do so that they can execute this command, at least 3 levels at once?
User avatar
SpiKe^^
Owner
Posts: 831
Joined: Fri May 12, 2006 10:20 pm
Location: Tennessee, USA
Contact:

Post by SpiKe^^ »

If I have this:

Quote:
bind pub o|v !command pub:process
bind pub o|v !command2 pub:process2

Means that only users with channel flag +v and global +o can do it?
Yes.
How I can do so that they can execute this command, at least 3 levels at once?
Maybe try something like this?

Code: Select all

bind pub oan|v !command2 pub:process2
SpiKe^^

Get BogusTrivia 2.06.4.7 at www.mytclscripts.com
or visit the New Tcl Acrhive at www.tclarchive.org
.
j
juanamores
Master
Posts: 317
Joined: Sun Mar 15, 2015 9:59 am

Post by juanamores »

Pefect! Thanks :)
Post Reply