UrbanBotSlack
Urban bot part which is responsible to launch slack bot.
Install
npm i @urban-bot/slack --save
yarn add @urban-bot/slack
Usage
import { render, Root, Text } from '@urban-bot/core';
import { UrbanBotSlack } from '@urban-bot/slack';
const urbanBotSlack = new UrbanBotSlack({
signingSecret: 'signingSecret',
token: 'token',
});
render(
<Root bot={urbanBotSlack}>
<Text>Hello, Slack!</Text>
</Root>,
);
Options
signingSecret
A slack signingSecret. You can get it from https://api.slack.com/apps/<YOUR_APP_ID>/general.
required
string
const urbanBotSlack = new UrbanBotSlack({
signingSecret: '6e7cf4e2fen267af5810e3a34gfcb254',
});
token
A slack token. You can get it from https://api.slack.com/apps/<YOUR_APP_ID>/oauth.
required
string
const urbanBotSlack = new UrbanBotSlack({
token: 'xoxb-1034561432512-1264285621449-nadENxhBj2BfrMkxJ90cqbuz',
});
Bot Instance
You could get bot instance by useBotContext
.
function SomeComponent() {
const { bot } = useBotContext();
// ...
}
type
Bot type.
required
'SLACK'
client
A client which you can use for call any Slack API.
required
function SomeComponent() {
const { bot } = useBotContext();
useText(({ text, chat, from }) => {
if (text.includes('Fu**')) {
bot.client.conversations.kick({
channel: chat.id,
user: from.id,
});
}
});
// ...
}