简体   繁体   English

Telegram Bot 向机器人发送消息

[英]Telegram Bot send Message to bot

I have programmed a telegram bot.我已经编写了一个电报机器人。 This works fine when sending to groups or to users.这在发送给组或用户时效果很好。 However I do a special requirement.但是我有一个特殊的要求。 I need to be able to send to another bot.我需要能够发送到另一个机器人。 When adding both bots to a group as administrators.将两个机器人作为管理员添加到组时。 I still cannot receive the message with my second bot.我的第二个机器人仍然无法收到消息。 I only see it with my real user account, that is added to this group.我只能通过添加到该组的真实用户帐户看到它。 What am I missing?我错过了什么? I used OKHttp to send the message我使用 OKHttp 发送消息

            Request request = new Request.Builder()
                .url("https://api.telegram.org/bot"+telSetup.getToken()+"/sendMessage?chat_id="+lAdr+"&parse_mode=HTML&text="+strMessage)
                .build();
            client.newCall(request).enqueue(new MyIPProcessing(request.toString()));

and

        if (response.message().equals("OK")){
            List <String> lStr=response.request().url().encodedPathSegments(); 

... ...

to receive messages... which basically works for communication with "real users".接收消息......这基本上适用于与“真实用户”的沟通。

Any ideas welcome....欢迎任何想法....

According to Bots FAQ根据机器人常见问题解答

Bots talking to each other could potentially get stuck in unwelcome loops.机器人相互交谈可能会陷入不受欢迎的循环。
To avoid this, we decided that bots will not be able to see messages from other bots regardless of mode.为避免这种情况,我们决定无论模式如何,机器人都将无法看到来自其他机器人的消息。

You can connect 2 (or more) bots with a private channel!您可以通过私人频道连接 2 个(或更多)机器人!

Just prompt the bots as admin in the channel.只需在频道中提示机器人为管理员即可。

Then when a bot send a post to the channel, other admin bots can see the message/file/...然后当机器人向频道发送帖子时,其他管理员机器人可以看到消息/文件/...

Bot wouldn't be able to send message to other bots.机器人将无法向其他机器人发送消息。 in most platform APIs it return an error.在大多数平台 API 中,它会返回错误。 kindly go through the documentation for the client(bot) and see its functionalities请通过客户端(机器人)的文档 go 并查看其功能

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM