【问题标题】:Aiogram send_message: OSError: [Errno 22] Invalid argumentAiogram send_message: OSError: [Errno 22] Invalid argument
【发布时间】:2020-12-18 08:05:03
【问题描述】:

我做了一个小机器人,在启动过程中遇到了一个错误"[Errno 22] Invalid argument ",这里有一段代码,因为它发生了:

@dp.message_handler()
async def echo_message(message: types.Message):
    member = await bot.get_chat_member(GROUP_ID, message.from_user.id)
    if member:
        await bot.send_message(message.chat.id, member)
    else:
        await bot.send_message(message.chat.id, str('Sorry !'))

“if”行运行良好,“else”行发送错误

【问题讨论】:

    标签: python-3.x telegram-bot


    【解决方案1】:

    正如 drforse 所说,您可以像这样修复它: github issue

    class DateTimeField(Field):
        """
        In this field st_ored datetime
    
        in: unixtime
        out: datetime
        """
    
        def serialize(self, value: datetime.datetime):
            print(value)
            if os.name == 'nt':
                timestamp = (value - datetime.datetime(1970, 1, 1)).total_seconds()
            else:
                timestamp = value.timestamp()
    
            return round(timestamp)
    
        def deserialize(self, value, parent=None):
            return datetime.datetime.fromtimestamp(value)
    

    【讨论】:

      猜你喜欢
      • 2020-04-07
      • 1970-01-01
      • 2020-07-29
      • 2019-06-29
      • 2018-06-15
      • 1970-01-01
      • 2021-08-26
      • 2018-12-02
      • 1970-01-01
      相关资源
      最近更新 更多