Urban Bot

Urban Bot

  • Docs
  • GitHub

›Bots

Getting Started

  • Intro
  • Telegram

Tutorials

  • Todo List

API

  • Components
  • Hooks
  • Bots

    • Telegram
    • Discord
    • Facebook
    • Slack

UrbanBotTelegram

Urban bot part which is responsible to launch telegram bot.

Install

npm i @urban-bot/telegram --save
yarn add @urban-bot/telegram

Usage

import { render, Root, Text } from '@urban-bot/core';
import { UrbanBotTelegram } from '@urban-bot/telegram';

const urbanBotTelegram = new UrbanBotTelegram({
    token: 'telegramToken',
});

render(
    <Root bot={urbanBotTelegram}>
        <Text>Hello, Telegram!</Text>
    </Root>,
);

Options

token

A telegram token. You can get it from @BotFather.

required

string

const urbanBotTelegram = new UrbanBotTelegram({
    token: '323452248:YYHG68zEKHl2NWQ5c_y1l9blh5wXmn385u4',
});

isPolling

Enabling long polling.

optional
default false

boolean

const urbanBotTelegram = new UrbanBotTelegram({
    isPolling: true,
});

Bot Instance

You could get bot instance by useBotContext.

function SomeComponent() {
    const { bot } = useBotContext();

    // ...
}

type

Bot type.

required

'TELEGRAM'

client

A client which you can use for call any Telegram API.

required

node-telegram-bot-api

function SomeComponent() {
    const { bot } = useBotContext();
    
    useText(({ text, chat, from }) => {
        if (text.includes('Fu**')) {
            bot.client.kickChatMember(chat.id, from.id);
        }
    });

    // ...
}
← HooksDiscord →
  • Options
  • Bot Instance
Docs
Get StartedComponentsHooksTelegramDiscordFacebookSlack
Community
Telegram
Links
Urban Bot
Copyright © 2022 German Smirnov and Ivan Pakhotin