GithubHelp home page GithubHelp logo

connector-slack'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-slack's People

Contributors

alexenriquent avatar jacobtomlinson avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

connector-slack's Issues

error when starting --> TypeError: object Response can't be used in 'await' expression

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

Update for v0.3.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.

Add reactions

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:

  • Reactions are implemented in 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.
  • So in the listen method of the slack connector, this new property should be filled with the timestamp of the message (m["ts"])
  • An 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)
  • In the test I made, slacker fails in 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.
  • With all changes done, this can be used from an skill:
if message.connector.name == 'slack':
    await message.connector.add_reaction(message, 'thumbsup')

What do you think?

Cannot connect to channel

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

Add attachment support

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.

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.