| View previous topic :: View next topic |
| Author |
Message |
Conc Voice
Joined: 31 Oct 2009 Posts: 6
|
Posted: Sun Nov 01, 2009 5:59 am Post subject: Edit rss.tcl |
|
|
Hi again.
I've downloaded a rss.tcl script. I wanted to edit it. For exemple, before the bot start posting rss, it set mode -S (it's easy) and it set mode +S after posting all rss
| Code: | proc ::rss-synd::feed_msg {type msgs targets {nick ""}} {
# check if our target is a nick
if {(($nick != "") && \
($targets == "")) || \
([regexp -- {[23]} $type])} {
set targets $nick
}
foreach msg $msgs {
foreach chan $targets {
if {([catch {botonchan $chan}] == 0) || \
([regexp -- {^[#&]} $chan] == 0)} {
foreach line [split $msg "\n"] {
if {($type == 1) || ($type == 3)} {
putserv "NOTICE $chan :$line"
} else {
putserv "MODE $chan -S"
putserv "PRIVMSG $chan :$line"
putserv "MODE $chan +S"
}
}
}
}
}
} |
Well... with that code, the bot does this:
| Quote: | * Egg sets mode -S
<Egg> RSS ..... blabla
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...) |
Thanks in advance |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Nov 01, 2009 12:02 pm Post subject: Re: Edit rss.tcl |
|
|
| Code: | # this code uses putquick, it acheives the same result
# as using the pushmode/flushmode code below does.
proc ::rss-synd::feed_msg {type msgs targets {nick ""}} {
# check if our target is a nick
if {(($nick != "") && \
($targets == "")) || \
([regexp -- {[23]} $type])} {
set targets $nick
}
foreach msg $msgs {
foreach chan $targets {
if {([catch {botonchan $chan}] == 0) || \
([regexp -- {^[#&]} $chan] == 0)} {
putquick "MODE $chan -S"
foreach line [split $msg "\n"] {
if {($type == 1) || ($type == 3)} {
putserv "NOTICE $chan :$line"
} else {
putserv "PRIVMSG $chan :$line"
}
}
putquick "MODE $chan +S"
}
}
}
} |
Did you try putting your mode changes outside of the foreach which spams the rss feed? I did.  _________________ speechles' eggdrop tcl archive
Last edited by speechles on Sun Nov 01, 2009 5:55 pm; edited 1 time in total |
|
| Back to top |
|
 |
Conc Voice
Joined: 31 Oct 2009 Posts: 6
|
Posted: Sun Nov 01, 2009 1:04 pm Post subject: |
|
|
| Quote: | * Egg sets mode -S
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...) |
 |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Nov 01, 2009 3:31 pm Post subject: |
|
|
| Conc wrote: | | Quote: | * Egg sets mode -S
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...) |
 |
Lmfao, I forgot priority's here, using the same queue will work. | Code: | # the putserv version is here. This is the code you should
# be using.. The same queue is used for everything.
proc ::rss-synd::feed_msg {type msgs targets {nick ""}} {
# check if our target is a nick
if {(($nick != "") && \
($targets == "")) || \
([regexp -- {[23]} $type])} {
set targets $nick
}
foreach msg $msgs {
foreach chan $targets {
if {([catch {botonchan $chan}] == 0) || \
([regexp -- {^[#&]} $chan] == 0)} {
putserv "MODE $chan -S"
foreach line [split $msg "\n"] {
if {($type == 1) || ($type == 3)} {
putserv "NOTICE $chan :$line"
} else {
putserv "PRIVMSG $chan :$line"
}
}
putserv "MODE $chan +S"
}
}
}
} |
That'll work exactly as you want. Sorry for the earlier, um.. mistake. ;D _________________ speechles' eggdrop tcl archive
Last edited by speechles on Sun Nov 01, 2009 5:56 pm; edited 2 times in total |
|
| Back to top |
|
 |
Conc Voice
Joined: 31 Oct 2009 Posts: 6
|
Posted: Sun Nov 01, 2009 4:10 pm Post subject: |
|
|
if there is just 1 rss feed, it works fine, but if there is more than 2... we have a problem (the same)
1 rss feed:
| Quote: | * Egg sets mode -S
<Egg> RSS ..... blabla
* Egg sets mode +S
|
+2 rss feed:
| Quote: | * Egg sets mode -S
<Egg> RSS ..... blabla
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...)
|
|
|
| Back to top |
|
 |
TCL_no_TK Owner

Joined: 25 Aug 2006 Posts: 509 Location: England, Yorkshire
|
Posted: Sun Nov 01, 2009 4:50 pm Post subject: |
|
|
| Quote: | pushmode <channel> <mode> [arg]
Description: sends out a channel mode change (ex: pushmode #lame +o goober) through the bot's queuing system. All the mode changes will be sent out at once (combined into one line as much as possible) after the script finishes, or when 'flushmode' is called. | sud work out better _________________ TCL the misunderstood |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Nov 01, 2009 5:00 pm Post subject: |
|
|
| Conc wrote: | | if there is just 1 rss feed, it works fine, but if there is more than 2... we have a problem (the same)] |
Look at my post above, use that code. It does it just fine. Put the mode changes outside the foreach. Use the same queue that the messages inside the foreach are using. This works. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Nov 01, 2009 5:04 pm Post subject: |
|
|
Upon putting thought into this it dawned on me why this happens. The order in which rss-synd does the foreaching on it's lists doesn't occur in the order required to do this as easily as I thought.
| Code: | proc ::rss-synd::feed_msg {type msgs targets {nick ""}} {
# check if our target is a nick
if {(($nick != "") && \
($targets == "")) || \
([regexp -- {[23]} $type])} {
set targets $nick
}
foreach msg $msgs {
foreach chan $targets {
if {([catch {botonchan $chan}] == 0) || \
([regexp -- {^[#&]} $chan] == 0)} {
# is this the first time we set the chan +S ?
if {![info exists did_we_s($chan)]} {
# yes, make note so we don't do it again
# and we can undo it later.
set did_we_s($chan) 0
# set the mode
putserv "MODE $chan +S"
}
foreach line [split $msg "\n"] {
if {($type == 1) || ($type == 3)} {
putserv "NOTICE $chan :$line"
} else {
putserv "PRIVMSG $chan :$line"
}
}
}
}
}
# did we make a list of chans to undo +S in?
if {[array exists did_we_s]} {
# yes, iterate them all
foreach c [array names did_we_s] {
# set the mode
putserv "MODE $c -S"
}
}
} |
This will do it, and I've commented the sections I've added to explain why they are there. This uses a simple array to keep track of which channels have been set +S. After sending all messages, this array is run through setting all channels -S. Have a fun.  _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
|