简体   繁体   English

如何在电报机器人 python 中获取其他聊天组中的频道名称?

[英]How to get name of the channel in other's chat group in telegram bot python?

I'am trying to get the name of the channel that sending message into other channel's chat.我正在尝试获取将消息发送到其他频道聊天的频道的名称。 For example: I have channel named Cat and Cat chat;例如:我有一个频道叫猫猫聊天; also I have a channel Dog.我也有一个频道Dog。 I've send the message using Dog into Cat chat and I wanna to get name Dog into variable.我已经使用 Dog 将消息发送到 Cat 聊天中,并且我想将名字 Dog 放入变量中。 I've tried message.from_user.username and message.from_user.first_name but it printed Channel_bot and Channel.我试过message.from_user.usernamemessage.from_user.first_name但它打印了 Channel_bot 和 Channel。 There is example of other channel commenting in my chat我的聊天中有其他频道评论的例子

So nickname "gdfgd" should be saved in variable.所以昵称“gdfgd”应该保存在变量中。 Is there any method that doing it?有什么方法可以做到吗? I'm using python and aiogram.我正在使用 python 和 aiogram。

https://core.telegram.org/bots/api#chat https://core.telegram.org/bots/api#chat

I think you need a key 'message.chat.title'我认为你需要一个关键的'message.chat.title'

I found method message.sender_chat.title that prints what i wanted!我发现方法message.sender_chat.title打印出我想要的!

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

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