api.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:py_mbot 作者: evgfilim1 项目源码 文件源码
def ban_member(self, chat, user_id=None, user=None):
        """Bans chat member

        Args:
            chat(int|str): chat ID or '@channel_name'
            user_id(Optional[int]): user ID to be banned
            user(Optional[:class:`telegram.User`]): user to be banned

        Returns:
            bool: ``True`` on success, ``False`` otherwise

        Raises:
            ValueError: if both ``user_id`` and ``user`` were (not) given

        """
        if (user_id is None and user is None) or (user_id is not None and user is not None):
            raise ValueError('Either `user_id` or `user` must be given')
        if user is not None:
            user_id = user.id

        try:
            self._bot.kick_chat_member(chat, user_id)
        except TelegramError as e:
            logger.exception('Exception was raised while kicking member', exc_info=e)
            return False
        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号