| View previous topic :: View next topic |
| Author |
Message |
JAFO Voice
Joined: 13 Oct 2005 Posts: 19
|
Posted: Sat Mar 17, 2007 5:24 am Post subject: Relay / Write |
|
|
Hi all ,
I would like to get some help on a script.
Searched the forum , found some bits and pieces of the script i'd like to have.
TCL aint my strongest side
This is what i found :
| Code: | set relay(chans) "[list #chan1 #chan2 #etc]"; # put the channels within this list of which you want to relay messages from
set relay(who) "[list nick1 nick2 nick3 etc]"; # put here the nicknames of who you want to relay messages from
set relay(to) "#relay-to-this-channel"
bind pubm - {*} relay:pubm
proc relay:pubm {nick uhost hand chan text} {
global relay
if {[lsearch -exact "$relay(chans)" $chan] == -1} { return }
if {[lsearch -exact "$relay(who)" $nick] == -1} { return }
if {[validchan $relay(to)] && [botonchan $relay(to)]} {
puthelp "PRIVMSG $relay(to) :\[[clock format [clock seconds] -format %H:%M:%S]\] <$nick> $text"
}
} |
But instead of relaying to a channel / network , i'd like the bot to write to a file.
IE.
My bot says:
<NFOrce> (NEWS) : blablabla http://blabla
then i wanna put "(NEWS) : blablabla http://blabla" into a file in /home/NFOrce/data.txt ( or any other word i want to echo later )
Also like to know if it's possible if the bot can write his own txt into the file or do i need a new eggdrop for that ??
TIA
JAFO |
|
| Back to top |
|
 |
w00f Halfop
Joined: 04 Oct 2006 Posts: 49
|
Posted: Sat Mar 17, 2007 6:30 pm Post subject: |
|
|
| Code: |
set relay(chans) "[list #chan1 #chan2 #etc]"
set relay(who) "[list nick1 nick2 nick3 etc]"
set relay(db) "NFOrce/nforce.txt"
set relay(db_bak) "NFOrce/nforce.bak.txt"
bind pubm - {*} relay:pubm
proc relay:pubm {nick uhost hand chan text} {
global relay
if {[lsearch -exact "$relay(chans)" $chan] == -1} { return }
if {[lsearch -exact "$relay(who)" $nick] == -1} { return }
if {![file exist $relay(db)]} {
putlog "creating db file ..."
create_db
}
file rename -force $relay(db) $relay(db_bak)
set i 0
set fp [open $relay(db) w]
set bak [open $relay(db_bak) r]
while {![eof $bak]} {
gets $bak line
if {$i == 1} {
puts $fp "$text"
}
if {$line != ""} {
puts $fp $line
}
incr i
}
close $fp
close $bak
}
proc create_db {} {
global relay
set fp [open $relay(db) a]
puts $fp "nforce info"
close $fp
}
putlog "crapy tcl loaded"
|
this code is untested, but i thinks that will work fine.
w00f |
|
| Back to top |
|
 |
JAFO Voice
Joined: 13 Oct 2005 Posts: 19
|
Posted: Sat Mar 17, 2007 7:46 pm Post subject: |
|
|
thx for ya help w00f
But i dont wanna use the .bak.txt.
Also i'd like to specify the word(s) in the line on which it should write to file.
Further help would be much appreciated  |
|
| Back to top |
|
 |
w00f Halfop
Joined: 04 Oct 2006 Posts: 49
|
Posted: Sat Mar 17, 2007 10:54 pm Post subject: |
|
|
You can specify what you want to add by , binding what you want instead of *(with * the bot will put into data file everything that X says in one of the #chans that you specify), regexp $text first in a way to get what you want.
All depends what you want to add to that file, and certainly that I don't know what you want.
for the example you gave, you can bind (NEWS).
bind pub - (NEWS) relay:pubm
this will work for that kind of NFOrce announce.
Like i said you can also add/remove from the $text what you want, but you need to tell what you want in spite of setting up the script.
or i completely misunderstood what you want (hard night here lol) |
|
| Back to top |
|
 |
JAFO Voice
Joined: 13 Oct 2005 Posts: 19
|
Posted: Wed Mar 21, 2007 6:09 am Post subject: |
|
|
maybe this will help.
I have this script that echoes to another channel.
I'd like to have it rewritten so it writes to a file. This script works like a charm, so maybe it be better if ya could help me rewrite this one
| Code: |
#what nicks are allowed to trigger the relay
# you can use wildcards, separate each nick with a space
set rl_nicks "NFOrce"
#source chan to relay from (only put one chan here)
#no wildcards allowed here
set rl_source "#NEWS"
#chans to relay to, separate each chan with a space
#no wildcards allowed here
set rl_dest "#chan1"
#text to watch for in the source chan
#(only put one text string here)
set rl_text "*(NEWS)*"
#DON'T EDIT BELOW HERE
bind pubm - "$rl_text" rl:go
proc rl:go { n u h c t } {
global rl_dest
if {[rl:auth $n $c]} {
set rl_dest [string tolower $rl_dest]
foreach dest $rl_dest {
if {[botonchan $dest]} {
puthelp "PRIVMSG $dest :$t"
}
}
}
}
proc rl:auth { n c } {
global rl_nicks rl_source
set rl_nicks [string tolower $rl_nicks]
set rl_source [string tolower $rl_source]
set n [string tolower $n]
set c [string tolower $c]
foreach m $rl_nicks {
if {[string match "$m" $n] && $c == $rl_source} {
return 1
}
}
return 0
}
|
But here it says
| Code: |
#text to watch for in the source chan
#(only put one text string here)
set rl_text "*(NEWS)*" |
only put one text
i'd like to add several.
TIA  |
|
| Back to top |
|
 |
JAFO Voice
Joined: 13 Oct 2005 Posts: 19
|
Posted: Thu Mar 22, 2007 7:49 pm Post subject: |
|
|
I tried the basic write script , but still nada
It's all mumbojumbo to me, so if anyone could help me out much appreciated. That way i'll get more insight on further tcl probs, since i will learn how the script reacts to what i want.
Hope anyone will help me out here ....
TIA |
|
| Back to top |
|
 |
|