opsdroid / connector-slack Goto Github PK
View Code? Open in Web Editor NEW๐ก A slack connector for opsdroid
License: Apache License 2.0
๐ก A slack connector for opsdroid
License: Apache License 2.0
v0.3.0 has a breaking change which requires connectors and databases to inherit from a base class in order to be used.
Therefore this module will no longer work until this is updated.
It also demonstrates that opsdroid needs some kind of versioning system for modules.
It would be nice to be able to use the attachments feature in Slack messages to format the message.
Link to code in Slacker for reference
Link to Slack API for reference
One bug I ran into when just forking the connector is that the current Message class doesn't support passing an extra argument, like attachments, to the respond()
method and there's not currently a message attribute that looks like it could be used for that.
You can specify a message as the reply to another message by setting thread_ts
to the timestamp of the original message.
https://api.slack.com/methods/chat.postMessage
This would fix thread replies being posted in the main room.
Reactions are a nice feature of slack, and would be great to add the capability to opsdroid slack connector to react to messages.
I investigated a lite and to archive this, we need to do some changes:
slacker
. But in order to react to a message, you need the channel and the exact timestamp of the message. Actually, opsdroid Message
class don't save the message origin timestamp. So a ts
property should be created, or created
property should be used for this prupose.listen
method of the slack connector, this new property should be filled with the timestamp of the message (m["ts"]
)add_reaction
method should be implemented in the slack connector, with something like: async def add_reaction(self, message, reaction):
""" Respond with a message """
_LOGGER.debug("Adding reaction '"+reaction+"' with: '" + message.text +
"' in room " + message.room)
await self.sc.reactions.add(
reaction, channel=message.room, timestamp=message.ts)
Reactions.add
when using channel and timestamp. To resolve it, I removed file and file_comment from the post call. We should try it again and if it fails as I saw, open an issue in slacker.if message.connector.name == 'slack':
await message.connector.add_reaction(message, 'thumbsup')
What do you think?
slacker-asyncio it's the main dependency and seems abandoned.
The last commit is from May'16.
See this issue: gfreezy/slacker-asyncio#7
I configured the bot with api-token and etc. But when the bot starts, it gets an error as follows:
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953748>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953710>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953748>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x1119537f0>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953710>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953828>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953860>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953898>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953780>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x1119538d0>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x1119539b0>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953780>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953a58>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x1119537b8>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953978>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953ac8>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953b38>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953978>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953b00>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953b70>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953ba8>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953be0>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953c18>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953c50>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953c88>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953908>
ERROR asyncio: Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x111953cc0>
INFO opsdroid.connector.slack: Connecting to Slack
Traceback (most recent call last):
File "./.env/bin/opsdroid", line 11, in <module>
sys.exit(main())
File "/Users/marcelopires/Desktop/chat-ops/opsdroid/.env/lib/python3.6/site-packages/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/marcelopires/Desktop/chat-ops/opsdroid/.env/lib/python3.6/site-packages/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/marcelopires/Desktop/chat-ops/opsdroid/.env/lib/python3.6/site-packages/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/marcelopires/Desktop/chat-ops/opsdroid/.env/lib/python3.6/site-packages/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/marcelopires/Desktop/chat-ops/opsdroid/.env/lib/python3.6/site-packages/opsdroid/__main__.py", line 192, in main
opsdroid.start_loop()
File "/Users/marcelopires/Desktop/chat-ops/opsdroid/.env/lib/python3.6/site-packages/opsdroid/core.py", line 137, in start_loop
self.start_connector_tasks(connectors)
File "/Users/marcelopires/Desktop/chat-ops/opsdroid/.env/lib/python3.6/site-packages/opsdroid/core.py", line 183, in start_connector_tasks
self.eventloop.run_until_complete(connector.connect(self))
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 466, in run_until_complete
return future.result()
File "/Users/marcelopires/Desktop/chat-ops/opsdroid/.env/lib/python3.6/site-packages/opsdroid/connector/slack/__init__.py", line 48, in connect
connection = await self.slacker.rtm.start()
File "/Users/marcelopires/Desktop/chat-ops/opsdroid/.env/lib/python3.6/site-packages/aioslacker/__init__.py", line 48, in __request
method = self.methods[method]
KeyError: <bound method BaseAPI._session_get of <aioslacker.RTM object at 0x111953748>>
Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=True debug=False>>
Traceback (most recent call last):
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/base_events.py", line 511, in __del__
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/unix_events.py", line 65, in close
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/asyncio/unix_events.py", line 146, in remove_signal_handler
File "/usr/local/Cellar/python3/3.6.1/Frameworks/Python.framework/Versions/3.6/lib/python3.6/signal.py", line 47, in signal
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object
If the websocket connection disconnects it doesn't reconnect.
INFO opsdroid-modules.connector.slack: Connecting to Slack
Traceback (most recent call last):
File "/root/.opsdroid/modules/opsdroid-modules/connector/slack/__init__.py", line 46, in connect
connection = await self.sc.rtm.start()
TypeError: object Response can't be used in 'await' expression
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/opsdroid", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/opsdroid/__main__.py", line 130, in main
opsdroid.start_loop()
File "/usr/local/lib/python3.5/dist-packages/opsdroid/core.py", line 142, in start_loop
self.start_connector_tasks(connectors)
File "/usr/local/lib/python3.5/dist-packages/opsdroid/core.py", line 190, in start_connector_tasks
self.eventloop.run_until_complete(connector.connect(self))
File "/usr/lib/python3.5/asyncio/base_events.py", line 387, in run_until_complete
return future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/root/.opsdroid/modules/opsdroid-modules/connector/slack/__init__.py", line 57, in connect
except aiohttp.errors.ClientOSError as e:
AttributeError: module 'aiohttp' has no attribute 'errors'
Exception ignored in: <bound method BaseEventLoop.__del__ of <_UnixSelectorEventLoop running=False closed=True debug=False>>
Traceback (most recent call last):
File "/usr/lib/python3.5/asyncio/base_events.py", line 431, in __del__
File "/usr/lib/python3.5/asyncio/unix_events.py", line 58, in close
File "/usr/lib/python3.5/asyncio/unix_events.py", line 139, in remove_signal_handler
File "/usr/lib/python3.5/signal.py", line 47, in signal
TypeError: signal handler must be signal.SIG_IGN, signal.SIG_DFL, or a callable object
Hi,
How can i set permissions to skills, To allow User A to use specific skill and not allow User B ?
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.