Giter Club home page Giter Club logo

slackbotapi's Introduction

Hi there ๐Ÿ‘‹

slackbotapi's People

Contributors

dasata avatar dependabot[bot] avatar franciskim avatar ganny26 avatar geetotes avatar gerlis18 avatar greenkeeperio-bot avatar gsabran avatar gzphreak avatar igorantun avatar jasonbahl avatar m4r71n avatar magroski avatar nerrad avatar pcuenca avatar rayman22201 avatar samhmills avatar sammons avatar simonjang avatar thedark1337 avatar waynekata avatar xbytez avatar zspecza 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

slackbotapi's Issues

Constructor does asynchronous tasks

The constructor performs asynchronous request to the Slack rtm.start method. The getChannel method of this module relies on the information gathered from this request and may fail when called right after construction.

HTML Example using slackboxapi

Hi,

It would be great if you could add an example HTML page using this API. I'm trying to use it at the moment but I keep getting the following error: "Uncaught ReferenceError: require is not defined".

I would be greatly appreciated if you could add this example to clear things up on how we can implement this into a web app.

Thanks,
Cathal.

Cannot read property 'ims' of undefined

23:13 31s 360ms [Transport] [SlackAPI]      Recieved: {"type":"message","channel":"....","user":"....","text":"%debug","ts":"1440717210.0000
32","team":"...."}

/example.js:47
                                console.log(slack.data.ims);
                                                      ^
TypeError: Cannot read property 'ims' of undefined

Header image for README.md

I feel like our README could use an image to further improve the looks of the README. Also a good hacktoberfest entry. No need to ask, feel free to submit a PR.

Feel free to take a look at the other issues as well.

avoid exiting the process and prefer throwing sane errors

On the lines:

https://github.com/xBytez/slackbotapi/blob/master/index.js#L91
https://github.com/xBytez/slackbotapi/blob/master/index.js#L100

process.exit(1) is called, which fatally stops the current script from running. There is a use case where the caller might create an API instance as a response to an HTTP request that provides a token, for example, suppose the developer is creating a means of "installing" a bot by responding to a user who inputs a token - in this scenario the developer's "bot" is hosted on a server that runs on multiple slack clients.

If one user submits the token 'notvalid', the app crashes and the other users, who's tokens are valid, are left in the dark.

It is far better to throw errors instead.

Example typo

There is a typo in the example file:

var slackAPI = require('slackAPI');

Should be:

var slackAPI = require('slackbotapi');

TypeError: Parameter 'url' must be a string, not undefined

Using the example code, I get this error:

url.js:110
    throw new TypeError("Parameter 'url' must be a string, not " + typeof url)
          ^
TypeError: Parameter 'url' must be a string, not undefined
    at Url.parse (url.js:110:11)
    at Object.urlParse [as parse] (url.js:104:5)
    at WebSocket.initAsClient (./node_modules/ws/lib/WebSocket.js:550:23)
    at new WebSocket (./node_modules/ws/lib/WebSocket.js:74:18)
    at slackAPI.connectSlack (./node_modules/slackbotapi/index.js:172:15)
    at ./node_modules/slackbotapi/index.js:121:14
    at Request._callback (./node_modules/slackbotapi/index.js:142:24)
    at Request.self.callback (./node_modules/request/request.js:198:22)
    at Request.emit (events.js:110:17)
    at Request.<anonymous> (./node_modules/request/request.js:1063:14)

Update dependencies

This project has gotten kind of stale with out-of-date dependencies. It still works but could use some updates.

Feel free to look at the other issues too.

Please test before submitting PRs.

Unable to PM

I am trying to PM a user when they join the team.

/home/ubuntu/node_modules/slackbotapi/index.js:238
    for (var i in self.slackData.ims) {
                  ^
ReferenceError: self is not defined
    at slackAPI.getIM (/home/ubuntu/node_modules/slackbotapi/index.js:238:19)

I even tried defining self = this there (probably not the right thing to do), but also no luck:

/home/ubuntu/node_modules/slackbotapi/index.js:245
            if (self.slackData.ims[i_]['user'] === this.getUser(term).id) {
                                                                     ^
TypeError: Cannot read property 'id' of null

The code I'm using:

slack.on('team_join', function (data) {
        slack.sendPM(data.user.id, "Welcome @" + data.user.name + "!");
});

pinned action in slack causes error

TypeError: Cannot call method 'slice' of undefined
    at EventEmitter.emit (/srv/www/experiments/ee-slackbot/node_modules/slackbotapi/node_modules/eventemitter2/lib/eventemitter2.js:302:77)

Error event getting fired on every message I send

Got this weird problem where whenever I post a message using the slack.sendMsg it emites an error event after the message has been sent containing a normal message sent response

{
  ok: true,
  reply_to: 0,
  ts: '1470627489.001015',
  text: 'text'
}

Any idea why it would be doing this?

[Question] manually run 'rtm.start' on an instance of slackAPI

This could be considered a more general JavaScript question.

I've made a 'greeter' bot - when someone joins, it'll message them a series of things.

For me to do this, I've needed to re-instantiate the slackAPI when someone joins:

slack.on('team_join', function (data) {
    slack = new slackAPI({
        'token': "abcdedfg",
        'logging': true
    });

I believe this resulted in multiple slackAPI instances being instantiated, and due to the lack of my JavaScript knowledge I do not know a better way to handle this.

The below code needs to be triggered to refresh the user list, as trying to PM a new user that has joined will error:

self.reqAPI('rtm.start', {}, function (data) {
        self.slackData.self = data.self;
        self.slackData.team = data.team;
        self.slackData.channels = data.channels;
        self.slackData.groups = data.groups;
        self.slackData.users = data.users;
        self.slackData.ims = data.ims;
        self.connectSlack(data.url, function(err, data){
            if (!err){
                self.emit(events[data.type], data);
            }
        });
    });

Any help is appreciated!

self.ws doesn't have on()

I'm getting

TypeError: self.ws.on is not a function
    at slackAPI.213.slackAPI.connectSlack (index.js:174)
    at index.js:121
    at Request._callback (index.js:142)
    at Request.322.Request.init.self.callback (request.js:198)
    at Request.166.EventEmitter.emit (events.js:80)
    at Request.<anonymous> (request.js:1073)
    at Request.166.EventEmitter.emit (events.js:99)
    at null.<anonymous> (request.js:1019)
    at 166.EventEmitter.emit (events.js:99)
    at endReadableNT (_stream_readable.js:944)

If I put a debugger, I see that self.ws has a onClose and an onOpen, etc, but no on. Is there a version mismatch somewhere? When I installed I ended up with version 0.8.0 of ws.

Write tests

This lib does not have any unit or integration tests yet.

Bot doesn't connect

Since commit 9cb065e the bot won't connect anymore since this.token was changed to this.authtoken but not in the reqAPI function.

Update dependencies (2018)

This project has gotten kind of stale with out-of-date dependencies. It still works but could use some updates.

Feel free to look at the other issues too.

This renders the greenkeeper bot PRs useless. You can ignore them and create one PR with all dependencies updated. Please extensively test before submitting PRs.

[Question] Start new DM

Hi again, do you know if it is possible to start a DM with a user just by the user ID/username? For example, to DM a user when they first join a Slack group.

presence_change events being blocked

I was testing multiple events using your code and I noticed that this block of code

} else if (data.type === 'presence_change') {
   // update slackData presence when user becomes active/inactive
   for (var i in self.slackData.users) {
      if (self.slackData.users[i].id === data.user) {
         self.slackData.users[i].presence = data.presence;
         break;
      }
   }
}

is blocking the bot from processing presence_change events.

Adding cb(null, messageData); after the for loop easily solve this problem.

https://github.com/xBytez/slackbotapi/blob/master/lib/rtm.js#L240

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.