opsdroid / connector-matrix Goto Github PK
View Code? Open in Web Editor NEWπ‘ A Matrix connector for opsdroid
License: Apache License 2.0
π‘ A Matrix connector for opsdroid
License: Apache License 2.0
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
If your bot is posting github events or just general sillyness into your channel you might just want it to send all events as m.notice
so it dosen't notify everyone.
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.
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',)>}
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.
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',)>}
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
It would probably be nice if we could auto-html markdown now we can send HTML messages.
Could be nice if it was in multiple rooms?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.