Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/297.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用python电报机器人获取用户类型_Python_Telegram_Telegram Bot_Python Telegram Bot - Fatal编程技术网

如何使用python电报机器人获取用户类型

如何使用python电报机器人获取用户类型,python,telegram,telegram-bot,python-telegram-bot,Python,Telegram,Telegram Bot,Python Telegram Bot,我正在为我的bot使用python电报bot。我想知道用户是否是普通用户、频道、机器人或组 例如: user_type = x_func("@practice_english") print(user_type) # User type should be channel here. 什么是x_func可以帮我完成这项任务?你可以使用Bot.get_chat(“@practice_english”)方法,该方法将返回一个。此对象有一个.type属性,如果它是“private

我正在为我的bot使用python电报bot。我想知道用户是否是普通用户、频道、机器人或组

例如:

user_type = x_func("@practice_english")
print(user_type) # User type should be channel here.

什么是x_func可以帮我完成这项任务?

你可以使用Bot.get_chat(“@practice_english”)方法,该方法将返回一个。此对象有一个
.type
属性,如果它是“private”,则该属性可以是“private”、“group”、“supergroup”或“channel”。您可以通过
bot.get\u chat\u member(“@practice\u english”)
进一步检查它是bot还是用户。但您需要一些自定义逻辑。阅读文档。注意,
get\u chat
只接受超级组和频道的用户名。对于普通组和私人聊天,你必须传递聊天id。然后,如果你已经有聊天id,你可以告诉:正面聊天id->用户,负面->组,负面与领先-100->超级组或频道谢谢你们,伙计们!现在我可以得到信息,如果提到的是一个频道或超级组。但是,对于普通用户和bot,我收到了以下错误:
导致错误Chat not found
对于get\u Chat\u成员,它无法为我工作,因为我没有聊天id。我唯一拥有的是用户id(@etc)