Restricted bot cannot post messages
babymotte opened this issue · 4 comments
Whenever I install a bot in a team as a restricted bot, any attempt by the bot to send a message to the channel it is installed to results in this error:
Error: error from chat server: team readers are unable to create conversations, found role RESTRICTEDBOT
Steps to reproduce:
- git clone https://github.com/keybase/keybase-bot.git && cd keybase-bot
- npm i
- KB_USERNAME=[username] KB_PAPERKEY=[paperkey] node demos/es7/advertised-echo.js
- In the keybase GUI enter a channel of a big team
- Add the bot's user as a restricted bot (i > Bots > Add a bot > Search featured bots or users... > Install as Restricted bot > Review > Install)
- Send "!echo hello"
Expected behavior:
Bot replies with "hello"
Observed behavior:
Bot does not reply, node.js process prints the following error message:
(node:60921) UnhandledPromiseRejectionWarning: Error: error from chat server: team readers are unable to create conversations, found role RESTRICTEDBOT
at new ErrorWithCode (/home/mbachmann/Code/keybase-bot/lib/client-base/index.js:63:28)
at Chat.<anonymous> (/home/mbachmann/Code/keybase-bot/lib/client-base/index.js:139:35)
at step (/home/mbachmann/Code/keybase-bot/lib/client-base/index.js:46:23)
at Object.next (/home/mbachmann/Code/keybase-bot/lib/client-base/index.js:27:53)
at fulfilled (/home/mbachmann/Code/keybase-bot/lib/client-base/index.js:18:58)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:60921) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:60921) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
When I add the bot as an unrestricted bot or as a regular team member/chat participant, it replies as expected.
Tested with Keybase GUI Version: 5.2.0 and keybase-bot 3.4.0
Sorry for replying so late here. Channel names are not keyed for restricted bot so the ChatChannel
can't be used to send a message to a team where the bot is added as restricted. Instead, you can use conversationId
which is available in the MsgSummary
you get from bot.chat.watchAllChannelsForNewMessages
. We've also updated both readme and the examples to use conversationId
when possible.
I've tried that but no luck so far. I don't get any errors anymore but none of the messages the bot sends are ever shown in the chat.
Oh, nevermind, I do get an answer. Just for whatever reason the first message after the bot is started takes about 4 minutes to arrive. I've never waited that long before.
Ok, seems to work. Thank you!