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.

Simple talk-back request

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
k
kny
Voice
Posts: 14
Joined: Tue Apr 14, 2009 4:50 pm

Simple talk-back request

Post by kny »

Hi folks, new to this and just after a very basic request, if I may.

I just want a simple chat-back function, ie:

If someone (anyone, irrespective of channel status) says a predetermined config'd word such as 'hi', the bot responds with 'hi' in the same channel.

As basic and crude as I can put it.

Thanks in advance.
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

Code: Select all

#
 set hi_flood_control 0
 set hello_msg {
 "hey"
 "hello"
 "yo"

}
bind pub -|- hi hi:reply
proc hi:reply {nick uhost handle channel text} {
   global hi_flood_control hello_msg
   if {$hi_flood_control == "1"} {return 0}
   set hi_flood_control 1
   timer 240 [list set hi_flood_control 0]
   set temp_hi $hello_msg
   set temp_hi [lindex $temp_hi [rand [llength $temp_hi]]]
   putquick "PRIVMSG $channel :\001ACTION $temp_hi \001"
   return 0
 }
k
kny
Voice
Posts: 14
Joined: Tue Apr 14, 2009 4:50 pm

Post by kny »

I've PM'd cache on this, but would also like to post here in case he/she is not around for a while, but also to potentially help others and keep the fix in the forum database.

I dumped that code into a new file, gave it .tcl extension and added it to /scripts/ and placed 'source scripts/name.tcl' into my bot config. Unfortunately after a rehash it killed the bot so I've had to uncomment it out for now.

Am I missing something to add in the file?

Thanks, all.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

http://forum.egghelp.org/viewtopic.php?t=15889&start=17

The "putserv-o-matic" script can easily do what you want and won't crash your bot ;)
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

kny wrote:I've PM'd cache on this, but would also like to post here in case he/she is not around for a while, but also to potentially help others and keep the fix in the forum database.

I dumped that code into a new file, gave it .tcl extension and added it to /scripts/ and placed 'source scripts/name.tcl' into my bot config. Unfortunately after a rehash it killed the bot so I've had to uncomment it out for now.

Am I missing something to add in the file?

Thanks, all.
It is working fine for me. What error msg you get in logs?
k
kny
Voice
Posts: 14
Joined: Tue Apr 14, 2009 4:50 pm

Post by kny »

Hi there, this is what happens:

Code: Select all

Eggdrop v1.6.19 (C) 1997 Robey Pointer (C) 2008 Eggheads
[07:03] --- Loading eggdrop v1.6.19 (Thu Apr 16 2009)
[07:03] Listening at telnet port 3366 (all).
[07:03] Module loaded: dns             
[07:03] Module loaded: channels        
[07:03] Module loaded: server          
[07:03] Module loaded: ctcp            
[07:03] Module loaded: irc             
[07:03] Module loaded: notes            (with lang support)
[07:03] Module loaded: console          (with lang support)
[07:03] Module loaded: blowfish        
[07:03] Module loaded: uptime          
[07:03] Tcl error in file 'bot.conf':
[07:03] invalid command name "\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf430
{\fonttbl\f0\fmodern\fcharset0 Courier;}
{\colortbl;\red255\green255\blue255;\red18\green131\blue4;}
\paperw11900\paperh16840\margl1440\margr1440\vieww9000\viewh8400\viewkind0
\deftab720
\pard\pardeftab720\ql\qnatural

\f0\fs22 \cf2 #  \'a0set hi_flood_control 0  \'a0set hello_msg \{  \'a0"hey"  \'a0"hello"  \'a0"yo"   \}  bind pub -|- hi hi:reply  proc hi:reply \{nick uhost handle channel text\} \{  \'a0 \'a0global hi_flood_control hello_msg  \'a0 \'a0if \{$hi_flood_control == "1"\} \{return 0\}  \'a0 \'a0set hi_flood_control 1  \'a0 \'a0timer 240 [list set hi_flood_control 0]  \'a0 \'a0set temp_hi $hello_msg  \'a0 \'a0set temp_hi [lindex $temp_hi [rand [llength $temp_hi]]]  
[07:03] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
If I uncomment out source scripts/name.tcl the bot will load up fine.


Thanks for the replies, folks.
c
cache
Master
Posts: 306
Joined: Tue Jan 10, 2006 4:59 am
Location: Mass

Post by cache »

Code: Select all

#
 set hi_flood_control 0
 set his_msg {
 "Hi 4"
 "Hi 3"
 "Hi 2"
 "Hi 1"

}
bind pubm -|- "*hi*" hi:reply
proc hi:reply {nick uhost handle channel text} {
   global hi_flood_control his_msg
   if {$hi_flood_control == "1"} {return 0}
   set hi_flood_control 1
   timer 240 [list set hi_flood_control 0]
   set temp_hi $his_msg
   set temp_hi [lindex $temp_hi [rand [llength $temp_hi]]]
   putquick "PRIVMSG $channel :\001ACTION $temp_hi \001"
   return 0
 }
#
k
kny
Voice
Posts: 14
Joined: Tue Apr 14, 2009 4:50 pm

Post by kny »

Here's what's happened after trying the updated script:

Code: Select all

[17:36:05] <bot> Rehashing.
[17:36:05] <bot> [17:36] Writing user file...
[17:36:05] <bot> [17:36] Writing channel file...
[17:36:05] <bot> [17:36] Rehashing ...
[17:36:05] <bot> [17:36] Listening at telnet port 3366 (all).
[17:36:05] <bot> [17:36] Tcl error in file 'bot.conf':
[17:36:05] <bot> [17:36] invalid command name "\rtf1\ansi\ansicpg1252\cocoartf949\cocoasubrtf430
[17:36:05] <bot> {\fonttbl\f0\fmodern\fcharset0 Courier;}
[17:36:05] <bot> {\colortbl;\red255\green255\blue255;\red18\green131\blue4;}
[17:36:05] <bot> \paperw11900\paperh16840\margl1440\margr1440\vieww9000\viewh8400\viewkind0
[17:36:05] <bot> \deftab720
[17:36:05] <bot> \pard\pardeftab720\ql\qnatural
[17:36:05] <bot> 
[17:36:05] <bot> \f0\fs22 \cf2 #  \'a0set hi_flood_control 0  \'a0set his_msg \{  \'a0"Hi 4"  \'a0"Hi 3"  \'a0"Hi 2"  \'a0"Hi 1"   \}  bind pubm -|- "*hi*" hi:reply  proc hi:reply \{nick uhost handle channel text\} \{ 
[17:36:05] <bot> [17:36] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
-
DCC session closed
I'm using Eggdrop v1.6.19 if that makes any difference?

Cheers folks.
k
kny
Voice
Posts: 14
Joined: Tue Apr 14, 2009 4:50 pm

Post by kny »

I've just tried the same test script on a second bot I'm running using 1.6.17, on a true shell provider and get the same issue.

I wanted to test this, as the one I want to add this script on is running off Mac OS X, so I wanted to eliminate OS X from the equation and also the versioning differences.
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

You seem to be picking up rtf (rich text format) tags from somewhere when you copy paste into your text editor and save as a .tcl file.
I must have had nothing to do
k
kny
Voice
Posts: 14
Joined: Tue Apr 14, 2009 4:50 pm

Post by kny »

arfer wrote:You seem to be picking up rtf (rich text format) tags from somewhere when you copy paste into your text editor and save as a .tcl file.
That's the one, thanks a lot for spotting, I'd never have known. I'm using a flat/fresh version of OS X and didn't set the text editor to save as plain text. The script(s) shown above now work - thank you to those who have contributed, but I have two final questions and I'll leave you all alone. :-)

The scripts cache has kindly provided means the bots responds with a /me action as opposed to a standard /say

- How would I alter that
- And how would I alter what the initial 'hi' trigger is, so the bot uses a different word (or two) to act upon?
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Send the output message to the channel as normal chat :-

Code: Select all

putquick "PRIVMSG $channel :output text here"
Send the message to a nick as a private message (can be annoying because it opens a private message window) :-

