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.

Edit rss.tcl

Support & discussion of released scripts, and announcements of new releases.
Post Reply
C
Conc
Voice
Posts: 6
Joined: Sat Oct 31, 2009 4:38 pm

Edit rss.tcl

Post by Conc »

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: Select all

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:
* Egg sets mode -S
<Egg> RSS ..... blabla
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...)
Thanks in advance
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Re: Edit rss.tcl

Post by speechles »

Code: Select all

# 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. ;)
Last edited by speechles on Sun Nov 01, 2009 5:55 pm, edited 1 time in total.
C
Conc
Voice
Posts: 6
Joined: Sat Oct 31, 2009 4:38 pm

Post by Conc »

* Egg sets mode -S
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...)
:roll:
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Conc wrote:
* Egg sets mode -S
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...)
:roll:
Lmfao, I forgot priority's here, using the same queue will work.

Code: Select all

# 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
Last edited by speechles on Sun Nov 01, 2009 5:56 pm, edited 2 times in total.
C
Conc
Voice
Posts: 6
Joined: Sat Oct 31, 2009 4:38 pm

Post by Conc »

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:
* Egg sets mode -S
<Egg> RSS ..... blabla
* Egg sets mode +S
+2 rss feed:
* Egg sets mode -S
<Egg> RSS ..... blabla
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...)
User avatar
TCL_no_TK
Owner
Posts: 509
Joined: Fri Aug 25, 2006 7:05 pm
Location: England, Yorkshire

Post by TCL_no_TK »

:idea:
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
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

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.
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

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: Select all

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. ;)
Post Reply