Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTM 模式下 user.name 应该进行调整 #23

Open
1 task
bcho opened this issue Apr 12, 2017 · 2 comments
Open
1 task

RTM 模式下 user.name 应该进行调整 #23

bcho opened this issue Apr 12, 2017 · 2 comments

Comments

@bcho
Copy link
Contributor

bcho commented Apr 12, 2017

考察插件

  • hubot-auth
@loddit
Copy link
Contributor

loddit commented Apr 12, 2017

现在 hubot rtm 得到的结构里 res.message 如下:

TextMessage {
  user: 
   User {
     id: '=bw52Q',
     message: 
      { created_ts: 1491987937546,
        image: '',
        instance_no: 1,
        instance_seq: 9,
        key: '1491987937546.0109',
        refer_key: null,
        subtype: 'normal',
        text: 'badger',
        to_uid: '=bwNZS',
        ts: 1491987937546,
        type: 'message',
        uid: '=bw52Q',
        unknown_before: false,
        vchannel_id: '=ofw7Ae' },
     room: { vchannelId: '=ofw7Ae' },
     name: '=bw52Q' },
  text: 'hubot-secretary badger',
  id: '1491987937546.0109',
  done: false,
  room: { vchannelId: '=ofw7Ae' } }

res.envelope 结构如下:

{ room: { vchannelId: '=ofw7Ae' },
  user: 
   User {
     id: '=bw52Q',
     message: 
      { created_ts: 1491987937546,
        image: '',
        instance_no: 1,
        instance_seq: 9,
        key: '1491987937546.0109',
        refer_key: null,
        subtype: 'normal',
        text: 'badger',
        to_uid: '=bwNZS',
        ts: 1491987937546,
        type: 'message',
        uid: '=bw52Q',
        unknown_before: false,
        vchannel_id: '=ofw7Ae' },
     room: { vchannelId: '=ofw7Ae' },
     name: '=bw52Q' },
  message: 
   TextMessage {
     user: 
      User {
        id: '=bw52Q',
        message: [Object],
        room: [Object],
        name: '=bw52Q' },
     text: 'hubot-secretary badger',
     id: '1491987937546.0109',
     done: false,
     room: { vchannelId: '=ofw7Ae' } } }

@loddit loddit self-assigned this Jun 21, 2017
@loddit
Copy link
Contributor

loddit commented Jun 27, 2017

研究完了 hubot-auth 的原理,它本身是依赖于 hubot.brain.users 的。brain 里需要存一份用户列表(基于现在的 brain 实现这个还是持久化的)。
hobot 的 slack adapter 里是支持的,它一上来就调用 API 获取一份 users 列表 ,并且用 slack-client 监听用户更新。(https://github.com/slackapi/hubot-slack/pull/381/files)
我们要想也走同样的方案,就要做同样的事情。

另外还有一个方案是自己 fork hubot-auth 或做一套独立的认证,不基于 hubot.brain.users 实现。这个做起来会比较容易,就是有点原理社区的生态。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants