Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SENDING MESSAGE TO A CHANNEL #310

Open
aledrstudio opened this issue Nov 7, 2023 · 2 comments
Open

SENDING MESSAGE TO A CHANNEL #310

aledrstudio opened this issue Nov 7, 2023 · 2 comments

Comments

@aledrstudio
Copy link

Hii, how can I send a message to a channel when a user click a button?

@aledrstudio
Copy link
Author

aledrstudio commented Nov 7, 2023

` function sendTextToChannel() {
        bot.sendMessage({
            chat_id: '@sviluppo1234',
            text: 'Questo è un messaggio di esempio dal mio bot React.',
        });
    }`
This is my code, but it doesn't work, 'bot' is the instance of the telegram Bot created here:
    `import { UrbanBotTelegram } from '@urban-bot/telegram';
import { render, Root } from '@urban-bot/core';
import dotenv from 'dotenv';
import { App } from '../App';
import PreHome from '../page/PreHome';

dotenv.config();

const { TELEGRAM_TOKEN, PORT } = process.env;

const isDevelopment = process.env.NODE_ENV === 'development';

if (!TELEGRAM_TOKEN) {
    throw new Error('Provide TELEGRAM_TOKEN to .env https://core.telegram.org/bots#6-botfather');
}

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

render(
    <Root bot={urbanBotTelegram} port={PORT ? Number(PORT) : undefined}>
        <PreHome bot={urbanBotTelegram}></PreHome>
    </Root>,
    () => console.log('telegram bot has started'),
);
`

@sergei-zheludkov
Copy link
Collaborator

sergei-zheludkov commented Jan 30, 2024

        chat_id: '@sviluppo1234',

because this isn't chat_id. You tried to pass nickname into the property chat_id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants