Esempio n. 1
0
 def main(inner, self, state):
     try:
         while True:
             yield inner.sub(self.timed(self.write_interval) 
                             | threado.dev_null())
     except services.Stop:
         inner.finish()
Esempio n. 2
0
    def main(inner, self):
        conn = yield self.xmpp_connect()
        dst = yield conn.muc.join(self.room_dst, self.bot_name)
        self.log.info("Joined room %r", self.room_dst), dst

        yield generate() | events_to_elements_with_delay_element(
        ) | dst | threado.dev_null()
Esempio n. 3
0
 def main(inner, self):
     dst = yield inner.sub(self._join("dst",
                                      self.xmpp_dst_jid,
                                      self.xmpp_dst_password,
                                      self.xmpp_dst_room))
     src = yield inner.sub(self._join("src",
                                      self.xmpp_src_jid,
                                      self.xmpp_src_password,
                                      self.xmpp_src_room))
     yield inner.sub(src | peel_messages() | dst | threado.dev_null())
Esempio n. 4
0
    def _room(inner, self, name):
        self.log.info("Joining room %r", name)
        room = yield inner.sub(self.xmpp.muc.join(name, self.bot_name))

        self.log.info("Joined room %r", name)
        try:
            yield inner.sub(events.events_to_elements()
                            | room
                            | threado.dev_null())
        finally:
            self.log.info("Left room %r", name)
Esempio n. 5
0
    def handle_room(inner, self, xmpp, name, alerter):
        self.log.info("Joining room %r", name)
        room = yield inner.sub(xmpp.muc.join(name, self.bot_name))
        self.log.info("Joined room %r", name)

        try:
            yield inner.sub(room 
                            | self.watch(alerter) 
                            | threado.dev_null())
        finally:
            self.log.info("Left room %r", name)
Esempio n. 6
0
def main(inner, jid, password, src_roomname, dst_roomname):
    # Join the XMPP network
    conn = yield xmpp.connect(jid, password)

    # Join the XMPP rooms
    src = yield conn.muc.join(src_roomname, "bot")
    dst = yield conn.muc.join(dst_roomname, "bot")

    # Forward body elements from the src room to the dst room,
    # but filter away stuff by the bot itself to avoid nasty loops.
    own_jid = src.nick_jid
    yield src | room_filter(own_jid) | dst | threado.dev_null()
Esempio n. 7
0
    def main(inner, self):
        # Join the XMPP network using credentials given from the command line
        conn = yield self.xmpp_connect()

        # Join the XMPP rooms
        src = yield conn.muc.join(self.room_src, self.bot_name)
        dst = yield conn.muc.join(self.room_dst, self.bot_name)
        self.log.info("Joined rooms %r and %r", self.room_src, self.room_dst)

        # Forward body elements from the src room to the dst room
        # but filter away stuff by the bot itself to avoid nasty loops.
        own_jid = src.nick_jid
        yield src | self.room_filter(own_jid) | dst | threado.dev_null()
Esempio n. 8
0
    def main(inner, self, dedup):
        if dedup is None:
            dedup = Dedup(10**6)

        try:
            yield inner.sub(self.feed() 
                            | self._dedup(dedup)
                            | self.augment()
                            | self._distribute()
                            | self._stats()
                            | threado.dev_null())
        except services.Stop:
            inner.finish(dedup)
Esempio n. 9
0
    def handle_room(inner, self, name):
        self.log.info("Joining room %r", name)
        room = yield inner.sub(self.xmpp.muc.join(name, self.bot_name))
        self.log.info("Joined room %r", name)

        try:
            yield inner.sub(room
                            | self.skip_own(room)
                            | events.stanzas_to_events()
                            | self.history.collect(unicode(room.room_jid))
                            | threado.dev_null())
        finally:
            self.log.info("Left room %r", name)
Esempio n. 10
0
    def main(inner, self):
        # Join the XMPP network using credentials given from the command line
        conn = yield self.xmpp_connect()

        # Join the XMPP room
        room = yield conn.muc.join(self.xmpp_room, self.bot_name)
        self.log.info("Joined room %r", self.xmpp_room)

        # Fetch the URL info and data as an file-like object.
        # Info contains e.g. the HTTP(S) headers, ignored for now.
        info, fileobj = yield utils.fetch_url(self.url)
        self.log.info("Opened URL %r", self.url)
        
        yield self.parse(fileobj) | events.events_to_elements() | room | threado.dev_null()
Esempio n. 11
0
    def main(inner, self):
        # Join the XMPP network using credentials given from the command line
        conn = yield self.xmpp_connect()

        # Join the XMPP room
        room = yield conn.muc.join(self.xmpp_room, self.bot_name)
        self.log.info("Joined room %r", self.xmpp_room)

        # Fetch the URL info and data as an file-like object.
        # Info contains e.g. the HTTP(S) headers, ignored for now.
        info, fileobj = yield utils.fetch_url(self.csv_url)
        self.log.info("Opened URL %r", self.csv_url)

        # csv_to_events feeds out abusehelper.core.events.Event
        # objects, so convert them to XML elements before sending them
        # to the room.
        csv_feed = utils.csv_to_events(fileobj,
                                       delimiter=self.csv_delimiter,
                                       columns=self.csv_columns)
        yield csv_feed | events.events_to_elements() | room | threado.dev_null()
Esempio n. 12
0
    def main(inner, self):
        self.xmpp = yield inner.sub(self.xmpp_connect())
        room = yield inner.sub(self.xmpp.muc.join(self.xmpp_room, self.bot_name))
        self.make_request(room)

        yield inner.sub(room | self.xmpp_to_log(room.nick_jid, room) | threado.dev_null())
Esempio n. 13
0
    def main(inner,self):
        conn = yield self.xmpp_connect()
        dst = yield conn.muc.join(self.room_dst, self.bot_name)
        self.log.info("Joined room %r", self.room_dst),dst

        yield generate() | events_to_elements_with_delay_element() |  dst | threado.dev_null()