• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python telegram.User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中telegram.User的典型用法代码示例。如果您正苦于以下问题:Python User类的具体用法?Python User怎么用?Python User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: de_json

    def de_json(cls, data, bot):
        if not data:
            return None

        data = super(Message, cls).de_json(data, bot)

        data['from_user'] = User.de_json(data.get('from'), bot)
        data['date'] = from_timestamp(data['date'])
        data['chat'] = Chat.de_json(data.get('chat'), bot)
        data['entities'] = MessageEntity.de_list(data.get('entities'), bot)
        data['forward_from'] = User.de_json(data.get('forward_from'), bot)
        data['forward_from_chat'] = Chat.de_json(data.get('forward_from_chat'), bot)
        data['forward_date'] = from_timestamp(data.get('forward_date'))
        data['reply_to_message'] = Message.de_json(data.get('reply_to_message'), bot)
        data['edit_date'] = from_timestamp(data.get('edit_date'))
        data['audio'] = Audio.de_json(data.get('audio'), bot)
        data['document'] = Document.de_json(data.get('document'), bot)
        data['game'] = Game.de_json(data.get('game'), bot)
        data['photo'] = PhotoSize.de_list(data.get('photo'), bot)
        data['sticker'] = Sticker.de_json(data.get('sticker'), bot)
        data['video'] = Video.de_json(data.get('video'), bot)
        data['voice'] = Voice.de_json(data.get('voice'), bot)
        data['video_note'] = VideoNote.de_json(data.get('video_note'), bot)
        data['contact'] = Contact.de_json(data.get('contact'), bot)
        data['location'] = Location.de_json(data.get('location'), bot)
        data['venue'] = Venue.de_json(data.get('venue'), bot)
        data['new_chat_member'] = User.de_json(data.get('new_chat_member'), bot)
        data['new_chat_members'] = User.de_list(data.get('new_chat_members'), bot)
        data['left_chat_member'] = User.de_json(data.get('left_chat_member'), bot)
        data['new_chat_photo'] = PhotoSize.de_list(data.get('new_chat_photo'), bot)
        data['pinned_message'] = Message.de_json(data.get('pinned_message'), bot)
        data['invoice'] = Invoice.de_json(data.get('invoice'), bot)
        data['successful_payment'] = SuccessfulPayment.de_json(data.get('successful_payment'), bot)

        return cls(bot=bot, **data)
开发者ID:noam09,项目名称:deluge-telegramer,代码行数:35,代码来源:message.py


示例2: de_json

    def de_json(data):
        """
        Args:
            data (dict):

        Returns:
            telegram.Message:
        """
        if not data:
            return None

        data['from_user'] = User.de_json(data.get('from'))
        data['date'] = datetime.fromtimestamp(data['date'])
        data['chat'] = Chat.de_json(data.get('chat'))
        data['entities'] = MessageEntity.de_list(data.get('entities'))
        data['forward_from'] = User.de_json(data.get('forward_from'))
        data['forward_date'] = Message._fromtimestamp(data.get('forward_date'))
        data['reply_to_message'] = \
            Message.de_json(data.get('reply_to_message'))
        data['audio'] = Audio.de_json(data.get('audio'))
        data['document'] = Document.de_json(data.get('document'))
        data['photo'] = PhotoSize.de_list(data.get('photo'))
        data['sticker'] = Sticker.de_json(data.get('sticker'))
        data['video'] = Video.de_json(data.get('video'))
        data['voice'] = Voice.de_json(data.get('voice'))
        data['contact'] = Contact.de_json(data.get('contact'))
        data['location'] = Location.de_json(data.get('location'))
        data['venue'] = Venue.de_json(data.get('venue'))
        data['new_chat_member'] = User.de_json(data.get('new_chat_member'))
        data['left_chat_member'] = User.de_json(data.get('left_chat_member'))
        data['new_chat_photo'] = PhotoSize.de_list(data.get('new_chat_photo'))
        data['pinned_message'] = Message.de_json(data.get('pinned_message'))

        return Message(**data)
开发者ID:AlexR1712,项目名称:python-telegram-bot,代码行数:34,代码来源:message.py


