TG two-way bot with verification code

Recently, I don’t even know which guy is bored enough to specifically target bots for advertising. That’s how I came across this project: a bidirectional bot with verification.
Project URL: GitHub - iawooo/ctt: 这是一个基于Cloudflare实现的Telegram消息转发机器人,专注于将用户消息安全、高效地转发到后台群组每个用户独立群组中的分话题,直接话题中发送信息而无需再艾特回复,适用于客服、社区管理等场景。

If you don’t like the project content that appears after each verification, you can modify the following.
Open the _worker.js file in your Cloudflare Workers editor and make these changes:

Step 1: Modify the getVerificationSuccessMessage function (remove project promotion)

This function retrieves the message shown after a successful verification, which currently includes project promotion.

Locate the code (around line 588):

JavaScript

async function getVerificationSuccessMessage() {
    const userRawEnabled = (await getSetting('user_raw_enabled', env.D1)) === 'true';
    if (userRawEnabled) return '验证成功!您现在可以与我聊天。';

    const response = await fetch('https://raw.githubusercontent.com/iawooo/ctt/refs/heads/main/CFTeleTrans/start/success.md' );
    if (!response.ok) return '验证成功!您现在可以与我聊天。';
    const message = await response.text();
    return message.trim() || '验证成功!您现在可以与我聊天。';
}

Replace it with the following code (remove remote fetching and return a default welcome message directly):

JavaScript

async function getVerificationSuccessMessage() {
    // Remove the logic that fetches remote promotional information
    // Default to returning a concise verification success message
    return '验证成功!您现在可以与我聊天。';
}

Step 2: Modify the onMessage function (change the final welcome text)

This function handles incoming messages and, when a user sends the /start command and verification succeeds, concatenates the result of getVerificationSuccessMessage with the final welcome text before sending.

Locate the code (around line 415):

JavaScript

// ... (onMessage function body)
const successMessage = await getVerificationSuccessMessage();
await sendMessageToUser(chatId, `${successMessage}\\n你好,欢迎使用私聊机器人,现在发送信息吧!`);
// ...

Replace it with the following code (change the final welcome text to whatever you want, e.g., an empty string):

JavaScript

// ... (onMessage function body)
const successMessage = await getVerificationSuccessMessage();
// Change the final welcome text to whatever you want, e.g., an empty string ""
// If you want to keep “你好,欢迎使用私聊机器人,现在发送信息吧!” you don’t need to modify this line.
await sendMessageToUser(chatId, `${successMessage}\\n`); 
// Or if you want to customize, for example:
// await sendMessageToUser(chatId, `${successMessage}\\n欢迎回来!`);
// ...

Recommended modification:

If you want to completely remove all promotional content and welcome text, sending only a concise prompt after verification, change the onMessage code to:

JavaScript

// ... (onMessage function body)
const successMessage = await getVerificationSuccessMessage();
await sendMessageToUser(chatId, successMessage); // Only send the verification success message, without additional welcome text
// ...
5 Likes

Thanks to the OP for sharing! I haven’t used this bidirectional robot yet! I’ll try to tinker with it!

It’s simple, just follow the tutorial.

1 Like

Just create a channel and start a private chat, that should be fine :xhj21:

If you like simplicity, this is the reason.

1 Like

Thanks to the OP for sharing the tutorial

3 Likes

It doesn’t seem to be needed for now, I’ll bookmark it first.

Take a look and tinker a bit

Thank you for sharing, boss

2 Likes

Thank you for sharing

2 Likes

I can see you every day

2 Likes

Can be seen in every post :xhj21:

Thank you, OP, for enthusiastically sharing the tutorial!

Thanks for sharing, I’ll try it out. :xhj16:

1 Like

It needs to be opened with a server

tg does not mess around

Thank you for sharing, OP. I tried to set it up, but wasn’t successful.

No need, just deploy on CF.

Most of the problems stem from the environment, the bot’s API, and the group chat ID. Check whether any of these variables have extra spaces. I built it myself yesterday and had to do it twice before it succeeded.

Okay, thanks, boss, I’ll redeploy and try again.

1 Like