You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to write a simple keybase bot. My intention was to auto-subscribe people to a rules channel as soon as they join. But I can't get the list of members. Here is my code:
constBot=require('keybase-bot')constbot=newBot()constusername='username-redacted'constpaperkey='paperkey-redacted'bot.init(username,paperkey,{verbose: false}).then(()=>{console.log(`Your bot is initialized. It is logged in as ${bot.myInfo().username}`)bot.team.listTeamMemberships({team: 'team-name-redacted'}).then(res=>console.log(res)).catch(error=>{console.error(error)})bot.deinit()}).catch(error=>{console.error(error)bot.deinit()})
I get the following error when I run it:
Your bot is initialized. It is logged in as username-redacted
Error: API network error: doRetry failed, attempts: 3, timeout 5.324s, last err: context canceled (error 1601)
at Team._runApiCommand (/home/epsilon/keybase-bot/node_modules/keybase-bot/index.js:565:13)
at processTicksAndRejections (internal/process/task_queues.js:89:5)
at async Team.listTeamMemberships (/home/epsilon/keybase-bot/node_modules/keybase-bot/index.js:1283:17)
I have copy-pasted the code from the example so I don't think the error comes from there. Keybase connects to the internet just fine. I don't know where the error comes from.
The text was updated successfully, but these errors were encountered:
Looks like a bug in keybase/client, list-team-memberships fails straight after the service's startup. As a workaround either use .initFromRunningService(), wait a second or two before making the request or implement a retry mechanism:
const Bot = require('../../index.js')
const bot = new Bot()
const username = process.env.KB_USERNAME
const paperkey = process.env.KB_PAPERKEY
function timeout(time) {
return new Promise(resolve => {
setTimeout(() => {
resolve()
}, time)
})
}
bot
.init(username, paperkey, {verbose: false})
.then(async () => {
console.log(`Your bot is initialized. It is logged in as ${bot.myInfo().username}`)
while (true) {
try {
const res = await bot.team.listTeamMemberships({team: process.env.KB_TEAM})
console.log(res)
break
} catch (err) {
console.log(err)
await timeout(500)
}
}
})
.catch(error => {
console.error(error)
bot.deinit()
})
I am trying to write a simple keybase bot. My intention was to auto-subscribe people to a rules channel as soon as they join. But I can't get the list of members. Here is my code:
I get the following error when I run it:
I have copy-pasted the code from the example so I don't think the error comes from there. Keybase connects to the internet just fine. I don't know where the error comes from.
The text was updated successfully, but these errors were encountered: