scrapinghub / slackbot

A chat bot for Slack (https://slack.com).
MIT License
1.26k stars 394 forks source link

Add bot-initiated messaging ability #95

Open csaftoiu opened 8 years ago

csaftoiu commented 8 years ago

The approach is to use an idle handler, which gets called whenever something else hasn't already happened, or once per second. This should help reduce rate limiting.

Functional testing has been added.

Updated README.md with how to use the new functionality.

Resolves #92.

Dev Notes

To allow the idle handler to send messages, I give it the instance of the SlackClient as a parameter.

To make SlackClient easier to use, I made send_message, rtm_send_message, and upload_file all take a "channelish" string, instead of a channel. This turns a string into a channel as follows:

This way a user can just client.send_message("some_user", "Here the message") instead of having to call any other helper functions.

csaftoiu commented 8 years ago

Oh boy, didn't see #89 and #54 already. Hmm well I'll leave this open as it's another approach. It's basically like #54 except it provides easy access to the client right there, and a nicer interface for sending messages (using channel names & usernames instead of ids).

Also it opens direct message channels if they aren't open yet. I think this may be necessary for messaging a user who has never messaged you, for example.

smrpr commented 8 years ago

@lins05 due to @prathyush not updating his PR, do you think we could focus on this one and fix what is needed to merge it? I think this would be really useful for slackbot.

olliencc commented 7 years ago

sad this isn't merged.. this is a killer PR

mew1033 commented 6 years ago

Looks awesome! I'm excited to see this merged!

nspo commented 6 years ago

Any chance of this being merged?

oannam commented 6 years ago

Is there any plan for this PR to be merged? I've seen that there are requests for changes. @csaftoiu any thoughts? In a fork of this repo I managed to build on top of the functionality added by @csaftoiu and added the possibility of running a function at certain times.