Code: Select all

putquick "PRIVMSG $nick :output text here"
Send the message to a nick as a notice :-

Code: Select all

putquick "NOTICE $nick :output text here"
One or more of the posts above demonstrate a means of preconfiguring different text triggers and responding to them.
I must have had nothing to do
User avatar
arfer
Master
Posts: 436
Joined: Fri Nov 26, 2004 8:45 pm
Location: Manchester, UK

Post by arfer »

Code: Select all

# space delimited list of channels that the script will function in
set vChannels "#eggTCL #nothing"

# list of channel text words/phrases that the bot will respond to
set vGreets {
    "hi"
    "hey"
    "hello"
    "g'day"
    "sup?"
    "good morning"
    "good evening"
}

# list of possibe responses from which one will be chosen randomly for the bot's response
set vResponses {
    "shut up"
    "hi"
    "hey"
    "what?"
    "go away"
}

# output type for bot's response
# 1 = action
# 2 = channel text
# 3 = private query to nick
# 4 = notice to nick
set vType 2

bind PUBM - * pRespond

proc pRespond {nick uhost hand channel txt} {
    global vChannels vGreets vResponses vType
    if {[lsearch -exact [string tolower $vChannels] [string tolower $channel]] != -1} {
        if {![isbotnick $nick]} {
            foreach phrase $vGreets {
                if {[regexp -- [subst -nobackslashes {(?i)\m$phrase\M}] $txt]} {
                    set response [lindex $vResponses [rand [llength $vResponses]]]
                    switch -- $vType {
                        1 {putquick "PRIVMSG $channel :\001ACTION $response\001"}
                        2 {putquick "PRIVMSG $channel :$response"}
                        3 {putquick "PRIVMSG $nick :$response"}
                        4 {putquick "NOTICE $nick :$response"}
                    }
                    break
                }
            }
        }
    }
    return 0
}
I must have had nothing to do
k
kny
Voice
Posts: 14
Joined: Tue Apr 14, 2009 4:50 pm

Post by kny »

Thanks very much, I really appreciate the help.

:-)
R
Repdientu
Voice
Posts: 37
Joined: Thu Apr 30, 2009 3:45 am
Location: Viet Nam
Contact:

Post by Repdientu »

i change this but it not worked:

Code: Select all

# space delimited list of channels that the script will function in
set vChannels "#VinaChat #Game"

# list of channel text words/phrases that the bot will respond to
set vGreets {
    "hi"
    "hey"
    "hello"
    "hi all"
    "chao"
    "good morning"
    "good evening"
}

# list of possibe responses from which one will be chosen randomly for the bot's response
set vResponses {
    "hello $nick. Good day"
    "hi $nick"
    "hey $nick"
    "what? $nick"
    "go away $nick"
}

# output type for bot's response
# 1 = action
# 2 = channel text
# 3 = private query to nick
# 4 = notice to nick
set vType 2

bind PUBM - * pRespond

proc pRespond {nick uhost hand channel txt} {
    global vChannels vGreets vResponses vType
    if {[lsearch -exact [string tolower $vChannels] [string tolower $channel]] != -1} {
        if {![isbotnick $nick]} {
            foreach phrase $vGreets {
                if {[regexp -- [subst -nobackslashes {(?i)\m$phrase\M}] $txt]} {
                    set response [lindex $vResponses [rand [llength $vResponses]]]
                    switch -- $vType {
                        1 {putquick "PRIVMSG $channel :\001ACTION $response\001"}
                        2 {putquick "PRIVMSG $channel :$response"}
                        3 {putquick "PRIVMSG $nick :$response"}
                        4 {putquick "NOTICE $nick :$response"}
                    }
                    break
                }
            }
        }
    }
    return 0
} 
when i type:
<Rdt> hi
<ChanBot> hi $nick
<Rdt>hello
<ChanBot>hello $nick. Good day

i want to fix $nick = Rdt
Eg:
<Rdt>hello
<ChanBot> hello Rdt. Good day
????
Post Reply