GithubHelp home page GithubHelp logo

slackapi / python-rtmbot Goto Github PK

View Code? Open in Web Editor NEW
680.0 129.0 258.0 210 KB

A framework for receiving and interacting with events from Slack's RTM API

Home Page: https://api.slack.com/rtm

License: MIT License

Python 100.00%

python-rtmbot's Introduction

python-rtmbot

This project is no longer under active development. If you’re just getting started, we recommend taking a look at the Python SDK first. If you’ve been using this project, only critical issues (such as security issues) will be addressed, but we advise planning to migrate to the Python SDK. You can still file an issue and ask us for help doing that!

πŸ’‘ If you’re interested in maintaining this package in the future, please get in touch

Build Status Coverage Status

A Slack bot written in Python that connects via the RTM API.

Python-rtmbot is a bot engine. The plugins architecture should be familiar to anyone with knowledge of the Slack API and Python. The configuration file format is YAML.

This project is currently pre-1.0. As such, you should plan for it to have breaking changes from time to time. For any breaking changes, we will bump the minor version while we are pre-1.0. (e.g. 0.2.4 -> 0.3.0 implies breaking changes). If stability is important, you'll likely want to lock in a specific minor version)

Some differences to webhooks:

  1. Doesn't require a webserver to receive messages
  2. Can respond to direct messages from users
  3. Logs in as a slack user (or bot)
  4. Bot users must be invited to a channel

Dependencies

Installation

  1. Create your project
        mkdir myproject
        cd myproject
  1. Install rtmbot (ideally into a virtualenv)
        pip install rtmbot
  1. Create an rtmbot.conf file and create a bot for your team
        # Add the following to rtmbot.conf
        DEBUG: True # make this False in production
        SLACK_TOKEN: "xoxb-11111111111-222222222222222"
        ACTIVE_PLUGINS:
            - plugins.repeat.RepeatPlugin

DEBUG will adjust logging verbosity and cause the runner to exit on exceptions, generally making debugging more pleasant.

SLACK_TOKEN is needed to authenticate with your Slack team.

ACTIVE_PLUGINS RTMBot will attempt to import any Plugin specified in ACTIVE_PLUGINS (relative to your python path) and instantiate them as plugins. These specified classes should inherit from the core Plugin class.

For example, if your python path includes '/path/to/myproject' and you include plugins.repeat.RepeatPlugin in ACTIVE_PLUGINS, it will find the RepeatPlugin class within /path/to/myproject/plugins/repeat.py and instantiate it, then attach it to your running RTMBot.

A Word on Structure

To give you a quick sense of how this library is structured, there is a RtmBot class which does the setup and handles input and outputs of messages. It will also search for and register Plugins within the specified directory(ies). These Plugins handle different message types with various methods and can also register periodic Jobs which will be executed by the Plugins.

RtmBot
β”œβ”€β”€ Plugin
|      β”œβ”€β”€ Job
|      └── Job
β”œβ”€β”€ Plugin
└── Plugin
       └── Job

Add Plugins

Plugins can live within any python module, but we recommend just putting them in ./plugins. (Don't forget to add an __init__.py file to your directory to make it a module -- use touch __init__.py within your plugin directory to create one)

To add a plugin, create a file within your plugin directory (./plugins is a good place for it).

    mkdir plugins
    touch plugins/__init__.py
    cd plugins
    vi myplugin.py

Add your plugin content into this file. Here's an example that will just print all of the requests it receives to the console. See below for more information on available methods.

    from __future__ import print_function
    from rtmbot.core import Plugin

    class MyPlugin(Plugin):

        def catch_all(self, data):
            print(data)

You can install as many plugins as you like, and each will handle every event received by the bot independently.

To create an example 'repeat' plugin:

Open plugins/repeat.py

Add the following:

    from __future__ import print_function
    from __future__ import unicode_literals

    from rtmbot.core import Plugin


    class RepeatPlugin(Plugin):

        def process_message(self, data):
            if data['channel'].startswith("D"):
                self.outputs.append(
                    [data['channel'], 'from repeat1 "{}" in channel {}'.format(
                        data['text'], data['channel']
                    )]
                )

The repeat plugin will now be loaded by the bot on startup. Run rtmbot from console to start your RtmBot.

    rtmbot

Create Plugins

Incoming data

All events from the RTM websocket are sent to the registered plugins. To act on an event, create a function definition, inside your Plugin class, called process_(api_method) that accepts a single arg for data. For example, to handle incoming messages:

    def process_message(self, data):
        print data

This will print the incoming message json (dict) to the screen where the bot is running.

Plugins having a method defined as catch_all(self, data) will receive ALL events from the websocket. This is useful for learning the names of events and debugging.

For a list of all possible API Methods, look here: https://api.slack.com/rtm

Note: If you're using Python 2.x, the incoming data should be a unicode string, be careful you don't coerce it into a normal str object as it will cause errors on output. You can add from __future__ import unicode_literals to your plugin file to avoid this.

Outgoing data

RTM Output

Plugins can send messages back to any channel or direct message. This is done by appending a two item array to the Plugin's output array (myPluginInstance.output). The first item in the array is the channel or DM ID and the second is the message text. Example that writes "hello world" when the plugin is started:

    class myPlugin(Plugin):

        def process_message(self, data):
            self.outputs.append(["C12345667", "hello world"])
SlackClient Web API Output

Plugins also have access to the connected SlackClient instance for more complex output (or to fetch data you may need).

    def process_message(self, data):
        self.slack_client.api_call(
            "chat.postMessage", channel="#general", text="Hello from Python! :tada:",
            username="pybot", icon_emoji=":robot_face:"

Timed jobs

Plugins can also run methods on a schedule. This allows a plugin to poll for updates or perform housekeeping during its lifetime. Jobs define a run() method and return any outputs to be sent to channels. They also have access to a SlackClient instance that allows them to make calls to the Slack Web API.

For example, this will print "hello world" every 10 seconds. You can output multiple messages to the same or different channels by passing multiple pairs of [Channel, Message] combos.

    from rtmbot.core import Plugin, Job


    class myJob(Job):

        def run(self, slack_client):
            return [["C12345667", "hello world"]]


    class myPlugin(Plugin):

        def register_jobs(self):
            job = myJob(10)
            self.jobs.append(job)

Plugin misc

The data within a plugin persists for the life of the rtmbot process. If you need persistent data, you should use something like sqlite or the python pickle libraries.

python-rtmbot's People

Contributors

abenbecker avatar aerickson avatar aoberoi avatar eyalev avatar finnito avatar gavinsherry avatar jammons avatar jiujitsu avatar jyap808 avatar kenden avatar kjschiroo avatar mattskone avatar philipyun avatar rawdigits avatar roach avatar schlueter avatar smalakys avatar theist avatar tklauser avatar tzakrajs avatar yasumoto avatar youknowone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-rtmbot's Issues

Set bot to respond only to the ambient event

  • [V ] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [V ] I've read and agree to the Code of Conduct.
  • [V ] I've searched for any related issues and avoided creating a duplicate issue.

Description

Trying to launch bot in ambient mode

Reproducible in:

  • [V ] This is reproducible in the sample project.
    RTMBot version: 0.4.0
    Python version: 3.6.3
    OS Version: 10.13.1

Expected result:

I'm trying to launch the bot in a way that will allow interacting with him in a specific channel only, responding to every message in said channel.

Actual result:

Right now the bot responds to direct messages and mentions, which is something we would like to achieve.

I saw similar functionality to what I'm seeking in this bot's readme - https://github.com/saviogl/slack-rtm-bot, wondering if it's possible with python-rtmbot.
Thanks!

Enable python-rtmbot to work from behind a Proxy.

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Description

I want to deploy my slack bot from behind a personal proxy but I suppose this cannot be done since proxy requires authentication
I couldn't find any documentation to run the slack bot from behind a proxy.
Appreciate if you guys can help fix this.

Reproducible in:

  • This is reproducible in the sample project.
    RTMBot version: Latest
    Python version: 2.7
    OS Version: Any

Bot does not work upon invitiation to new channel or private group

Description:

After inviting a bot to a channel or private group, the bot does not respond in the channel. After restarting the bot process, the bot correctly responds in the channel/group.

Date Seen:

07 October 2015

Bot Version:

The bot I run is based on https://github.com/slackhq/python-rtmbot from 22fb111. I forked the repo here: https://github.com/mac-reid/python-rtmbot

Running on Python 2.7.6 with the following modules (in virtualenv):
backports.ssl-match-hostname (3.4.0.2)
docutils (0.12)
google-api-python-client (1.4.2)
httplib2 (0.9.2)
lockfile (0.10.2)
oauth2client (1.5.1)
pip (7.1.2)
pyasn1 (0.1.9)
pyasn1-modules (0.0.8)
python-daemon (2.0.6)
PyYAML (3.11)
requests (2.7.0)
rsa (3.2)
setuptools (18.2)
simplejson (3.8.0)
six (1.9.0)
slackclient (0.16)
uritemplate (0.6)
websocket-client (0.32.0)
wheel (0.24.0)

Severity:

Trivial

Steps to reproduce:

  1. Make a new channel or private group
  2. /invite @botName
  3. type message to trigger bot

Actual Behavior:

Start the bot and connect to slack. The bot shows user presence. Create a new channel/group and invite the bot. Type a message to trigger the bot (such as @botName: help). The bot receives the message but fails to respond on the new channel.

Expected Behavior:

Start the bot and connect to slack. The bot shows user presence. Create a new channel/group and invite the bot. Type a message to trigger the bot (such as @botName: help). The bot receives the message and responds on the new channel.

Testing Steps:

When the bot is added to the new channel and receives a message, the output to send is added to the channel, but the rtmbot never actually gets to sending the message on the channel.

Workaround:

Restart the bot each time it is added to a new channel.

Doesn't response

Hello!
I've copied the todo example bot as stated in the readme, but it doesn't work... The bot is online, though. Does it need an input/output webhook or something like that? Because the script and everything is running

What is the development status of this project?

Hello, does Slack plan to continue development?

I need to extend the functionality and would like to know whether I should:

  1. not change rtmbot code because a major revision is coming, which would potentially make my upgrade path difficult.
  2. make my changes such that that they could be considered as pull requests here.

I have been trying hard to do 1, but my own code is getting more twisted trying to not modify RTMBot itself. I would be happy to do 2, but that's a lot more work, so if no further work is planned here anyway, I would more save time and just fork this project internally.

Thanks!

docker container for python-rtmbot?

Is there a minimal docker container available for python-rtmbot, which would simply require a user to pop some bot scripts into a specified location in order to construct an easy to deploy image containing them?

Question on the structure

Hi,

Thanks for creating this project for us to reference on.

Correct me if I'm wrong, it seems like the bot would have to go through all the plugins, all the outputs, find the output with some values in it and then only the bot will send out the value to the channel.

Just wondering if there is a reason behind this structure, is it possible we only call the plugin when we need it and not go through every single one of them for every message the bot receive?

Thanks!
Zhiquan

Implement flood protection?

I'm wanting to implement flood protection in to my bot to prevent abuse by users as well as keep the bot from spamming the channels.

Use case:

The bot will say hi when a user's presence changes to active. However, the presence event fires for each channel the user is in, making the bot say hi for each channel, which is not ideal. I could implement a simple counter I suppose, but I'm wondering if there are any plans for anti-flood before I give it a shot. Or, maybe there's something already in place I'm not aware of.

In the case of an error path, `cls` may be undefined on line 155 of core.py

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Description

When running using Python 3.6, I get the following error:

Traceback (most recent call last):
  File "/usr/local/bin/rtmbot", line 11, in <module>
    load_entry_point('rtmbot==0.4.0', 'console_scripts', 'rtmbot')()
  File "/usr/local/lib/python3.6/site-packages/rtmbot/bin/run_rtmbot.py", line 31, in main
    bot.start()
  File "/usr/local/lib/python3.6/site-packages/rtmbot/core.py", line 99, in start
    self._start()
  File "/usr/local/lib/python3.6/site-packages/rtmbot/core.py", line 74, in _start
    self.load_plugins()
  File "/usr/local/lib/python3.6/site-packages/rtmbot/core.py", line 155, in load_plugins
    plugin_config = self.config.get(cls.__name__, {})
UnboundLocalError: local variable 'cls' referenced before assignment

Reproducible in:

  • This is reproducible in the sample project.
    RTMBot version: 0.4.0
    Python version: 3.6.0
    OS Version: Debian Stretch (running RTMBot in python:3.6 docker container)

Steps to reproduce:

  1. docker run -it python:3.6 bash
  2. pip install rtmbot
  3. add a testing rtmbot.conf file
  4. run rtmbot

Expected result:

I expected that the bot would run. (well, when real bot code was in the container...)

Actual result:

The following error happened:

root@2dc3d0e0a668:/# rtmbot
Traceback (most recent call last):
  File "/usr/local/bin/rtmbot", line 11, in <module>
    load_entry_point('rtmbot==0.4.0', 'console_scripts', 'rtmbot')()
  File "/usr/local/lib/python3.6/site-packages/rtmbot/bin/run_rtmbot.py", line 31, in main
    bot.start()
  File "/usr/local/lib/python3.6/site-packages/rtmbot/core.py", line 99, in start
    self._start()
  File "/usr/local/lib/python3.6/site-packages/rtmbot/core.py", line 74, in _start
    self.load_plugins()
  File "/usr/local/lib/python3.6/site-packages/rtmbot/core.py", line 155, in load_plugins
    plugin_config = self.config.get(cls.__name__, {})
UnboundLocalError: local variable 'cls' referenced before assignment

Log Rotation for rtm-bot

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Description

Please implement a way to configure daily / hourly log rotation for logging data.

Reproducible in:

  • This is reproducible in the sample project.
    RTMBot version: latest
    Python version: 2.7
    OS Version: MacOS High Sierra

Steps to reproduce:

Not Applicable

Expected result:

Should be able to automatically create log files and rename the old log file accordingly.
Example Old log file format: rtmbot.log.2018.04.17

Actual result:

Functionality not available as of now.

rtmbot does not handle websocket disconnections (incl team_migration_starting)

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Description

As per https://api.slack.com/events/team_migration_started, when this event occurs all websockets will be closed. This causes an exception inside rtm_read(), which is not handled by _start(), start(), or main(), meaning that the rtmbot will exit with an unhandled exception.

Ideally the bot should catch such exceptions and react accordingly, eg. by reconnecting and then continuing to process rtm events.

Reproducible in:

  • This is reproducible in the sample project.
    RTMBot version:
    Python version:
    OS Version:

Steps to reproduce:

I haven't actually done this in rtmbot, but I have seen it in extremely similar code.

  1. Start rtmbot
  2. Verify that it is processing rtm events
  3. Use a utility like tcpkill to reset the rtm websocket connection (use netstat to find the connection)

Expected result:

rtmbot reconnects and continues

Actual result:

rtmbot exits with an unhandled exception

Attachments:

e.g. Logs, screenshots, screencast, sample project, funny gif, etc.

crontable

I can't find any documentation on crontable.append used by one of the plugins (counter.py)....I'd like to use the counter.py to post the time every hour on the hour but I'm not familiar with how to do this using the crontable.

I modified counter.py to use the python scheduler (2.7) but it's not working... for some reason, the rtmbot script doesn't seem to recognize it, I don't get any error but it's not posting the time.


crontable.append([5,"say_time"])

def say_time():
#NOTE: you must add a real channel ID for this to work

outputs.append(["D12345678", time.time()])

Here's my code :

import schedule
import time
outputs = []

def say_time():
outputs.append(["D12345678", time.ctime()])

schedule.every(2).minutes.do(say_time)

while True:
schedule.run_pending()

time.sleep(1)

rtm_send_message not documented correctly

The readme says I should be able to pass a dict to slackclient.rtm_send_message but the source has 2 positional arguments.

It also doesnt look like it can recognize anything but the ID of the channel itself

tests!

Need tests dude, please add some.

Open IM to Direct Message a User

How do we direct message a user from their user ID ?

API says to open an IM with them and send the message to the Direct Message channel.

Is there any support for this method?

RFC: Python 2.7 Support Timeline

Why are we doing this?
Python 2.7 will reach it’s official β€˜end of life’ (EOL) on December 31st, 2019. This means that it will no longer be supported by its maintainers. Accordingly, we will retire python-rtmbot support for Python 2.7.

β€œPython 2.x is legacy, Python 3.x is the present and future of the language.β€œ

How will this change the project?
All new python-rtmbot features and bug fixes will continue to be supported in Python 2.7 until Dec 31st, 2019.

After January 1, 2020 we’ll be creating a new version of the python-rtmbot. This version will remove any Python 2.x specific code. We’ll also immediately stop fixing any bugs and security vulnerabilities that are specific to this older version.

We’d love your feedback!
Please let us know what you think by commenting on this issue. We’d love feedback on this timeline; does it work for you?

b' in slack channel

Hello,

My bot is displaying all messages as follows:

devopsbotBOT [10:33 AM]
b'drew: Hello.'

How can i remove the b' from this?

Thanks,
Drew

Allow Advanced Logging Configuration

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Description

Currently, all logging is done to the file specified by LOGFILE, which is configurable. It would be useful to allow more advanced logging configurations via python logging configuration files, as shown here in the python documentation.

Reproducible in:

  • This is reproducible in the sample project.
    RTMBot version: 0.4.0
    Python version: 2.7.11
    OS Version: All

How to open multiple rtmbots on the server?

Well, I am trying to have a server that have multiple rtmbots. Each one will have it's own websocket that connects to one team/client.
However in the main loop, I see that you can only open one websocket to the client specified in the .conf token.
Is there a way to open multiple RTM connection dynamically at runtime?

Problems with importing plugins

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Description

Something causes problems in importing plugins from the bot's directory. Since the pip install installs plugins/repeat.py in Python's library directory, it overrides the one in the bot's directory.

My custom plugins are in /opt/rtmbot/plugins. I set the BASE_PATH to /opt/rtmbot, but that didn't help.

I tried installing in a virtualenv and with the system Python. System Python seems to work better for some reason.

I added a debug print of sys.path before the module loading code.

This is from the system Python install:

['/usr/local/bin',
 '/usr/lib/python36.zip',
 '/usr/lib/python3.6',
 '/usr/lib/python3.6/lib-dynload',
 '/usr/local/lib/python3.6/dist-packages',
 '/usr/lib/python3/dist-packages',
 '/opt/rtmbot']

And this is from the virtualenv:

['/opt/rtmbot/venv/bin',
 '/opt/rtmbot/venv/lib/python36.zip',
 '/opt/rtmbot/venv/lib/python3.6',
 '/opt/rtmbot/venv/lib/python3.6/lib-dynload',
 '/usr/lib/python3.6',
 '/opt/rtmbot/venv/lib/python3.6/site-packages',
 '/opt/rtmbot']

If I change /opt/rtmbot/plugins to /opt/rtmbot/more-plugins, for example, I can get the plugin to load.

Reproducible in:

  • This is reproducible in the sample project.
    RTMBot version: 0.4.1
    Python version: 3.6.6
    OS Version: Ubuntu 18.04

Expected result:

No import errors.

Actual result:

Rtmbot fails to start due to not finding my plugins.

Attachments:

The actual error:

Traceback (most recent call last):
  File "/opt/rtmbot/venv/bin/rtmbot", line 11, in <module>
    sys.exit(main())
  File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/bin/run_rtmbot.py", line 31, in main
    bot.start()
  File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/core.py", line 100, in start
    self._start()
  File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/core.py", line 75, in _start
    self.load_plugins()
  File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/core.py", line 160, in load_plugins
    cls = import_string(plugin_path)
  File "/opt/rtmbot/venv/lib/python3.6/site-packages/rtmbot/utils/module_loading.py", line 17, in import_string
    module = import_module(module_path)
  File "/opt/rtmbot/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'plugins.cve'

Cannot listen to message events in channels

Hi,

I have a channel #test in my slack account. While rtmbot is running, even if message some text to #test, rtmbot does not show that as a event. It reports if the message is starred/ unstarred.

To further investigate, I opened a web socket and tried seeing if I am receiving any data when I post to #test, but I dont get that.

Can you tell me if there is any thing that I can look into ?

Multiple teams on a single machine

I tried rtm_connect for multiple teams on the same machine. somehow, only one teams gets started. Is it somekind of limit per machine?

References to CODE_OF_CONDUCT.md in .github directory

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Description

On https://github.com/slackhq/python-rtmbot/blob/master/.github/CONTRIBUTING.md in the Before Contributing section, there is a link to CODE_OF_CONDUCT.md:

Before contributing, please read our Code of Conduct. We take it very seriously, and expect that you will as well.

The actual link goes to this URL:
https://github.com/slackhq/python-rtmbot/blob/master/.github/CODE_OF_CONDUCT.md

However, it appears that this file has been moved to the top level of the project:
https://github.com/slackhq/python-rtmbot/blob/master/CODE_OF_CONDUCT.md

I'm not sure whether the file should be moved back into the .github directory, or if the links in the CONTRIBUTING.md and issue/PR templates need to be updated, so I just opened an issue instead.

Can't create a plugin

Hi everyone!
I have the bot working correctly but I don't know how to create a plugin. I have followed the instructions to create the console print plugin but this not works.
Anyone can tell me how to create a plugin for rtmbot?
Thank you!

interaction with OH rules?

would it be possible to have rtmbot interact with OH rules to post content out to slack based on triggers in OH instead of requests from slack users?

ie -- I'd like to create a rule to post perimeter security exceptions (doors/windows opening and motion) to slack. Other irregular events such as thermostat temp/mode changes, presence, usage stats, and alarms would all be nice to post in my family slack stream

Can't start rtmbot in bash on ubuntu on windows with virtualenv

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Description

Can't start rtmbot.py in bash on ubuntu on windows using virtualenv and any python version.

Reproducible in:

  • This is reproducible in the sample project.
    RTMBot version: git
    Python version: 3.4.3/2.7.6
    OS Version: Windows 10 Version 1607 (OS Build 14393.321)

Steps to reproduce:

  1. Create a new virtualenv on windows 10 using bash on ubuntu on windows
  2. Activate session
  3. Follow instructions on github website
  4. Try to start rtmbot.py using: ./rtmbot.py or python rtmbot.py

Expected result:

rtmbot to start

Actual result:

Error message comes up. See below. (Tested on 2 different computers with same result and error)

Attachments:

Traceback (most recent call last): File "rtmbot.py", line 26, in <module> bot.start() File "/home/xxx/git/python-rtmbot/rtmbot/core.py", line 78, in start self._start() File "/home/xxx/git/python-rtmbot/rtmbot/core.py", line 65, in _start for reply in self.slack_client.rtm_read(): File "/home/xxx/virtualenv/slack-environment/local/lib/python2.7/site-packages/slackclient/_client.py", line 120, in rtm_read json_data = self.server.websocket_safe_read() File "/home/xxx/virtualenv/slack-environment/local/lib/python2.7/site-packages/slackclient/_server.py", line 138, in websocket_safe_read data += "{0}\n".format(self.websocket.recv()) AttributeError: 'NoneType' object has no attribute 'recv'

Traceback (most recent call last): File "./rtmbot.py", line 26, in <module> bot.start() File "/home/xxx/bottest/python-rtmbot/rtmbot/core.py", line 78, in start self._start() File "/home/xxx/bottest/python-rtmbot/rtmbot/core.py", line 65, in _start for reply in self.slack_client.rtm_read(): File "/home/xxx/virtualenv/slack-bot/lib/python3.4/site-packages/slackclient/_client.py", line 120, in rtm_read json_data = self.server.websocket_safe_read() File "/home/xxx/virtualenv/slack-bot/lib/python3.4/site-packages/slackclient/_server.py", line 138, in websocket_safe_read data += "{0}\n".format(self.websocket.recv()) AttributeError: 'NoneType' object has no attribute 'recv'

URL not detected by slack

When I do

outputs.append([data['channel'], '<http://www.google.com|Google>']

The URL is not detected by Slack.

Add ability to send the "typing" event in the outcomes array.

Right now, we can send DM messages back to the user.

But, it would be nice to be able post a "typing" event (indicating that the bot is typing). This gives users comfort, particularly when processing the message might take a little while.

The event structure (from the Slack API docs):

{
"id": 1,
"type": "typing",
"channel": "C024BE91L"
}

So, similar to sending a DM, but just a different JSON structure needs to be sent.

Random exception thrown

After running for an unkown number of hours this exception was thrown, any insight?

Traceback (most recent call last):
  File "./rtmbot.py", line 24, in <module>
    bot.start()
  File "/Users/jemarjones/Documents/Projects/MarsBot/rtmbot/core.py", line 78, in start
    self._start()
  File "/Users/jemarjones/Documents/Projects/MarsBot/rtmbot/core.py", line 65, in _start
    for reply in self.slack_client.rtm_read():
  File "/usr/local/lib/python2.7/site-packages/slackclient/_client.py", line 39, in rtm_read
    json_data = self.server.websocket_safe_read()
  File "/usr/local/lib/python2.7/site-packages/slackclient/_server.py", line 110, in websocket_safe_read
    data += "{0}\n".format(self.websocket.recv())
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 298, in recv
    opcode, data = self.recv_data()
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 315, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 328, in recv_data_frame
    frame = self.recv_frame()
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 360, in recv_frame
    return self.frame_buffer.recv_frame()
  File "/usr/local/lib/python2.7/site-packages/websocket/_abnf.py", line 312, in recv_frame
    self.recv_header()
  File "/usr/local/lib/python2.7/site-packages/websocket/_abnf.py", line 261, in recv_header
    header = self.recv_strict(2)
  File "/usr/local/lib/python2.7/site-packages/websocket/_abnf.py", line 346, in recv_strict
    bytes = self.recv(min(16384, shortage))
  File "/usr/local/lib/python2.7/site-packages/websocket/_core.py", line 429, in _recv
    return recv(self.sock, bufsize)
  File "/usr/local/lib/python2.7/site-packages/websocket/_socket.py", line 77, in recv
    bytes = sock.recv(bufsize)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 734, in recv
    return self.read(buflen)
  File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 621, in read
    v = self._sslobj.read(len or 1024)
socket.error: [Errno 60] Operation timed out

Bot is disconnecting when copying large files in plugin

Hi,

I have a plugin that is executing various commands when entered in the bot channel.
Especially in my plugin I need to copy using shutil a large amount of date (it could take several minutes).
And in this case the bot is sometimes disconnecting . I there a way to manage this in a asynchronous ways , without perturbing the bot behavior ?

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.