Git Product home page Git Product logo

Comments (5)

StewPoll avatar StewPoll commented on May 31, 2024

The first part of the channel ID will start with "D"

{'ts': '1454135373.000338', 'text': 'This is a channel', 'user': 'U02GSB32U', 'channel': 'C02HDGZT9', 'team': '<REDACTED>', 'type': 'message'}
{'ts': '1454135387.000045', 'text': 'This is a group', 'user': 'U02GSB32U', 'channel': 'G04UL2QM5', 'team': '<REDACTED>', 'type': 'message'}
{'ts': '1454135392.000010', 'text': 'This is a DM', 'user': 'U02GSB32U', 'channel': 'D04UGH7SL', 'team': '<REDACTED>', 'type': 'message'}

from limbo.

llimllib avatar llimllib commented on May 31, 2024

neat! next up is that this should be wired into slackrtm, probably the message should come with an is_direct_message field or something?

from limbo.

StewPoll avatar StewPoll commented on May 31, 2024

Having a second look at the code in the commit that you've linked, they're not looking for DMs, they're looking for mentions of the bot within regular channel/group messages.

init_msg == '<@xxxxxxx>:'

You can get this ID using the auth.test call from slack.

Maybe have a .self_id attribute to server?

That way we can have the following functions as part of the server object, that people can check with within plugins:

def is_direct(server, msg):
    if msg['channel'][0] == "D":
        return True

def is_mention(server, msg):
    if msg["text"].split(" ")[0] = "<{0}>:".format(server.self_id):
        return True

from limbo.

llimllib avatar llimllib commented on May 31, 2024

The bot's ID is actually available, via the opaque server.slack.server.login_data["self"]["name"]; limbo used to make sure it wasn't responding to itself but I seem to have cut that out when I added the bot_message handler.

from limbo.

llimllib avatar llimllib commented on May 31, 2024

the slackrtm library should probably gain two issues:

  • create a self_id attribute
  • add a direct message flag

will do when I have time

from limbo.

Related Issues (20)

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.