示例3: de_json

    def de_json(data):
        """
        Args:
            data (str):

        Returns:
            telegram.Message:
        """
        if not data:
            return None

        data['from_user'] = User.de_json(data.get('from'))
        data['date'] = datetime.fromtimestamp(data['date'])
        if 'first_name' in data.get('chat', ''):
            data['chat'] = User.de_json(data.get('chat'))
        elif 'title' in data.get('chat', ''):
            data['chat'] = GroupChat.de_json(data.get('chat'))
        data['forward_from'] = \
            User.de_json(data.get('forward_from'))
        data['forward_date'] = \
            Message._fromtimestamp(data.get('forward_date'))
        data['reply_to_message'] = \
            Message.de_json(data.get('reply_to_message'))
        data['audio'] = \
            Audio.de_json(data.get('audio'))
        data['document'] = \
            Document.de_json(data.get('document'))
        data['photo'] = \
            PhotoSize.de_list(data.get('photo'))
        data['sticker'] = \
            Sticker.de_json(data.get('sticker'))
        data['video'] = \
            Video.de_json(data.get('video'))
        data['voice'] = \
            Voice.de_json(data.get('voice'))
        data['contact'] = \
            Contact.de_json(data.get('contact'))
        data['location'] = \
            Location.de_json(data.get('location'))
        data['new_chat_participant'] = \
            User.de_json(data.get('new_chat_participant'))
        data['left_chat_participant'] = \
            User.de_json(data.get('left_chat_participant'))
        data['new_chat_photo'] = \
            PhotoSize.de_list(data.get('new_chat_photo'))

        return Message(**data)
开发者ID:SalamiArmy,项目名称:hitagibot,代码行数:47,代码来源:message.py


示例4: de_json

    def de_json(data):
        if not data:
            return None

        data['from_user'] = User.de_json(data.get('from'))
        data['message'] = Message.de_json(data.get('message'))

        return CallbackQuery(**data)
开发者ID:AlexR1712,项目名称:python-telegram-bot,代码行数:8,代码来源:callbackquery.py


示例5: de_json

    def de_json(cls, data, bot):
        data = super(MessageEntity, cls).de_json(data, bot)

        if not data:
            return None

        data['user'] = User.de_json(data.get('user'), bot)

        return cls(**data)
开发者ID:hobbit19,项目名称:python-telegram-bot,代码行数:9,代码来源:messageentity.py


示例6: de_json

    def de_json(cls, data, bot):
        if not data:
            return None

        data = super(GameHighScore, cls).de_json(data, bot)

        data['user'] = User.de_json(data.get('user'), bot)

        return cls(**data)
开发者ID:hobbit19,项目名称:python-telegram-bot,代码行数:9,代码来源:gamehighscore.py


示例7: test_de_json

    def test_de_json(self, json_dict, bot):
        user = User.de_json(json_dict, bot)

        assert user.id == self.id
        assert user.is_bot == self.is_bot
        assert user.first_name == self.first_name
        assert user.last_name == self.last_name
        assert user.username == self.username
        assert user.language_code == self.language_code
开发者ID:ferisystem,项目名称:python-telegram-bot,代码行数:9,代码来源:test_user.py


示例8: de_json

    def de_json(cls, data, bot):
        if not data:
            return None

        data = super(ChatMember, cls).de_json(data, bot)

        data['user'] = User.de_json(data.get('user'), bot)
        data['until_date'] = from_timestamp(data.get('until_date', None))

        return cls(**data)
开发者ID:hobbit19,项目名称:python-telegram-bot,代码行数:10,代码来源:chatmember.py


示例9: de_json

    def de_json(cls, data, bot):
        if not data:
            return None

        data = super(CallbackQuery, cls).de_json(data, bot)

        data['from_user'] = User.de_json(data.get('from'), bot)
        data['message'] = Message.de_json(data.get('message'), bot)

        return cls(bot=bot, **data)
开发者ID:noam09,项目名称:deluge-telegramer,代码行数:10,代码来源:callbackquery.py


示例10: de_json

    def de_json(cls, data, bot):
        if not data:
            return None

        data = super(PreCheckoutQuery, cls).de_json(data, bot)

        data['from_user'] = User.de_json(data.pop('from'), bot)
        data['order_info'] = OrderInfo.de_json(data.get('order_info'), bot)

        return cls(**data)
开发者ID:noam09,项目名称:deluge-telegramer,代码行数:10,代码来源:precheckoutquery.py


示例11: de_json

    def de_json(cls, data, bot):
        if not data:
            return None

        data = super(ShippingQuery, cls).de_json(data, bot)

        data['from_user'] = User.de_json(data.pop('from'), bot)
        data['shipping_address'] = ShippingAddress.de_json(data.get('shipping_address'), bot)

        return cls(**data)
开发者ID:technoekat,项目名称:prodeda1,代码行数:10,代码来源:shippingquery.py


示例12: de_json

    def de_json(cls, data, bot):
        data = super(InlineQuery, cls).de_json(data, bot)

        if not data:
            return None

        data['from_user'] = User.de_json(data.get('from'), bot)
        data['location'] = Location.de_json(data.get('location'), bot)

        return cls(bot=bot, **data)
开发者ID:technoekat,项目名称:prodeda1,代码行数:10,代码来源:inlinequery.py


示例13: test_de_json_without_username

    def test_de_json_without_username(self, json_dict, bot):
        del json_dict['username']

        user = User.de_json(json_dict, bot)

        assert user.id == self.id
        assert user.is_bot == self.is_bot
        assert user.first_name == self.first_name
        assert user.last_name == self.last_name
        assert user.username is None
        assert user.language_code == self.language_code
开发者ID:ferisystem,项目名称:python-telegram-bot,代码行数:11,代码来源:test_user.py


示例14: de_json

    def de_json(cls, data, bot):
        if not data:
            return None

        data = super(ChosenInlineResult, cls).de_json(data, bot)
        # Required
        data['from_user'] = User.de_json(data.pop('from'), bot)
        # Optionals
        data['location'] = Location.de_json(data.get('location'), bot)

        return cls(**data)
开发者ID:hobbit19,项目名称:python-telegram-bot,代码行数:11,代码来源:choseninlineresult.py


示例15: getMe

    def getMe(self):
        """A simple method for testing your bot's auth token.

        Returns:
          A telegram.User instance representing that bot if the
          credentials are valid, None otherwise.
        """
        url = "%s/getMe" % (self.base_url)

        json_data = self._requestUrl(url, "GET")
        data = self._parseAndCheckTelegram(json_data.decode())

        return User.de_json(data)
开发者ID:kalloc,项目名称:python-telegram-bot,代码行数:13,代码来源:bot.py


示例16: getMe

    def getMe(self):
        """A simple method for testing your bot's auth token.

        Returns:
          A telegram.User instance representing that bot if the
          credentials are valid, None otherwise.
        """
        url = '%s/getMe' % self.base_url

        result = request.get(url)

        self.bot = User.de_json(result)

        return self.bot
开发者ID:peczony,项目名称:python-telegram-bot,代码行数:14,代码来源:bot.py


示例17: de_json

    def de_json(data):
        """
        Args:
            data (dict):

        Returns:
            telegram.ChatMember:
        """
        if not data:
            return None

        data['user'] = User.de_json(data.get('user'))

        return ChatMember(**data)
开发者ID:9kopb,项目名称:python-telegram-bot,代码行数:14,代码来源:chatmember.py


示例18: de_json

    def de_json(data):
        """
        Args:
            data (dict):

        Returns:
            telegram.ChosenInlineResult:
        """
        if not data:
            return None
        data = data.copy()
        data['from_user'] = User.de_json(data.pop('from'))

        return ChosenInlineResult(**data)
开发者ID:BoSicle,项目名称:python-telegram-bot,代码行数:14,代码来源:choseninlineresult.py


示例19: de_json

    def de_json(data):
        """
        Args:
            data (dict):

        Returns:
            telegram.InlineQuery:
        """
        if not data:
            return None
        data = data.copy()
        data['from_user'] = User.de_json(data.pop('from'))

        return InlineQuery(**data)
开发者ID:BoSicle,项目名称:python-telegram-bot,代码行数:14,代码来源:inlinequery.py


示例20: de_json

    def de_json(data, bot):
        """
        Args:
            data (dict):
            bot (telegram.Bot):

        Returns:
            telegram.ChatMember:
        """
        if not data:
            return None

        data["user"] = User.de_json(data.get("user"), bot)

        return ChatMember(**data)
开发者ID:matibarriento,项目名称:python-telegram-bot,代码行数:15,代码来源:chatmember.py



注:本文中的telegram.User类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ext.Filters类代码示例发布时间:2022-05-27
下一篇:
Python telegram.Updater类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap