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
}
It is working fine for me. What error msg you get in logs?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.
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)
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
}
#
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
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.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.
Code: Select all
putquick "PRIVMSG $channel :output text here"
Code: Select all
putquick "PRIVMSG $nick :output text here"
Code: Select all
putquick "NOTICE $nick :output text here"
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
}
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
}