我一直在尝试解决这个问题三天,而没有PF我在网上发现的解决方案似乎有效,所以我必须寻求帮助。
我想创建一个电报“小组聊天”,以由我所在的俱乐部成员使用。我创建了带有俱乐部缩写的聊天,例如:“ ABCD”并添加了一些成员。现在,我想自动将偶尔的消息发送给小组以供所有成员查看。天气预报,我们的画廊的随机照片等。
使用@botfather,我创建了一个名为“ Abcdbot”的机器人,并指出了该机器人的令牌。现在,我的浏览器左侧面板上有两个“ ABCD”。选择一个给我“ ABCD bot”,然后选择另一个给我“ ABCD 123成员”。
使用Perl脚本和LWP,我可以使用此作品发送照片
#!/usr/bin/perl -w
use feature 'say';
use LWP;
my $api = LWP::UserAgent->new ();
my $chat_id = '1234567890';
my $photo = '/home/user/gallery/photo999.jpg';
my $response = $api->post(
"https://api.telegram.org/bot<ABCDbot's token>/sendPhoto",
[ 'chat_id' => $chat_id,
'caption' => 'Photo Randomly Selected by the gallery',
'photo' => $photo,
],
'Content_Type' => 'form-data',
);
if ($response->is_success) {
say "Response..... Success!";
} else {
say "Response..... Failure!";
}
,只要我给它一个合法的CHAT_ID和一个合法的文件即可发送。
但是麻烦是:我找不到与123名成员的小组聊天的chat_id !我现在尝试过的每种方法都被证明是过时的,或者根本不会返回ABCD组聊天所需的CHAT_ID。我可以获取自己的聊天ID或小组的个别成员或机器人本身的聊天ID,并且可以成功地将照片,消息等发送给这些目的地,但是我只是无法将任何东西发送给组。
有人可以带我完成我的小组聊天的CANT_ID的过程吗?还是将我引导到描述最新的,工作方法的文档?
协助非常感谢。
I've been trying to solve this for three days and none pf the solutions I've found online seem to work, so I am going to have to ask for help.
I want to create a Telegram "Group Chat" to be used by members of a club I'm in. I created the chat named with the initials of the club, like: "ABCD" and added some members. Now I want to automate the sending of occasional messages to the group for all members to see. Weather forecast, random photograph from our gallery, etc.
Using @BotFather I created a bot called "ABCDbot" and noted the token for that bot. Now I have two "ABCD"s on my browser left side-panel. Selecting one gives me "ABCD bot" and selecting the other gives me "ABCD 123 members".
Using a perl script and LWP I can send a photo using
#!/usr/bin/perl -w
use feature 'say';
use LWP;
my $api = LWP::UserAgent->new ();
my $chat_id = '1234567890';
my $photo = '/home/user/gallery/photo999.jpg';
my $response = $api->post(
"https://api.telegram.org/bot<ABCDbot's token>/sendPhoto",
[ 'chat_id' => $chat_id,
'caption' => 'Photo Randomly Selected by the gallery',
'photo' => $photo,
],
'Content_Type' => 'form-data',
);
if ($response->is_success) {
say "Response..... Success!";
} else {
say "Response..... Failure!";
}
This works, providing I give it a legitimate chat_id and a legitimate file to send.
But the trouble is: I can't find the chat_id for the group chat with 123 members! Every method I've tried now proves to be obsolete or simply doesn't return the desired chat_id for the ABCD group chat. I can get my own chat ID or that of individual members of the group, or of the bot itself, and can successfully send photos, messages, etc to those destinations, but I just can't send anything to the group.
Can anybody walk me through the process of getting the chat_id for my group chat? Or direct me to a document describing an up-to-date, working method for obtaining same?
Assistance much appreciated.
发布评论
评论(4)
方法1( web a )
方法2(私有超级组)
如果聊天是一个私人频道/超级组,则可以执行以下操作:
方法3(第三方机器人)
如果您相信第三方机器人,则其中许多。一个已知的是@missrose_bot 您可以将其添加到您的组并使用其/ID命令。另一个是@usinfobot 仅适用于内联,仅适用于公众聊天。
Method 1 (Web A)
Method 2 (Private Supergroups)
If the chat is a private channel/supergroup, you can do the following:
Method 3 (Third-Party Bots)
If you trust 3rd party bots, there are many of them. A known one is @MissRose_bot which you can add it to your group and use its /id command. Another one is @usinfobot which works inline and only for public chats.
要获取电报组ID,您需要在当您这样做时,请单击该组时,您要获得ID,如果您查看URL,它将说
To get a telegram group ID you need to open the group on https://web.telegram.org/z/ when you do so click on the group you want to gain the ID of then if you look at the URL it will say something like https://web.telegram.org/z/#-1234567 and the numbers there is the ID of the telegram group!
Hope this helps
这是一个简单的电报机器人的Python代码,该机器人打印任何聊天ID。将您的机器人添加到组聊天中,然后发送一条消息在组聊天中 @提及bot。
要创建一个机器人并获取API令牌,请写入
@botfather
。Here's a Python code for a simple Telegram bot that prints any chat ID. Add your bot to the group chat and send a message mentioning the bot by @ in the group chat.
To create a bot and get the API token, write to
@BotFather
.我尝试了上面的安格斯,但没有成功。
获取组聊天的正确聊天ID的唯一方法是将@getMyID_bot添加到兴趣组 ,然后向组发送消息。
答案是用户聊天ID和组的聊天ID。
警告:验证,您将正确的机器人添加到您的组(如上所述的名称完全) - 据我所知,只能在应用程序中区分。
I tried the anwers above but did not succeed.
The only way to get the correct chat id of a group chat was to add @getmyid_bot to the group of interest and then send a message to the group.
The answer is the users chat id and the chat id of the group.
Warning: Verify, that you add the correct bot to your group (name exactly as mentioned above) - which can only be distinguished in the app as far as I know.