### Example: Initialize Keybase Bot with Username and Paperkey Source: https://github.com/keybase/keybase-bot/blob/master/README.md A JavaScript example demonstrating the basic usage of the `bot.init` method to authenticate and start the Keybase bot using a provided username and paperkey. ```javascript bot.init('username', 'paperkey') ``` -------------------------------- ### Install Keybase Bot Module Source: https://github.com/keybase/keybase-bot/blob/master/README.md Instructions to install the `keybase-bot` module using npm or yarn. This setup requires Node.js 12 or above and a running Keybase application. ```bash npm install keybase-bot # or yarn add keybase-bot ``` -------------------------------- ### Keybase Bot Source Code Setup Source: https://github.com/keybase/keybase-bot/blob/master/README.md Provides step-by-step instructions and commands to set up the Keybase bot development environment, including cloning the repository, installing dependencies, and building the project for development, production, and documentation. ```shell git clone yarn yarn dev yarn build yarn docs ``` -------------------------------- ### Examples for Batch Sending Lumens (XLM) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Provides an example of how to use the `batch` method to send XLM to multiple recipients in a single operation, specifying a batch ID and an array of payment details. ```javascript bot.wallet.batch('airdrop2040', [ {recipient: 'a1', amount: '1.414', message: 'hi a1, yes 1'}, {recipient: 'a2', amount: '3.14159', message: 'hi a2, yes 2'} ]) ``` -------------------------------- ### Bot.init Method API Reference Source: https://github.com/keybase/keybase-bot/blob/master/README.md Detailed API documentation for the `init` method of the Keybase Bot, including its purpose, parameters, and return type. This method is crucial for authenticating and starting the bot's service. ```APIDOC Bot.init(username: string, paperkey: string, options?: InitOptions) username: The username of your bot's Keybase account. paperkey: The paperkey of your bot's Keybase account. options: The initialization options for your bot. Returns: Promise ``` -------------------------------- ### Examples for Sending Lumens (XLM) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Illustrates various ways to use the `send` method to transfer XLM, including sending to Keybase users, external accounts, specifying currency, and adding a message. ```javascript bot.wallet.send('nathunsmitty', '3.50') // Send 3.50 XLM to Keybase user `nathunsmitty` bot.wallet.send('nathunsmitty@github', '3.50') // Send 3.50 XLM to GitHub user `nathunsmitty` bot.wallet.send('nathunsmitty', '3.50', 'USD') // Send $3.50 worth of lumens to Keybase user `nathunsmitty` bot.wallet.send('nathunsmitty', '3.50', 'USD', 'Shut up and take my money!') // Send $3.50 worth of lumens to Keybase user `nathunsmitty` with a memo ``` -------------------------------- ### Keybase Bot Type Generation Source: https://github.com/keybase/keybase-bot/blob/master/README.md Explains how to generate TypeScript types for the Keybase bot. This process relies on definitions from the Keybase client repository's protocol directory and requires Go, Node.js, and Yarn to be installed for fetching the client repo, installing its dependencies, and running the type generation Makefile. ```shell go get github.com/keybase/client/go/keybase cd client/protocol yarn install cd path/to/keybase-bot make make clean ``` -------------------------------- ### Send a 'Hello World' Message with Keybase Bot Source: https://github.com/keybase/keybase-bot/blob/master/README.md A complete example demonstrating how to initialize a Keybase bot with credentials, send a 'Hello World' message to a specific channel (kbot), and then deinitialize the bot. Includes basic error handling. ```javascript const Bot = require('keybase-bot') async function main() { const bot = new Bot() try { const username = 'some_username' // put a real username here const paperkey = 'foo bar car zar...' // put a real paperkey here await bot.init(username, paperkey, {verbose: false}) console.log(`Your bot is initialized. It is logged in as ${bot.myInfo().username}`) const channel = {name: 'kbot'} const message = { body: `Hello kbot! This is ${bot.myInfo().username} saying hello from my device ${bot.myInfo().devicename}`, } await bot.chat.send(channel, message) console.log('Message sent!') } catch (error) { console.error(error) } finally { await bot.deinit() } } main() ``` -------------------------------- ### Send Chat Messages (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md These JavaScript examples illustrate how to send messages using `bot.chat.send`. The first example shows sending a direct message to a defined channel. The second demonstrates sending a reply within a `watchAllChannelsForNewMessages` listener, showcasing reactive message sending. ```javascript const channel = {name: 'kbot,' + bot.myInfo().username, public: false, topicType: 'chat'} const message = {body: 'Hello kbot!'} bot.chat.send(channel, message).then(() => console.log('message sent!')) ``` ```javascript const onMessage = async message => { bot.chat.send(message.conversationId, { body: 'hello!', }) } await bot.chat.watchAllChannelsForNewMessages(onMessage, onError) ``` -------------------------------- ### Create a New Chat Channel (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md This JavaScript example demonstrates how to create a new chat conversation using `bot.chat.createChannel`. It shows a Promise-based approach to confirm when the conversation has been successfully created. ```javascript bot.chat.createChannel(channel).then(() => console.log('conversation created')) ``` -------------------------------- ### Keybase Bot JavaScript Application Example Source: https://github.com/keybase/keybase-bot/blob/master/README.md A Node.js script demonstrating how to initialize a Keybase bot, log in using environment variables (KB_USERNAME, KB_PAPERKEY), send a chat message to a specified target (KB_TARGET), and properly deinitialize the bot. It includes error handling and logs bot information. ```javascript #!/usr/bin/env node const Bot = require('keybase-bot') async function main() { const bot = new Bot() try { const username = process.env.KB_USERNAME const paperkey = process.env.KB_PAPERKEY const target = process.env.KB_TARGET await bot.init(username, paperkey, {verbose: false}) console.log(`Your bot is initialized. It is logged in as ${bot.myInfo().username}`) const channel = {name: target + ',' + bot.myInfo().username, public: false, topicType: 'chat'} const message = { body: `Hello ${target}! This is ${bot.myInfo().username} saying hello from my device ${bot.myInfo().devicename}`, } await bot.chat.send(channel, message) console.log('Message sent!') } catch (error) { console.error(error) } finally { await bot.deinit() } } main() ``` -------------------------------- ### Get Keybase Bot Information Source: https://github.com/keybase/keybase-bot/blob/master/README.md Retrieves essential information about the Keybase bot, including its username, device, and home directory. This method returns a BotInfo object if the bot is initialized, otherwise it returns null. ```APIDOC myInfo(): BotInfo | null Returns: Useful information like the username, device, and home directory of your bot. If your bot isn't initialized, you'll get null. ``` ```javascript const info = bot.myInfo() ``` -------------------------------- ### Dockerfile for Keybase Bot Application Source: https://github.com/keybase/keybase-bot/blob/master/README.md A Dockerfile to build a container image for the Keybase bot application. It uses a Keybase client base image, sets up an application directory, copies package files, installs Node.js dependencies, and defines the command to run the bot's main script. ```dockerfile FROM keybaseio/client:nightly-node RUN mkdir /app && chown keybase:keybase /app WORKDIR /app COPY package*.json ./ RUN npm install # or use yarn COPY . . CMD node /app/index.js ``` -------------------------------- ### List Chat Channels in a Team (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md This JavaScript example shows how to use `bot.chat.listChannels` to retrieve conversation channels for a given team. It demonstrates a Promise-based approach to log the resulting array of `chat1.ConvSummary` objects. ```javascript bot.chat.listChannels('team_name').then(chatConversations => console.log(chatConversations)) ``` -------------------------------- ### Attach a File to a Chat Conversation (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md This JavaScript example demonstrates how to attach a file to a chat conversation using `bot.chat.attach`. It shows sending a local image file and logging a confirmation message upon successful attachment. ```javascript bot.chat.attach(channel, '/Users/nathan/my_picture.png').then(() => console.log('Sent a picture!')) ``` -------------------------------- ### Read Messages from a Chat Conversation (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md This JavaScript example demonstrates how to read messages from a chat conversation using `alice.chat.read`. It shows a Promise-based pattern to log the retrieved messages. An error is thrown if the channel has no messages. ```javascript alice.chat.read(channel).then(messages => console.log(messages)) ``` -------------------------------- ### Example for Canceling a Keybase Bot Payment Source: https://github.com/keybase/keybase-bot/blob/master/README.md Demonstrates how to use the `cancel` method to revoke a pending XLM transaction using its transaction ID, with a success callback. ```javascript bot.wallet .cancel('e5334601b9dc2a24e031ffeec2fce37bb6a8b4b51fc711d16dec04d3e64976c4') .then(() => console.log('Transaction successfully canceled!')) ``` -------------------------------- ### List Chat Conversations (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md This JavaScript example demonstrates how to list chat conversations using the `bot.chat.list` method. It retrieves only unread conversations and logs the result to the console. The method returns a Promise that resolves to an array of `chat1.ConvSummary` objects. ```javascript const chatConversations = await bot.chat.list({unreadOnly: true}) console.log(chatConversations) ``` -------------------------------- ### Get Keybase Wallet Balances (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Fetches a list of all Stellar accounts owned by the current Keybase user and their balances. This method returns a Promise that resolves to an array of `stellar1.OwnAccountCLILocal` objects, which may be empty if no accounts exist. ```javascript bot.wallet.balances().then(accounts => console.log(accounts)) ``` -------------------------------- ### Get Keybase Wallet Transaction Details (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Provides detailed information for a specific Stellar transaction. This method requires the `transactionId` as a parameter. It returns a Promise that resolves to a `stellar1.PaymentCLILocal` object containing the transaction details. ```javascript bot.wallet.details('e5334601b9dc2a24e031ffeec2fce37bb6a8b4b51fc711d16dec04d3e64976c4').then(details => console.log(details)) ``` -------------------------------- ### Load Flip Details in Keybase Bot Chat Source: https://github.com/keybase/keybase-bot/blob/master/README.md Loads the detailed status of a coin flip within a Keybase chat conversation. This function requires specific identifiers including the conversation ID, flip conversation ID, message ID, and game ID to retrieve the flip's details. Note: No direct code example is provided in the source; refer to `demos/es7/poker-hands.js` for usage. ```APIDOC loadFlip(conversationID: string, flipConversationID: string, messageID: number, gameID: string): Promise conversationID: string - conversation ID received in API listen flipConversationID: string - flipConvID from the message summary messageID: number - ID of the message in the conversation gameID: string - gameID from the flip message contents ``` -------------------------------- ### Get Current Unfurl Settings in Keybase Bot Chat Source: https://github.com/keybase/keybase-bot/blob/master/README.md Retrieves the current unfurling settings for the Keybase chat client. This function returns a Promise that resolves with the current unfurl mode, which dictates how links are previewed in chat messages. ```JavaScript bot.chat.getUnfurlSettings().then(mode => console.log(mode)) ``` ```APIDOC getUnfurlSettings(): Promise ``` -------------------------------- ### Get Keybase Wallet Transaction History (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Retrieves the transaction history for a specific Stellar account owned by the Keybase user. This method requires the `accountId` as a parameter. It returns a Promise that resolves to an array of `stellar1.PaymentCLILocal` objects representing the transactions. ```javascript bot.wallet.history('GDUKZH6Q3U5WQD4PDGZXYLJE3P76BDRDWPSALN4OUFEESI2QL5UZHCK').then(transactions => console.log(transactions)) ``` -------------------------------- ### Node.js Package Configuration for Keybase Bot Source: https://github.com/keybase/keybase-bot/blob/master/README.md A standard `package.json` file defining the project's metadata, main entry point (`index.js`), and dependencies, specifically including the `keybase-bot` package with a specified version. ```json { "name": "keybase-demo", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "keybase-bot": "^3.0.2" } } ``` -------------------------------- ### Initialize Keybase Bot from Running Service Source: https://github.com/keybase/keybase-bot/blob/master/README.md Initializes the Keybase bot by connecting to an existing running Keybase service. This method allows specifying a custom home directory and additional initialization options. It returns a Promise that resolves upon successful initialization. ```APIDOC initFromRunningService(homeDir?: string, options?: InitOptions): Promise homeDir: The home directory of this currently running service. Leave blank to use the default homeDir for your system. options: The initialization options for your bot. ``` ```javascript bot.initFromRunningService() ``` -------------------------------- ### Initialize Keybase Bot with Environment Variables Source: https://github.com/keybase/keybase-bot/blob/master/README.md Illustrates a more secure way to initialize the Keybase bot by reading the username and paper key from environment variables (`KB_USERNAME`, `KB_PAPERKEY`) instead of hard-coding them directly in the code. ```javascript const username = process.env.KB_USERNAME const paperkey = process.env.KB_PAPERKEY await bot.init(username, paperkey) ``` -------------------------------- ### Run Keybase Bot JavaScript File Source: https://github.com/keybase/keybase-bot/blob/master/README.md Command line instruction to execute a JavaScript file containing Keybase bot code using Node.js. ```bash node .js ``` -------------------------------- ### Initialize Keybase Bot with Username and Paper Key Source: https://github.com/keybase/keybase-bot/blob/master/README.md Demonstrates how to initialize the Keybase bot with a specific username and paper key. This method allows the bot to run independently of the Keybase GUI application and is suitable for long-running background processes. ```javascript const Bot = require('keybase-bot') async function main() { const bot = new Bot() await bot.init('usernameX', 'some paper key...') /* now you can do things with the bot */ await bot.deinit() // when done } main() ``` -------------------------------- ### Initialize Keybase Bot from Running Service Source: https://github.com/keybase/keybase-bot/blob/master/README.md Shows how to initialize the Keybase bot by connecting to an already running Keybase service. This method makes the bot act as the currently logged-in user in the Keybase app and requires no explicit credentials. ```javascript const Bot = require('keybase-bot') async function main() { const bot = new Bot() // Make sure you're logged into the Keybase app first! // No credentials neeeded: await bot.initFromRunningService() /* now you can do things with the bot */ await bot.deinit() // when done } main() ``` -------------------------------- ### Keybase Bot Release Process Source: https://github.com/keybase/keybase-bot/blob/master/README.md Outlines the steps for cutting a new release of the Keybase bot. This involves ensuring the master branch is up to date, running `standard-version` to generate a CHANGELOG and version, pushing the new git tags, and publishing the package to npm. ```shell # Make sure all commits are squash-merged into master branch. # On your local copy, checkout master and ensure it's up to date with origin/master. yarn release git push --follow-tags origin master yarn publish ``` -------------------------------- ### Run Keybase Bot Script with Environment Variables Source: https://github.com/keybase/keybase-bot/blob/master/README.md Command line instruction to execute a JavaScript file while passing Keybase bot credentials as environment variables, enhancing security by avoiding hardcoded values. ```bash KB_USERNAME=foo KB_PAPERKEY="foo bar car" node my-awesome-program.js ``` -------------------------------- ### Build Keybase Bot Docker Image Command Source: https://github.com/keybase/keybase-bot/blob/master/README.md A bash command to build the Docker image for the Keybase bot application. It navigates to the project directory and tags the resulting image as 'keybase-docker-test'. ```bash cd $PROJECT_DIR docker build -t "keybase-docker-test" . ``` -------------------------------- ### Keybase Bot Chat API: createChannel Method Source: https://github.com/keybase/keybase-bot/blob/master/README.md Documents the `createChannel` method for the Keybase bot's chat API. This method is used to create a new, empty chat conversation. It requires a `chat1.ChatChannel` object as a parameter and returns a Promise that resolves to void. ```APIDOC Method: createChannel Description: Creates a new blank conversation. Parameters: - channel: chat1.ChatChannel (The chat channel to create.) Returns: Promise ``` -------------------------------- ### API: Batch Send Lumens (XLM) via Keybase Bot Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `batch` method, designed for sending XLM to multiple users simultaneously within the same 5-second Stellar ledger. It outlines the parameters for batch payments and the expected return value. ```APIDOC batch(batchId: string, payments: Array): Promise batchId: Example, if sending a bunch of batches for an airdrop, you could pass them all `airdrop2025`. payments: An array of objects containing recipients and XLM of the form {"recipient": "someusername", "amount": "1.234", "message", "hi there"}. ``` -------------------------------- ### API Reference: Keybase Team Module Source: https://github.com/keybase/keybase-bot/blob/master/README.md This section documents the Keybase bot's team module, which extends `ClientBase`. It provides methods for managing team members, such as adding multiple users with specified privileges. ```APIDOC Team (Extends ClientBase): The team module of your Keybase bot. For more info about the API this module uses, you may want to check out `keybase team api`. addMembers(additions: AddMembersParam): Add a bunch of people with different privileges to a team additions: AddMembersParam - an array of the users to add, with privs ``` -------------------------------- ### Keybase Bot Test Execution Source: https://github.com/keybase/keybase-bot/blob/master/README.md Details the process for running tests for the Keybase bot using Jest. This involves configuring a test environment with specific Keybase accounts, paperkeys, and team names by copying and editing a configuration file, then executing the tests. ```shell cp __tests__/test.config.example.ts __tests__/test.config.ts # Edit __tests__/test.config.ts to replace placeholder values yarn test ``` -------------------------------- ### Run Keybase Bot Docker Container Command Source: https://github.com/keybase/keybase-bot/blob/master/README.md A bash command to run the Keybase bot Docker container. It uses the '--rm' flag to remove the container after exit and passes necessary environment variables (KB_USERNAME, KB_PAPERKEY, KB_TARGET) for bot authentication and target user identification. ```bash docker run \ --rm \ -e KB_USERNAME="yourbotname" \ -e KB_PAPERKEY="your_paper_key" \ -e KB_TARGET="yourusername" \ keybase-docker-test ``` -------------------------------- ### Advertise Bot Commands in Keybase Chat Source: https://github.com/keybase/keybase-bot/blob/master/README.md Publishes a set of commands that will be shown in the Keybase chat autocomplete menu (e.g., when typing '!'). This allows users to discover and use bot functionalities. The method requires an `Advertisement` object defining the commands, their descriptions, and usage. ```JavaScript await bot.chat.advertiseCommands({ advertisements: [ { type: 'public', commands: [ { name: '!echo', description: 'Sends out your message to the current channel.', usage: '[your text]', }, ], }, ], }) ``` ```APIDOC advertiseCommands(advertisement: Advertisement): Promise advertisement: Advertisement - details of the advertisement ``` -------------------------------- ### API: Send Lumens (XLM) via Keybase Bot Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `send` method, which allows sending Stellar Lumens (XLM) through the Keybase bot. It details the parameters required for sending money to various recipient types and the expected return value. ```APIDOC send(recipient: string, amount: string, currency?: string, message?: string): Promise recipient: Who you're sending your money to. This can be a Keybase user, stellar address, or a username of another account that is supported by Keybase if it is followed by an '@'. amount: The amount of XLM to send. currency: Adds a currency value to the amount specified. For example, adding 'USD' would send. message: The message for your payment. ``` -------------------------------- ### Keybase Wallet balances API (APIDOC) Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `balances` method in the Keybase Bot's Wallet module. This method provides a list of all accounts owned by the current Keybase user. ```APIDOC bot.wallet.balances() Returns: Promise> - An array of accounts. If there are no accounts, the array is empty. ``` -------------------------------- ### API Reference: watchAllChannelsForNewMessages Method Source: https://github.com/keybase/keybase-bot/blob/master/README.md This API method puts the bot into full-read mode, allowing it to receive and process all new messages across all channels. It provides callbacks for message handling and error reporting, along with options for message listening. ```APIDOC watchAllChannelsForNewMessages(onMessage: OnMessage, onError?: OnError, options?: ListenOptions): Promise onMessage: OnMessage - A callback that is triggered on every message your bot receives. onError: OnError? - A callback that is triggered on any error that occurs while the method is executing. options: ListenOptions? - Options for the listen method. ``` -------------------------------- ### Keybase Wallet details API (APIDOC) Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `details` method in the Keybase Bot's Wallet module. This method retrieves details about a particular transaction. ```APIDOC bot.wallet.details(transactionId: stellar1.TransactionID) transactionId: stellar1.TransactionID - The id of the transaction you would like details about. Returns: Promise - An object of details about the transaction specified. ``` -------------------------------- ### Watch Channel for New Keybase Chat Messages (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Sets up a listener for new chat messages on a specified Keybase channel. The `onMessage` callback function is triggered for every message your bot receives. This method is similar to `watchAllChannelsForNewMessages` but focuses on a single channel. It can receive messages posted by the bot itself from other devices, which can be filtered by inspecting the message's sender object. Exploding messages are hidden by default. It returns a Promise that resolves when the listener is successfully set up. ```APIDOC watchChannelForNewMessages(channel: chat1.ChatChannel, onMessage: OnMessage, onError?: OnError, options?: ListenOptions): Promise channel: The chat channel to watch. onMessage: A callback that is triggered on every message your bot receives. onError: A callback that is triggered on any error that occurs while the method is executing. options: Options for the listen method. ``` ```javascript // Reply to all messages between you and `kbot` with 'thanks!' const channel = {name: 'kbot,' + bot.myInfo().username, public: false, topicType: 'chat'} const onMessage = message => { const conversationId = message.conversationId bot.chat.send(conversationId, {body: 'thanks!!!'}) } bot.chat.watchChannelForNewMessages(channel, onMessage) ``` -------------------------------- ### Download File in Keybase Chat (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Downloads a file sent via Keybase chat. This method requires the chat channel or conversation ID, the message ID of the attached file, and the absolute path where the file should be downloaded. It returns a Promise that resolves when the download is complete. ```APIDOC download(channelOrConversationId: chat1.ChatChannel | chat1.ConvIDStr, messageId: number, output: string, options?: ChatDownloadOptions): Promise channelOrConversationId: The chat conversation to send the message in. messageId: The message id of the attached file. output: The absolute path of where the file should be downloaded to. options: An object of options that can be passed to the method ``` ```javascript bot.chat.download(channel, 325, '/Users/nathan/Downloads/file.png') ``` -------------------------------- ### Log Informational Debug Messages Source: https://github.com/keybase/keybase-bot/blob/master/README.md Writes informational text to a designated debug log file, provided the bot was initialized with an adminDebugDirectory. This function is useful for recording general operational messages. It returns a Promise that resolves after the text is written. ```APIDOC adminDebugLogInfo(text: string): Promise text: The string text to log. ``` ```javascript bot.adminDebugLogInfo('My bot is ready to go.') ``` -------------------------------- ### API: ChatListChannelsOptions Type Definition Source: https://github.com/keybase/keybase-bot/blob/master/README.md Defines the options structure for the `listChannels` method within the chat module of the Keybase bot. ```APIDOC ChatListChannelsOptions: Options for the `listChannels` method of the chat module. ``` -------------------------------- ### Keybase Team listTeamMemberships API (APIDOC) Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `listTeamMemberships` method in the Keybase Bot's Team module. This method lists all members of a specified team. ```APIDOC bot.team.listTeamMemberships(team: ListTeamMembershipsParam) team: ListTeamMembershipsParam - an object with the `team` name in it. Returns: Promise - Details about the team. ``` -------------------------------- ### List Advertised Bot Commands in Keybase Chat Source: https://github.com/keybase/keybase-bot/blob/master/README.md Retrieves a list of all commands currently advertised within a specific Keybase chat channel. This function can be used to inspect available bot commands and their details, such as name, description, usage, and publisher. It requires an `AdvertisementsLookup` object to specify the target channel. ```JavaScript const commandsList = await bot.chat.listCommands({ channel: channel, }) console.log(commandsList) // prints out something like: // { // commands: [ // { // name: '!helloworld', // description: 'sample description', // usage: '[command arguments]', // username: 'userwhopublished', // } // ] // } ``` ```APIDOC listCommands(lookup: AdvertisementsLookup): Promise<{commands: Array}> lookup: AdvertisementsLookup - either conversation id or channel ``` -------------------------------- ### Join a Keybase Team Chat Channel Source: https://github.com/keybase/keybase-bot/blob/master/README.md Enables the bot to join a specified team conversation channel. This method requires a chat1.ChatChannel object to identify the target channel. It returns a Promise that resolves once the bot has successfully joined the channel. ```APIDOC joinChannel(channel: chat1.ChatChannel): Promise channel: The team chat channel to join. ``` ```javascript bot.chat.listConvsOnName('team_name').then(async teamConversations => { for (const conversation of teamConversations) { if (conversation.memberStatus !== 'active') { await bot.chat.join(conversation.channel) console.log('Joined team channel', conversation.channel) } } }) ``` -------------------------------- ### API Reference: Keybase Chat Module Types Source: https://github.com/keybase/keybase-bot/blob/master/README.md This section defines various types used within the Keybase bot's chat module, including options for `attach`, `download`, `react`, and `delete` methods, as well as callback function types for `OnMessage` and `OnError`, and `ListenOptions`. ```APIDOC ChatAttachOptions: Options for the `attach` method of the chat module. ChatDownloadOptions: Options for the `download` method of the chat module. ChatReactOptions: Options for the `react` method of the chat module. ChatDeleteOptions: Options for the `delete` method of the chat module. OnMessage: function (message: chat1.MsgSummary): (void | Promise) - A function to call when a message is received. OnError: function (error: Error): (void | Promise) - A function to call when an error occurs. ListenOptions: Options for the methods in the chat module that listen for new messages. Local messages are ones sent by your device. Including them in the output is useful for applications such as logging conversations, monitoring own flips and building tools that seamlessly integrate with a running client used by the user. ``` -------------------------------- ### Keybase Bot Chat API: listChannels Method Source: https://github.com/keybase/keybase-bot/blob/master/README.md Documents the `listChannels` method of the Keybase bot's chat API. This method is used to list all conversation channels within a specified team. It accepts the team name and optional `ChatListChannelsOptions` and returns a Promise resolving to an array of `chat1.ConvSummary` objects. ```APIDOC Method: listChannels Description: Lists conversation channels in a team Parameters: - name: string (Name of the team) - options: ChatListChannelsOptions? (An object of options that can be passed to the method.) Returns: Promise> (An array of chat conversations. If there are no conversations, the array is empty.) ``` -------------------------------- ### Keybase Team addMembers API (APIDOC) Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `addMembers` method in the Keybase Bot's Team module. This method adds new members to a team, allowing specification of roles and using either email addresses or Keybase/social usernames. ```APIDOC bot.team.addMembers(params: object) params.team: string - The name of the team. params.emails: Array<{email: string, role: string}> - An array of email objects with email and role. params.usernames: Array<{username: string, role: string}> - An array of username objects with username and role. Returns: Promise - A result object of adding these members to the team. ``` -------------------------------- ### API: ChatListOptions Type Definition Source: https://github.com/keybase/keybase-bot/blob/master/README.md Defines the options structure for the `list` method within the chat module of the Keybase bot. ```APIDOC ChatListOptions: Options for the `list` method of the chat module. ``` -------------------------------- ### Keybase Wallet history API (APIDOC) Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `history` method in the Keybase Bot's Wallet module. This method provides a list of all transactions in a single account. ```APIDOC bot.wallet.history(accountId: stellar1.AccountID) accountId: stellar1.AccountID - The id of an account owned by a Keybase user. Returns: Promise> - An array of transactions related to the account. ``` -------------------------------- ### Deinitialize Keybase Bot Source: https://github.com/keybase/keybase-bot/blob/master/README.md Deinitializes the Keybase bot by logging out, stopping the Keybase service, and cleaning up any temporary login files. This crucial method should be executed before the bot application terminates to ensure a clean shutdown. It returns a Promise that resolves when the deinitialization process is complete. ```APIDOC deinit(): Promise ``` ```javascript bot.deinit() ``` -------------------------------- ### Lookup Keybase User or External Account Source: https://github.com/keybase/keybase-bot/blob/master/README.md Demonstrates how to look up a Keybase user or an external account (e.g., Twitter) using the bot's wallet lookup function. It shows how to compare the results using Lodash's `isEqual`. ```javascript const lookup1 = bot.wallet.lookup('patrick') // 'patrick' on Keybase is 'patrickxb' on twitter const lookup2 = bot.wallet.lookup('patrcikxb@twitter') // Using Lodash's `isEqual` since objects with same values aren't equal in JavaScript _.isEqual(lookup1, lookup2) // => true ``` -------------------------------- ### Set Unfurl Mode in Keybase Bot Chat Source: https://github.com/keybase/keybase-bot/blob/master/README.md Configures the unfurling mode for the Keybase chat client. Unfurling generates link previews for messages. If the mode is set to 'always' or the domain is whitelisted, the Keybase service automatically sends a preview. This method requires a `chat1.UnfurlSettings` object as input. ```JavaScript bot.chat .setUnfurlMode({ mode: 'always', }) .then(mode => console.log('mode updated!')) ``` ```APIDOC setUnfurlSettings(mode: chat1.UnfurlSettings): Promise mode: chat1.UnfurlSettings - the new unfurl mode ``` -------------------------------- ### Keybase Bot Chat API: attach Method Source: https://github.com/keybase/keybase-bot/blob/master/README.md Documents the `attach` method for the Keybase bot's chat API. This method allows sending a file attachment to a specified chat conversation. It requires the channel or conversation ID, the absolute path to the file, and optional `ChatAttachOptions`. ```APIDOC Method: attach Description: Send a file to a conversation. Parameters: - channelOrConversationId: chat1.ChatChannel or chat1.ConvIDStr (The chat conversation to send the message in.) - filename: string (The absolute path of the file to send.) - options: ChatAttachOptions? (An object of options that can be passed to the method.) Returns: Promise ``` -------------------------------- ### Keybase Bot Chat Module Source: https://github.com/keybase/keybase-bot/blob/master/README.md The Chat module provides comprehensive functionalities for interacting with Keybase chat conversations. It extends the ClientBase and offers methods for managing channel memberships and sending messages. Further details can be found in the keybase chat api documentation. ```APIDOC class Chat extends ClientBase ``` -------------------------------- ### List Keybase Bot Chats Source: https://github.com/keybase/keybase-bot/blob/master/README.md Lists all chat conversations accessible to the bot, providing information on which ones have unread messages. An optional `ChatListOptions` object can be passed to the method to customize the listing behavior. ```APIDOC list(options?: ChatListOptions) options: ChatListOptions? - An object of options that can be passed to the method. ``` -------------------------------- ### API: Cancel Pending Keybase Bot Payment Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `cancel` method, which allows a user to cancel a pending XLM payment if the recipient has not yet established a wallet and claimed it. The XLM will be returned to the sender's account. ```APIDOC cancel(transactionId: stellar1.TransactionID): Promise transactionId: The id of the transaction to cancel. ``` -------------------------------- ### List Keybase Team Memberships (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Retrieves a list of all members for a given Keybase team. The method takes an object containing the team name as input. It returns a Promise that resolves to an object containing details about the team and its members. ```javascript bot.team.listTeamMemberships({team: 'phoenix'}).then(res => console.log(res)) ``` -------------------------------- ### API: Wallet Types Collection Source: https://github.com/keybase/keybase-bot/blob/master/README.md Documentation for a collection of data types specifically used within the Keybase bot's Wallet module. ```APIDOC Wallet Types: A collection of types used by the Wallet module. ``` -------------------------------- ### Keybase Bot Chat API: read Method Source: https://github.com/keybase/keybase-bot/blob/master/README.md Documents the `read` method for the Keybase bot's chat API. This method allows reading messages from a specified conversation, with an option to not mark them as read. It requires a channel or conversation ID and returns a `Promise` resolving to a `ReadResult`. ```APIDOC Method: read Description: Reads the messages in a conversation. You can read with or without marking as read. Parameters: - channelOrConversationId: chat1.ChatChannel or chat1.ConvIDStr (The chat conversation to send the message in.) - options: ChatReadOptions? (An object of options that can be passed to the method.) Returns: Promise (A summary of data about a message, including who send it, when, the content of the message, etc. If there are no messages in your channel, then an error is thrown.) ``` -------------------------------- ### Keybase Wallet Lookup API (APIDOC) Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `lookup` method within the Keybase Bot's Wallet module. This method is used to find the primary Stellar account ID associated with a Keybase user or a linked social account. ```APIDOC bot.wallet.lookup(name: string) name: string - The name of the user you want to lookup. This can be either a Keybase username or a username of another account that is supported by Keybase if it is followed by an '@'. ``` -------------------------------- ### Log Error Debug Messages Source: https://github.com/keybase/keybase-bot/blob/master/README.md Writes error text to a designated debug log file, provided the bot was initialized with an adminDebugDirectory. This function is useful for recording error conditions and exceptions. It returns a Promise that resolves after the error text is written. ```APIDOC adminDebugLogError(text: string): Promise text: The string text to log. ``` ```javascript bot.adminDebugLogInfo('My bot is ready to go.') ``` -------------------------------- ### React to Message in Keybase Chat (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Adds a reaction (emoji) to a specific message within a Keybase chat conversation. The message is identified by its message ID, which can be obtained using `bot.chat.read`. The reaction should be provided in colon form (e.g., ':+1:'). It returns a Promise that resolves with a `chat1.SendRes` object. ```APIDOC react(channelOrConversationId: chat1.ChatChannel | chat1.ConvIDStr, messageId: number, reaction: string, options?: ChatReactOptions): Promise channelOrConversationId: The chat conversation to send the message in. messageId: The id of the message to react to. reaction: The reaction emoji, in colon form. options: An object of options that can be passed to the method. ``` ```javascript bot.chat.react(channel, 314, ':+1:').then(() => console.log('Thumbs up!')) ``` -------------------------------- ### Listen for New Chat Messages Across All Channels (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md This function enables the Keybase bot to monitor all chat channels for new messages, passing them to a specified callback. It's designed for bots that need to process every incoming message, allowing for custom responses or logging. The function also notes that it receives messages posted by the bot itself from other devices, which can be filtered out. ```javascript // Reply to incoming traffic on all channels with 'thanks!' const onMessage = message => { const conversationId = message.conversationId bot.chat.send(conversationId, {body: 'thanks!!!'}) } bot.chat.watchAllChannelsForNewMessages(onMessage) ``` -------------------------------- ### Keybase Bot Chat API: send Method Source: https://github.com/keybase/keybase-bot/blob/master/README.md Documents the `send` method for the Keybase bot's chat API. This method is used to send a message to a specified chat conversation. It requires a channel or conversation ID, the message content, and optional `ChatSendOptions`. ```APIDOC Method: send Description: Send a message to a certain conversation. Parameters: - channelOrConversationId: chat1.ChatChannel or chat1.ConvIDStr (The chat conversation to send the message in.) - message: chat1.ChatMessage (The chat message to send.) - options: ChatSendOptions? (An object of options that can be passed to the method.) Returns: Promise ``` -------------------------------- ### Add Members to Keybase Team (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Adds new members to a specified Keybase team. Members can be added via email or Keybase/social usernames, with assigned roles like writer, admin, or reader. This method returns a Promise that resolves to the result of the operation. ```javascript bot.team .addMembers({ team: 'phoenix', emails: [ {email: 'alice@keybase.io', role: 'writer'}, {email: 'cleo@keybase.io', role: 'admin'} ], usernames: [ {username: 'frank', role: 'reader'}, {username: 'keybaseio@twitter', role: 'writer'} ] }) .then(res => console.log(res)) ``` -------------------------------- ### Leave a Keybase Team Chat Channel Source: https://github.com/keybase/keybase-bot/blob/master/README.md Allows the bot to leave a specified team conversation channel. This method requires a chat1.ChatChannel object to identify the channel to be left. It returns a Promise that resolves once the bot has successfully departed the channel. ```APIDOC leaveChannel(channel: chat1.ChatChannel): Promise channel: The team chat channel to leave. ``` ```javascript bot.chat.listConvsOnName('team_name').then(async teamConversations => { for (const conversation of teamConversations) { if (conversation.memberStatus === 'active') { await bot.chat.leave(conversation.channel) console.log('Left team channel', conversation.channel) } } }) ``` -------------------------------- ### Keybase Team removeMember API (APIDOC) Source: https://github.com/keybase/keybase-bot/blob/master/README.md API documentation for the `removeMember` method in the Keybase Bot's Team module. This method removes a specified member from a team. ```APIDOC bot.team.removeMember(removal: RemoveMemberParam) removal: RemoveMemberParam - object with the `team` name and `username` Returns: Promise ``` -------------------------------- ### Clear All Advertised Bot Commands in Keybase Chat Source: https://github.com/keybase/keybase-bot/blob/master/README.md Removes all previously published command advertisements from the Keybase chat autocomplete. This effectively hides the bot's commands from the '!' menu, making them no longer discoverable via the autocomplete feature. ```JavaScript await bot.chat.clearCommands() ``` ```APIDOC clearCommands(advertisement: advertisement parameters): Promise advertisement: advertisement parameters ``` -------------------------------- ### Remove Member from Keybase Team (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Removes a specified member from a Keybase team. This method requires the team name and the username of the member to be removed. It returns a Promise that resolves to void upon successful removal. ```javascript bot.team.removeMember({team: 'phoenix', username: 'frank'}).then(res => console.log(res)) ``` -------------------------------- ### Delete Message in Keybase Chat (JavaScript) Source: https://github.com/keybase/keybase-bot/blob/master/README.md Deletes a specific message from a Keybase chat conversation using its message ID. Message IDs can be found by using `bot.chat.read`. Please note that due to GUI caching, the deletion might not appear immediately in the Keybase client. It returns a Promise that resolves upon successful deletion. ```APIDOC delete(channelOrConversationId: chat1.ChatChannel | chat1.ConvIDStr, messageId: number, options?: ChatDeleteOptions): Promise channelOrConversationId: The chat conversation to send the message in. messageId: The id of the message to delete. options: An object of options that can be passed to the method. ``` ```javascript bot.chat.delete(channel, 314).then(() => console.log('message deleted!')) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.