| View previous topic :: View next topic |
| Author |
Message |
Sbarkeri Voice
Joined: 11 Aug 2009 Posts: 15
|
Posted: Tue Dec 08, 2009 8:02 pm Post subject: Auto Reply Script |
|
|
Hi I am very new to eggdrops and TCL scripting however I want to make a very simple auto reply script.
I want the bot to scan the public chat in around 3 channels, when someone types something such as !rules or !help I want it to display a string of text to the channel however this string of text will be different for each of the 3 channels.
| Code: | bind pub - !rules rules
proc rules {nickname userhost handle channel arguments} {
puthelp "PRIVMSG #clanbase.mw2 :HI! $nick Rules for Call of Duty 4 http://clanbase.ggl.com/rules.php?lid=5709"
} |
I have so far managed to make that embarrassing efford for a script, it works well however there are a few more things I want to get it to do.
1. If someone types the same command in a different channel I want it to reply with a different message.
2. For it to change the channel mode to [-c] before it sends the message and [+c] just after it has sent it, I had a play around with the PUTMODE command however failed miserably.
3. Somehow enable the use of wildcards so that it detects the text anywhere in the chat and not just at the beggining of the sentence.
I really hope someone can help me here, I am very much a visual basic guy so this TCL stuff is very alien to me.
Cheers  |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Dec 08, 2009 8:27 pm Post subject: |
|
|
In order to send different messages to different channels, use one of the various conditional constructs, and test the value of the variable channel. Here I'll go with the switch construct, as it is easily extended to handle many different values of the tested variable. I also use a command (string tolower) to make sure the channel name is always in lower case, since switch cares for case:
| Code: | proc rules {nickname userhost handle channel arguments} {
switch [string tolower $channel] {
"#clanbase.mw2" {
putserv "MODE #clanbase.mw2 -c"
putserv "PRIVMSG #clanbase.mv2 :Hi $nick! Rules for Call of Duty 4 http://clanbase.ggl.com/rules.phpp?lid=5709"
putserv "MODE #clanbase.mw2 +c"
}
"#clanbase.other" {
putserv "MODE #clanbase.mw2 -c"
putserv "PRIVMSG #clanbase.other :Hi $nick! Rules for Other yet to come"
putserv "MODE #clanbase.mw2 +c"
}
}
} |
With putmode, I assume you're thinking of pushmode. Pushmode has the ability to group up mode changes to the most efficient sets (depending on settings). As such, it will not issue the changes directly, but put them in a list that will be tended to once the proc ends. Any double or contradictive mode-changes will then be ignored, and modes stacked as efficiently as possible.
In the code above, I used the putserv instead, which sends the mode command directly to the SERV-queue (fairly fast queue in eggdrop), so the commands should be sent out in the order I issue them.
If you'd like to trigger on anything containing !rules, rather than starting with !rules, you'll need to change your binding from the public command binding (pub), into the public match (pubm):
| Code: | | bind pubm - "% *!rules*" rules |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Sbarkeri Voice
Joined: 11 Aug 2009 Posts: 15
|
Posted: Tue Dec 08, 2009 9:18 pm Post subject: |
|
|
Wow, can't thank you enough, you just solved my 2 days of install various TCL scripts in 20 minutes!
Really though cheers mate can't thank you enough.
Just one small question that I'm sure requires 1 or 2 lines of code, I want to send a message cross channel (the bot is in both channels so it should be fine just to use PRIVMSG). I want one of the admins in the channel #clanbase.crew.mw2 to be able to type "!wars USERHERE" and then a message to appear in #clanbase.mw2 saying "*Notice for USERHERE* Please do not search for wars here, it is a support channel". I am thinking a variable needs to be created for the USERNAME the admin enters however not sure how to go about it in TCL.
Cheers once again. |
|
| Back to top |
|
 |
blake Master
Joined: 23 Feb 2009 Posts: 201
|
Posted: Wed Dec 09, 2009 7:41 am Post subject: |
|
|
| Code: | bind pub o|o !wars wars_proc
proc wars_proc { nick uhost hand chan arg } {
putserv "PRIVMSG #clanbase.mw2 :Notice for $nick Please do not search for wars here, it is a support channel"
} |
type !wars nickname that should work _________________ Blake
UKEasyHosting UKStormWatch |
|
| Back to top |
|
 |
TCL_no_TK Owner

Joined: 25 Aug 2006 Posts: 509 Location: England, Yorkshire
|
Posted: Wed Dec 09, 2009 12:13 pm Post subject: |
|
|
| Code: | bind pub -|- !wars pub:wars
proc pub:wars {nick host hand chan text} {
if {![string match [string tolower $chan] "#clanbase.mw2"]} {
return 0
}
if {[llength $text] == 0} {
puthelp "PRIVMSG $chan :\002Please do no search for wars here!\002 This is a Support Channel Only!"
} else {
set target [lindex [split $text] 0]
puthelp "PRIVMSG $chan :\002$target\002 Please do not search for wars here! This is a Support Channel Only!"
}
} | $nick is equal to the person that issued the command, not the nickname given with the command. the above code, allows for !wars and !wars nickname _________________ TCL the misunderstood |
|
| Back to top |
|
 |
Sbarkeri Voice
Joined: 11 Aug 2009 Posts: 15
|
Posted: Wed Dec 09, 2009 1:10 pm Post subject: |
|
|
TCL_no_TK just tried the script you posted now and it works like a charm! How can I edit to script to monitor 2 "host" channels and send different messages to 2 different "client" channels.
For example I will have the bot in the channels, #clanbase.crew.cod4 and #clanbase.crew.mw2 (these are both admin channels). I will also have the bot in #clanbase.cod4 and #clanbase.mw2 (these are general support channels). I want the admin to type !wars in the crew channel and the message to display in the support channels, however I want 2 different messages to display for each channel respectivly. |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Wed Dec 09, 2009 7:08 pm Post subject: |
|
|
Have you tried/looked at the Putserv-O-Matic script?
| Code: | "!wars|#clanbase.crew.mw2|privmsg #clanbase.mw2 :\002Please do no search for wars here!\002 This is the first message in one channel!"
"!wars|#clanbase.crew.cod4|privmsg #clanbase.cod4 :\002Please do no search for wars here!\002 This is a second message in a different channel!" |
Construct "mycommads" for it like above. There are several ways to use this but there limits to how far this goes. This should help you get most of what you want going with minimal ease. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
Sbarkeri Voice
Joined: 11 Aug 2009 Posts: 15
|
Posted: Wed Dec 09, 2009 10:22 pm Post subject: |
|
|
| Yes I did try it out before my initial post on here, however I couldn't figure out how to make it change the chanel mode of the TARGET channel before it sent the message to it. I've been trying to edit the script by TCL_no_TK which works great to all my needs as I have added the channel flag changer myself, however I cannot work out how to make it monitor 2 channels for the same !xxxx command and supply 2 different responces based on which channel requested it, I have been playing around with the "elseif" to see if I could add in a line or two of code however my eggdrop crashes upon a rehash clearly telling me that my TCL isn't good. |
|
| Back to top |
|
 |
TCL_no_TK Owner

Joined: 25 Aug 2006 Posts: 509 Location: England, Yorkshire
|
Posted: Thu Dec 10, 2009 7:50 am Post subject: |
|
|
| Code: | if {![string match [string tolower $chan] "#clanbase.mw2"]} {
return 0
} | Makes the script only work on #clanbase.mw2 I've used $chan which due to the code at the top would be #clanbase.mw2 so you can change | Code: | | puthelp "PRIVMSG $chan : | to | Code: | | puthelp "PRIVMSG #clanbase.cod4 : | to send one of the warnings to #clanbase.cod4
(so lets make it send the warning to #clanbase.cod4 if a nickname is given with the !wars command)
Example: | Code: | bind pub -|- !wars pub:wars
proc pub:wars {nick host hand chan text} {
if {![string match [string tolower $chan] "#clanbase.mw2"]} {
return 0
}
if {[llength $text] == 0} {
puthelp "PRIVMSG $chan :\002Please do no search for wars here!\002 This is a Support Channel Only!"
} else {
set target [lindex [split $text] 0]
puthelp "PRIVMSG #clanbase.cod4 :\002$target\002 Please do not search for wars here! This is a Support Channel Only!"
}
} | This would still only work in #clanbase.mw2 but if someone wanted to warn a nickname (i.e uses !wars <nickname> it would warn them in #clanbase.cod4 and not in #clanbase.mw2
As for the differant messages for differant channels, you could try editing the code to something like | Code: | bind pub -|- !wars pub:wars
proc pub:wars {nick host hand chan text} {
if {[string match [string tolower $chan] "#clanbase.mw2"]} {
# This is the warning we use for #clanbase.mw2 when someone uses !wars or !wars <nickname>
set msg "Please do not search for wars here! This is a support channel only!"
} else {
# This is the warning we use for ANY other channel than #clanbase.mw2 when someone uses !wars or !wars <nickname>
set msg "Please visit are channel rules http://are.channel.ru/les.php!"
}
if {[llength $text] == 0} {
puthelp "PRIVMSG $chan :\002$msg\002"
} else {
set target [lindex [split $text] 0]
puthelp "PRIVMSG #clanbase.cod4 :\002$target\002 $msg"
}
} |
Hopefully i explained it a little better for you to edit it and play around with the code a bit  _________________ TCL the misunderstood |
|
| Back to top |
|
 |
|