| View previous topic :: View next topic |
| Author |
Message |
Danielle99 Voice
Joined: 16 Nov 2010 Posts: 6
|
Posted: Tue Nov 16, 2010 11:49 pm Post subject: public command for voice and add user |
|
|
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. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed Nov 17, 2010 10:42 am Post subject: Re: public command for voice and add user |
|
|
| 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/1.6.20/tcl-commands.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.
| Quote: |
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. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Wed Nov 17, 2010 10:50 am Post subject: |
|
|
Here is a rudimentary example:
| Code: |
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:
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.
 |
|
| Back to top |
|
 |
Danielle99 Voice
Joined: 16 Nov 2010 Posts: 6
|
Posted: Mon Nov 22, 2010 9:59 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
Danielle99 Voice
Joined: 16 Nov 2010 Posts: 6
|
Posted: Mon Nov 22, 2010 10:05 am Post subject: |
|
|
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. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Mon Nov 22, 2010 10:16 am Post subject: |
|
|
| 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.
| Quote: |
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.
| Quote: |
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?
| Quote: |
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.
 |
|
| Back to top |
|
 |
Danielle99 Voice
Joined: 16 Nov 2010 Posts: 6
|
Posted: Mon Nov 22, 2010 10:43 am Post subject: |
|
|
| Quote: | | [lindex [split $text] 1 ] |
Was exactly what I ment, Thanks.
| Quote: | 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. |
|
| Back to top |
|
 |
Danielle99 Voice
Joined: 16 Nov 2010 Posts: 6
|
Posted: Mon Nov 29, 2010 10:02 am Post subject: |
|
|
| Ok after a long weekend and trying to make this work, I guess I havent got a clue. Can someone please assist? |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Mon Nov 29, 2010 10:15 am Post subject: |
|
|
| 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. |
|
| Back to top |
|
 |
Luminous Op
Joined: 12 Feb 2010 Posts: 146
|
Posted: Mon Nov 29, 2010 12:49 pm Post subject: |
|
|
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: | | 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: | 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.  |
|
| Back to top |
|
 |
Danielle99 Voice
Joined: 16 Nov 2010 Posts: 6
|
Posted: Mon Dec 13, 2010 1:27 pm Post subject: |
|
|
Luminous,
Thanks for the help, I'm much farther along than before, there are still somethings here that are not working as expected.
The | Quote: | | proc asl_kb {$nick $chan} { | does not seem to be working after 30 sec.
and The
| Quote: | } 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. |
|
| Back to top |
|
 |
|
|
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
|
|