Exemplo n.º 1
0
 def test_poll(self):
     m = getUpdates()
     m.timeout = 10
     m.limit = 100
     #m.offset = 585177182
     resp = self._tgclient.post(m)
     print(resp)
Exemplo n.º 2
0
 def test_poll(self):
     m = getUpdates()
     m.timeout = 10
     m.limit = 100
     #m.offset = 585177182
     resp = self._tgclient.post(m)
     print(resp)
    def test_poll(self):
        m = getUpdates()
        m.timeout = 5
        m.limit = 5
        updates = self._client.send_method(m)

        for update in updates:
            print(update)
Exemplo n.º 4
0
    def test_poll(self):
        m = getUpdates()
        m.timeout = 5
        m.limit = 5
        updates = yield from self._client.send_method(m)

        for update in updates:
            print(update)
Exemplo n.º 5
0
    def test_poll(self):
        m = getUpdates()
        m.timeout = 5
        m.limit = 5
        #m.offset = 585177182
        updates, update_id = self._client.post(m)

        print "Latest offset: %s" % update_id
        for update in updates:
            print update
Exemplo n.º 6
0
 def _poll_updates_thread(self):
     m = getUpdates()
     m.timeout = self._timeout
     m.limit = self._limit
     if self._offset is not None:
         m.offset = self._offset
     try:
         updates = self._client.send_method(m)
         reactor.callFromThread(self._handle_updates, updates)
     except Exception as e:
         reactor.callFromThread(self._handle_updates_error, e)
Exemplo n.º 7
0
 def _poll_updates(self):
     m = getUpdates()
     m.timeout = self._poll_timeout
     m.limit = self._limit
     if self._offset is not None:
         m.offset = self._offset
     try:
         updates = yield self.send_method(m)
         reactor.callFromThread(self._handle_updates_result,
                                updates)  # @UndefinedVariable
     except Exception as e:
         self._handle_updates_error(e)
Exemplo n.º 8
0
    def run(self):
        for plugin in self._plugins:
            yield from plugin.startPlugin()

        try:
            while True:
                method = getUpdates()
                method.offset = self._update_id
                method.timeout = 30
                updates = yield from self._client.send_method(method)

                for update in updates:
                    yield from self._on_update(update)
                    self._update_id = update.update_id + 1
                # if not len(updates):
                #     yield from asyncio.sleep(10)

        except KeyboardInterrupt:
            log.info('Stopping ...')

        for plugin in self._plugins:
            yield from plugin.stopPlugin()