egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple talk-back request
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
kny
Voice


Joined: 14 Apr 2009
Posts: 14

PostPosted: Tue Apr 14, 2009 4:54 pm    Post subject: Simple talk-back request Reply with quote

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.
Back to top
View user's profile Send private message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Tue Apr 14, 2009 5:01 pm    Post subject: Reply with quote

Code:

#
 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
 }
Back to top
View user's profile Send private message
kny
Voice


Joined: 14 Apr 2009
Posts: 14

PostPosted: Wed Apr 15, 2009 2:09 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Apr 15, 2009 4:27 pm    Post subject: Reply with quote

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 Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Wed Apr 15, 2009 7:04 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
kny
Voice


Joined: 14 Apr 2009
Posts: 14

PostPosted: Thu Apr 16, 2009 2:07 am    Post subject: Reply with quote

Hi there, this is what happens:

Code:
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.
Back to top
View user's profile Send private message
cache
Master


Joined: 10 Jan 2006
Posts: 306
Location: Mass

PostPosted: Thu Apr 16, 2009 3:56 am    Post subject: Reply with quote

Code:

#
 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
 }
#
Back to top
View user's profile Send private message
kny
Voice


Joined: 14 Apr 2009
Posts: 14

PostPosted: Thu Apr 16, 2009 12:38 pm    Post subject: Reply with quote

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

Code:
[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.
Back to top
View user's profile Send private message
kny
Voice


Joined: 14 Apr 2009
Posts: 14

PostPosted: Thu Apr 16, 2009 12:45 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Thu Apr 16, 2009 1:26 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
kny
Voice


Joined: 14 Apr 2009
Posts: 14

PostPosted: Thu Apr 16, 2009 1:58 pm    Post subject: Reply with quote

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. Smile

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?
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Apr 17, 2009 5:35 am    Post subject: Reply with quote

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

Code:

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:

putquick "PRIVMSG $nick :output text here"


Send the message to a nick as a notice :-

Code:

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
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri Apr 17, 2009 10:35 am    Post subject: Reply with quote

Code:

# 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
Back to top
View user's profile Send private message
kny
Voice


Joined: 14 Apr 2009
Posts: 14

PostPosted: Fri Apr 17, 2009 1:19 pm    Post subject: Reply with quote

Thanks very much, I really appreciate the help.

Smile
Back to top
View user's profile Send private message
Repdientu
Voice


Joined: 30 Apr 2009
Posts: 33
Location: Viet Nam

PostPosted: Mon Jul 27, 2009 1:58 am    Post subject: Reply with quote

i change this but it not worked:
Code:

# 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
????
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber