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.

public command for voice and add user

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
D
Danielle99
Voice
Posts: 6
Joined: Tue Nov 16, 2010 11:41 pm

public command for voice and add user

Post by Danielle99 »

I am trying to figure out how to code a script for my bot.

I would like to have a user give a/s/l in channel and on */f/* give voice on that. I would also like the script to add the user with .chattr +fg

I have no idea where to begin. Please help.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Re: public command for voice and add user

Post by willyw »

Danielle99 wrote:I am trying to figure out how to code a script for my bot.
Here are three things that are immense help, when beginning with TCL scripts for Eggdrop bots:

http://suninet.the-demon.de/
Be sure to bookmark this one.
It is worth reading, from start to finish.
Along the way, stop and do some experimenting and have some fun, too.

http://www.eggheads.org/support/egghtml ... mands.html
This is all the Eggdrop specific TCL commands.
Having this at your fingertips is essential.
This is the online version, but you already have a copy of it. Look in your bot's doc/ directory for a file named tcl-commands.doc

http://www.tcl.tk/man/tcl8.5/TclCmd/contents.htm
This is the non-Eggdrop specific commands.
Also essential.
Be sure to bookmark that too.

I would like to have a user give a/s/l in channel and on */f/* give voice on that. I would also like the script to add the user with .chattr +fg

I have no idea where to begin. Please help.
As you read the Suninet pages, and skim through tcl-commands.doc , pay close attention to the parts about
bind
There are many different bind types.
It sounds like you will be wanting a
bind pub
Meaning: your script will have the bot watch for any user to say something specific, and react to it.... a public comment is bound to a procedure.... when "this" happens, do "that".

For your specific need, the trick will be in determining exactly what you want the bot to watch for.
For example:
asl 20 f USA
If so, you could have the bot watch for "asl" as the trigger, and then everything that follows can be data that you operate with in the script....
to give voice if f, and to add the user to bot with +fg, etc. etc.
(On the Suninet site, it even explains how to do
if
look for : 7. Running commands under certain conditions )

I hope this helps.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Here is a rudimentary example:

Code: Select all

bind pub - "asl" voice_fem

proc voice_fem {nick uhost handle chan text} {

set gender [lindex [split $text] 1 ]

     if {"$gender" == "f"} {
	   pushmode $chan +v $nick 
      } 
}

if a user types:
asl x f xxxxx
it will trigger.
x and xxxxx can be anything. But that f there in the middle?.. if it is not an f, then the user is not voiced.
If it is an f, then the user that said it, is voiced.
Thus: the first thing typed must be
asl
and the f must appear in the proper location, for the user to be voiced.

Again, this is a very basic example.

Once you grasp this, we can move on to adding the user, with flags, etc.
:)
D
Danielle99
Voice
Posts: 6
Joined: Tue Nov 16, 2010 11:41 pm

Post by Danielle99 »

I'm still working mty way through this, Thanks for the links, there is a lot of information, I do understand the bind things, I understand the levels of use (-*nom) After looking at your example I dont understand how this connects.

from asl to determining the "f" in the script. Better off I was hoping for a generic Variable/f/variable trigger without a log of data to follow, As i understanf a extra space or mis-type could result in the script not to trigger.
D
Danielle99
Voice
Posts: 6
Joined: Tue Nov 16, 2010 11:41 pm

Post by Danielle99 »

My final concept of this script would be.

use A/S/L to determine m/f.

Voice all Females and kick/ban all males.

Also to require a response to the a/s/l script within lets say 30 sec or it will kick/ban (timed 5 Min) the incomming user onjoin the channel.

Exception: +f

Then add the authorized */f/* or */F/* to the bot +fg (friend and autovoice)


It seems to be a lot and I know very little, I'm dragging myself through it.

I would appreciate all the help I can get.
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Danielle99 wrote:I'm still working mty way through this, Thanks for the links, there is a lot of information, I do understand the bind things, I understand the levels of use (-*nom) After looking at your example I dont understand how this connects.
Yes, it is a lot, at first. :)

"dont' understand how this connects." .. What do you mean by, "connects"?
I need to understand what you are saying, to be able to try to reply.
from asl to determining the "f" in the script.
This is not a sentence, so I'm having trouble figuring it out.
If you are asking how the script finds the "f", that is what this:
[lindex [split $text] 1 ]
does.
Better off I was hoping for a generic Variable/f/variable trigger without a log of data to follow,
Log?
I don't understand... what log?
As i understanf a extra space or mis-type could result in the script not to trigger.
True.

Unfortunately, I'm a bit rushed at the moment, and nothing is coming to mind... other than to remind that was meant to be just an example.
I even referred to it as rudimentary. :)

Perhaps someone else will jump in here with a better idea, before I can return and think about it properly.
It won't upset me at all, if they do.
:)
D
Danielle99
Voice
Posts: 6
Joined: Tue Nov 16, 2010 11:41 pm

Post by Danielle99 »

[lindex [split $text] 1 ]
Was exactly what I ment, Thanks.
Better off I was hoping for a generic Variable/f/variable trigger without a log of data to follow,
It was a typeo "Lot" is what I ment.

Its monday, and there isnt enough coffee for me this morning. I cant seem to type at all. My appologies to all.
D
Danielle99
Voice
Posts: 6
Joined: Tue Nov 16, 2010 11:41 pm

Post by Danielle99 »

Ok after a long weekend and trying to make this work, I guess I havent got a clue. Can someone please assist?
w
willyw
Revered One
Posts: 1203
Joined: Thu Jan 15, 2009 12:55 am

Post by willyw »

Danielle99 wrote:Ok after a long weekend and trying to make this work, I guess I havent got a clue. Can someone please assist?
We can try. :)

Some time has gone by, so it would be best if you posted whatever the "this" is, that you are working with now. Just post the script here.
L
Luminous
Op
Posts: 146
Joined: Fri Feb 12, 2010 1:00 pm

Post by Luminous »

First of all... do you understand how variable setting works? More specifically, do you understand how tcl processes "indices" or "indexes" within a list? If not, then you should learn this before moving on, cause without it, things will be overly hard for you. I can give a quick run down though.

All lists start at element 0. The next item is element 1, then 2, etc. Most programming languages are similar in this way. So if you have this:

Code: Select all

set gender [lindex [split $text] 1]
and the user types "asl * f *" in the channel, the "f" would be element 1. The "asl" part is what triggers the script, and is not counted as a list item. Element 0 in this case would be whatever that first "*" is.

Strings and lists are harder to explain, but I think it's best to say that lists can have multiple indexes, and strings do not. Certain commands are list-only or string-only, and it's crucial to understand the difference.

I don't have a lot of time to test this, but here's what i think might work:

Code: Select all

bind join * * asl
proc asl {nick host hand chan} {
 bind pubm * * form
   putserv "PRIVMSG $chan :$nick: a/s/l?"
   set ::id [utimer 30 [list asl_kb $nick $chan]]
}

bind pubm * * form
proc form {nick host hand chan text} {
  if {[string match -nocase "*/f/*" $text]} {
    unbind pubm * * form
    killutimer $::id
    set host [getchanhost $nick $chan]
    set user [regsub -all {[^a-z]} $nick ""]
    adduser "$user *![join [lrange [split $host @] 0]]@*.[join [lrange [split $host .] end-2 end] .]"
    chattr $user |+fg $chan
    pushmode $chan +v $nick
  
  } elseif {[string match -nocase "*/m/*" $text]} {
    unbind pubm * * form
    set host [getchanhost $nick $chan]
      putquick "MODE $chan +b *![join [lindex [split $host @] 0]]@*.[join [lrange [split $host .] end-2 end] .]"
      putserv "KICK $chan $nick :Wrong response to \"a/s/l\"?"
  }
}

proc asl_kb {$nick $chan} {
  unbind pubm * * form
  set host [getchanhost $nick $chan]
      putquick "MODE $chan +b *![join [lindex [split $host @] 0]]@*.[join [lrange [split $host .] end-2 end] .]"
      putserv "KICK $chan $nick :Took too much time to reply to \"a/s/l?\""
}
Biggest flaw I see without testing is that if more than one person joins during that 30 second window, it should screw it badly. To make it more elaborate, you would have to store each nick into either a global list or(my preference) a file. I could do this, but I have to leave you something to do. :)
D
Danielle99
Voice
Posts: 6
Joined: Tue Nov 16, 2010 11:41 pm

Post by Danielle99 »

Luminous,
Thanks for the help, I'm much farther along than before, there are still somethings here that are not working as expected.

The
proc asl_kb {$nick $chan} {
does not seem to be working after 30 sec.

and The
} elseif {[string match -nocase "*/m/*" $text]} {
seems to be working well.

however I do not get a +v or added to the bot with a */f/*?

Any Idea's? i've tried to check different variations of /F/ and /f/ nothing seems to trigger and add.
Post Reply