GithubHelp home page GithubHelp logo

connector-matrix's Introduction

Opsdroid Logo

An open source chat-ops bot framework

Current version of pypi Github CI Status codecov BCH compliance Docker Build Docker Image Size (latest by date)Docker Layers Documentation Status Matrix Chat Backers on Open Collective Sponsors on Open Collective Open Source Helpers


Quick Start β€’ Documentation β€’ Playground β€’ Blog β€’ Community


An open source chatbot framework written in Python. It is designed to be extendable, scalable and simple.

This framework is designed to take events from chat services and other sources and execute Python functions (skills) based on their contents. Those functions can be anything you like, from simple conversational responses to running complex tasks. The true power of this project is to act as a glue library to bring the multitude of natural language APIs, chat services and third-party APIs together.

See our full documentation to get started.

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! πŸ™ [Become a backer]

Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

connector-matrix's People

Contributors

almightyfuzz avatar cadair avatar jacobtomlinson avatar solardrew avatar szimszon avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

connector-matrix's Issues

Unreliable await message.respond()

Hi,

I wonder if you could help me.

I'm writing a shell skill to be able to run shell scripts. I have done this for matrix already but I like this frameworks.
My problem is that sometimes I receive

Traceback (most recent call last):
  File "/home/szimszon/.opsdroid/modules/opsdroid-modules/skill/shell/__init__.py", line 67, in do_something
    await message.respond(str(stdout))
  File "/usr/local/lib/python3.6/dist-packages/opsdroid/message.py", line 54, in respond
    await self.connector.respond(response)
  File "/home/szimszon/.opsdroid/modules/opsdroid-modules/connector/matrix/connector.py", line 163, in respond
    await self.connection.send_message(room_id, message.text)
  File "/home/szimszon/.opsdroid/modules/opsdroid-modules/connector/matrix/matrix_async.py", line 66, in _send
    async with request as response:
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/client.py", line 690, in __aenter__
    self._resp = yield from self._coro
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/client.py", line 277, in _request
    yield from resp.start(conn, read_until_eof)
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/client_reqrep.py", line 624, in start
    (message, payload) = yield from self._protocol.read()
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/streams.py", line 554, in read
    yield from self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: None

also the message is not delivered. I don't know the cause for this.
Also if I put the await message.respond() inside a try: except: and resend the message like below it seems to work.

           try:
               await message.respond(str(stdout))
            except aiohttp.client_exceptions.ServerDisconnectedError:
               logging.error("stdout: ["+str(stdout)+"]")
               import traceback
               logging.error("Error while sending: "+str(traceback.format_exc()))
               time.sleep(3)
               logging.error("== Retry ==")
               await message.respond(str(stdout))
               logging.error("== Recovered ==")

I still get an exception like below between "== Retry ==" and "== Recovered ==" but the message is delivered.

ERROR opsdroid-modules.connector.matrix.connector: Matrix Sync Error
Traceback (most recent call last):
  File "/home/szimszon/.opsdroid/modules/opsdroid-modules/connector/matrix/connector.py", line 112, in listen
    filter=self.filter_id)
  File "/home/szimszon/.opsdroid/modules/opsdroid-modules/connector/matrix/matrix_async.py", line 66, in _send
    async with request as response:
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/client.py", line 690, in __aenter__
    self._resp = yield from self._coro
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/client.py", line 277, in _request
    yield from resp.start(conn, read_until_eof)
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/client_reqrep.py", line 624, in start
    (message, payload) = yield from self._protocol.read()
  File "/usr/local/lib/python3.6/dist-packages/aiohttp/streams.py", line 554, in read
    yield from self._waiter
aiohttp.client_exceptions.ServerDisconnectedError: None

Add graceful log in failure?

Currently if the log in details for the bot are incorrect it causes opsdroid to fall over with a huge error message that is not all that clear on why it died.

Become an official connector

Hey @SolarDrew, awesome work! It's great to see you taking the time to create your own connector for opsdroid.

Would you be interested in making this an official connector by moving the repo over to the opsdroid org?

You will of course still retain control over the repo and be the primary maintainers, it would just result in the connector being listed on the opsdroid website and allow users to install it without specifying the repo url.

If you want to move it over please go into the repo settings and change the ownership to me (@jacobtomlinson), I will then move it over to opsdroid. I will ensure you have full admin control on the repo, although I think that happens by default when transferring.

Note: If you do want to make it official it will be affected by opsdroid/opsdroid#286, which I see as a good thing! But you should be aware of it if you're not already.

update disconnect method for opsdroid 0.13.0

