从python电报bot中的组获取成员信息

从python电报bot中的组获取成员信息,python,telegram-bot,python-telegram-bot,Python,Telegram Bot,Python Telegram Bot,我正在使用python编写电报机器人的部分代码: def ok(bot,update): print update.message handler = MessageHandler(Filters.all,ok) updater.dispatcher.add_handler(handler) updater.start_polling() updater.idle() 当我被直接发送一个pm到我的机器人时,我可以打印成员用户名: print update.message["cha

我正在使用python编写电报机器人的部分代码:

def ok(bot,update):
    print update.message


handler = MessageHandler(Filters.all,ok)
updater.dispatcher.add_handler(handler)

updater.start_polling()
updater.idle()
当我被直接发送一个pm到我的机器人时,我可以打印成员用户名:

print update.message["chat"]["username"]
结果:

print update.message
打印更新消息

当直接向robot发送消息时:

{'delete_chat_photo': False, 'new_chat_photo': [], 'from': {'username': u'un_detectable', 'first_name': u'Sina \U0001f3a9', 'is_bot': False, 'id': 207541477, 'language_code': u'en-US'}, 'text': u'salaaam', 'entities': [], 'channel_chat_created': False, 'new_chat_members': [], 'supergroup_chat_created': False, 'chat': {'username': u'un_detectable', 'first_name': u'Sina \U0001f3a9', 'type': u'private', 'id': 207541477}, 'photo': [], 'date': 1505902164, 'group_chat_created': False, 'message_id': 297, 'new_chat_member': None}
在聊天区用户名是存在的,正如我所说的,可以打印出来

但当我被派到一个下午在组(我的机器人perm是管理员)我不能访问成员用户名

结果:

print update.message
在聊天组中发送消息时:

{'delete_chat_photo': False, 'new_chat_photo': [], 'from': {'username': u'un_detectable', 'first_name': u'Sina \U0001f3a9', 'is_bot': False, 'id': 207541477, 'language_code': u'en-US'}, 'text': u'salaaaam', 'entities': [], 'channel_chat_created': False, 'new_chat_members': [], 'supergroup_chat_created': False, 'chat': {'type': u'supergroup', 'id': -1001139540291L, 'title': u'test'}, 'photo': [], 'date': 1505902183, 'group_chat_created': False, 'message_id': 201, 'new_chat_member': None}
在聊天字段中,用户名不存在 我想在其中一个成员在组中编写消息时,将我的bot-him消息+用户名保存在数据库中 但我无法访问组成员的用户名!
有人能帮我吗?

您的群组需要一个像
@AwesomeTeleBot
这样的公共链接,它可以由创建者在编辑群组中进行配置。

在私人消息中,
聊天
等于
用户
,这就是为什么您可以看到
聊天
用户名
,以及
来自用户
字段的原因


在群组中,
chat
指群组,
from\u user
指发送消息的用户。如果你想记录用户的用户名,你应该在
update.message.from_user.username

中找到它们。为什么我在编辑组字段中没有这个选项?只是,删除组存在我的意思是聊天组不是频道,只有频道才是私有或公共的。你需要升级到超级组,此功能在普通组中不可用。