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 

Edit rss.tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases
View previous topic :: View next topic  
Author Message
Conc
Voice


Joined: 31 Oct 2009
Posts: 6

PostPosted: Sun Nov 01, 2009 5:59 am    Post subject: Edit rss.tcl Reply with quote

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


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

PostPosted: Sun Nov 01, 2009 12:02 pm    Post subject: Re: Edit rss.tcl Reply with quote

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. Wink
_________________
speechles' eggdrop tcl archive


Last edited by speechles on Sun Nov 01, 2009 5:55 pm; edited 1 time in total
Back to top
View user's profile Send private message
Conc
Voice


Joined: 31 Oct 2009
Posts: 6

PostPosted: Sun Nov 01, 2009 1:04 pm    Post subject: Reply with quote

Quote:
* Egg sets mode -S
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...)


Rolling Eyes
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: Sun Nov 01, 2009 3:31 pm    Post subject: Reply with quote

Conc wrote:
Quote:
* Egg sets mode -S
* Egg sets mode +S
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
<Egg> RSS ..... blabla
(...)


Rolling Eyes


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
View user's profile Send private message
Conc
Voice


Joined: 31 Oct 2009
Posts: 6

PostPosted: Sun Nov 01, 2009 4:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
TCL_no_TK
Owner


Joined: 25 Aug 2006
Posts: 509
Location: England, Yorkshire

PostPosted: Sun Nov 01, 2009 4:50 pm    Post subject: Reply with quote

Idea
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
View user's profile Send private message Send e-mail
speechles
Revered One


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

PostPosted: Sun Nov 01, 2009 5:00 pm    Post subject: Reply with quote

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


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

PostPosted: Sun Nov 01, 2009 5:04 pm    Post subject: Reply with quote

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. Wink
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Support & Releases All times are GMT - 4 Hours
Page 1 of 1

 
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