Latest opsdroid gives the following exception when receiving a stop signal:

/home/opsdroid/.local/share/opsdroid/opsdroid-modules/connector/matrix/connector.py:201: RuntimeWarning: coroutine 'ClientSession.close' was never awaited
  self.session.close()
INFO opsdroid.core: Stopped connector ConnectorMatrix
INFO opsdroid.core: Stopping database ...
ERROR opsdroid.core: Caught exception
ERROR opsdroid.core: {'message': 'Task exception was never retrieved', 'exception': TypeError('disconnect() takes 1 positional argument but 2 were given',), 'future': <Task finished coro=<OpsDroid.handle_signal() done, defined at /usr/local/lib/python3.6/dist-packages/opsdroid/core.py:120> exception=TypeError('disconnect() takes 1 positional argument but 2 were given',)>}

Can’t shut down the bot, as disconnect needs too few parameters

When shutting down the bot (e.g. pressing Ctrl-C in the shell connector) i get this message:

ERROR opsdroid.core: {'message': 'Task exception was never retrieved', 'exception': TypeError('disconnect() takes 1 positional argument but 2 were given',), 'future': <Task finished coro=<OpsDroid.handle_signal() done, defined at /home/polesz/.local/lib/python3.6/site-packages/opsdroid/core.py:121> exception=TypeError('disconnect() takes 1 positional argument but 2 were given',)>}

Wrong password crashes the bot

If the password is wrong in the config file, the homeserver responds 403. After that, the bot crashes with this traceback:

Traceback (most recent call last):
  File "/home/polesz/bin/opsdroid", line 11, in <module>
    load_entry_point('opsdroid==0.13.0', 'console_scripts', 'opsdroid')()
  File "/home/polesz/.local/lib/python3.6/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/home/polesz/.local/lib/python3.6/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/home/polesz/.local/lib/python3.6/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/polesz/.local/lib/python3.6/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/home/polesz/.local/lib/python3.6/site-packages/opsdroid/__main__.py", line 196, in main
    opsdroid.load()
  File "/home/polesz/.local/lib/python3.6/site-packages/opsdroid/core.py", line 154, in load
    self.start_connectors(self.modules["connectors"])
  File "/home/polesz/.local/lib/python3.6/site-packages/opsdroid/core.py", line 249, in start_connectors
    self.eventloop.run_until_complete(connector.connect(self))
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 468, in run_until_complete
    return future.result()
  File "/home/polesz/.local/share/opsdroid/opsdroid-modules/connector/matrix/connector.py", line 123, in connect
    "m.login.password", user=self.mxid, password=self.password)
  File "/home/polesz/.local/share/opsdroid/site-packages/matrix_api_async/api_asyncio.py", line 67, in _send
    code=response.status, content=await response.text())
matrix_client.errors.MatrixRequestError: 403: {"errcode":"M_FORBIDDEN","error":"Invalid password"}
ERROR opsdroid.core: Caught exception
ERROR asyncio: Unhandled error in exception handler
context: {'client_session': <aiohttp.client.ClientSession object at 0x7f8dd06fdb70>, 'message': 'Unclosed client session'}
Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1302, in call_exception_handler
    self._exception_handler(self, context)
  File "/home/polesz/.local/lib/python3.6/site-packages/opsdroid/core.py", line 114, in handle_async_exception
    _LOGGER.error(_("Caught exception"))
  File "/usr/lib64/python3.6/logging/__init__.py", line 1336, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1443, in _log
    self.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1453, in handle
    self.callHandlers(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1515, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 864, in handle
    self.emit(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1070, in emit
    self.stream = self._open()
  File "/usr/lib64/python3.6/logging/__init__.py", line 1060, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
NameError: name 'open' is not defined
ERROR asyncio: Exception in default exception handler while handling an unexpected error in custom exception handler
Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1302, in call_exception_handler
    self._exception_handler(self, context)
  File "/home/polesz/.local/lib/python3.6/site-packages/opsdroid/core.py", line 114, in handle_async_exception
    _LOGGER.error(_("Caught exception"))
  File "/usr/lib64/python3.6/logging/__init__.py", line 1336, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1443, in _log
    self.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1453, in handle
    self.callHandlers(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1515, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 864, in handle
    self.emit(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1070, in emit
    self.stream = self._open()
  File "/usr/lib64/python3.6/logging/__init__.py", line 1060, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
NameError: name 'open' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1310, in call_exception_handler
    'context': context,
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1268, in default_exception_handler
    logger.error('\n'.join(log_lines), exc_info=exc_info)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1336, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1443, in _log
    self.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1453, in handle
    self.callHandlers(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1515, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 864, in handle
    self.emit(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1070, in emit
    self.stream = self._open()
  File "/usr/lib64/python3.6/logging/__init__.py", line 1060, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
NameError: name 'open' is not defined
Exception ignored in: <bound method ClientSession.__del__ of <aiohttp.client.ClientSession object at 0x7f8dd06fdb70>>
Traceback (most recent call last):
  File "/home/polesz/.local/lib/python3.6/site-packages/aiohttp/client.py", line 216, in __del__
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1318, in call_exception_handler
  File "/usr/lib64/python3.6/logging/__init__.py", line 1336, in error
  File "/usr/lib64/python3.6/logging/__init__.py", line 1443, in _log
  File "/usr/lib64/python3.6/logging/__init__.py", line 1453, in handle
  File "/usr/lib64/python3.6/logging/__init__.py", line 1515, in callHandlers
  File "/usr/lib64/python3.6/logging/__init__.py", line 864, in handle
  File "/usr/lib64/python3.6/logging/__init__.py", line 1070, in emit
  File "/usr/lib64/python3.6/logging/__init__.py", line 1060, in _open
NameError: name 'open' is not defined
ERROR opsdroid.core: Caught exception
ERROR asyncio: Unhandled error in exception handler
context: {'connector': <aiohttp.connector.TCPConnector object at 0x7f8dd26a15f8>, 'connections': ['[(<aiohttp.client_proto.ResponseHandler object at 0x7f8dcff52048>, 24691.038180863)]'], 'message': 'Unclosed connector'}
Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1302, in call_exception_handler
    self._exception_handler(self, context)
  File "/home/polesz/.local/lib/python3.6/site-packages/opsdroid/core.py", line 114, in handle_async_exception
    _LOGGER.error(_("Caught exception"))
  File "/usr/lib64/python3.6/logging/__init__.py", line 1336, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1443, in _log
    self.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1453, in handle
    self.callHandlers(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1515, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 864, in handle
    self.emit(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1070, in emit
    self.stream = self._open()
  File "/usr/lib64/python3.6/logging/__init__.py", line 1060, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
NameError: name 'open' is not defined
ERROR asyncio: Exception in default exception handler while handling an unexpected error in custom exception handler
Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1302, in call_exception_handler
    self._exception_handler(self, context)
  File "/home/polesz/.local/lib/python3.6/site-packages/opsdroid/core.py", line 114, in handle_async_exception
    _LOGGER.error(_("Caught exception"))
  File "/usr/lib64/python3.6/logging/__init__.py", line 1336, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1443, in _log
    self.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1453, in handle
    self.callHandlers(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1515, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 864, in handle
    self.emit(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1070, in emit
    self.stream = self._open()
  File "/usr/lib64/python3.6/logging/__init__.py", line 1060, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
NameError: name 'open' is not defined

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1310, in call_exception_handler
    'context': context,
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1268, in default_exception_handler
    logger.error('\n'.join(log_lines), exc_info=exc_info)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1336, in error
    self._log(ERROR, msg, args, **kwargs)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1443, in _log
    self.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1453, in handle
    self.callHandlers(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1515, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 864, in handle
    self.emit(record)
  File "/usr/lib64/python3.6/logging/__init__.py", line 1070, in emit
    self.stream = self._open()
  File "/usr/lib64/python3.6/logging/__init__.py", line 1060, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding)
NameError: name 'open' is not defined
Exception ignored in: <bound method BaseConnector.__del__ of <aiohttp.connector.TCPConnector object at 0x7f8dd26a15f8>>
Traceback (most recent call last):
  File "/home/polesz/.local/lib/python3.6/site-packages/aiohttp/connector.py", line 227, in __del__
  File "/usr/lib64/python3.6/asyncio/base_events.py", line 1318, in call_exception_handler
  File "/usr/lib64/python3.6/logging/__init__.py", line 1336, in error
  File "/usr/lib64/python3.6/logging/__init__.py", line 1443, in _log
  File "/usr/lib64/python3.6/logging/__init__.py", line 1453, in handle
  File "/usr/lib64/python3.6/logging/__init__.py", line 1515, in callHandlers
  File "/usr/lib64/python3.6/logging/__init__.py", line 864, in handle
  File "/usr/lib64/python3.6/logging/__init__.py", line 1070, in emit
  File "/usr/lib64/python3.6/logging/__init__.py", line 1060, in _open
NameError: name 'open' is not defined

My opsdroid is v0.13.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.