Skip to content

Commit

Permalink
fix #42
Browse files Browse the repository at this point in the history
  • Loading branch information
Wybxc committed Jul 20, 2022
1 parent 25c64ad commit fbdafe1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions mirai/models/message/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime
from enum import Enum
from pathlib import Path
from typing import List, Optional, Union
from typing import List, Optional, Union, cast

from pydantic import HttpUrl, validator

Expand Down Expand Up @@ -55,11 +55,12 @@ class Face(MessageComponent):
def __init__(self, *args, **kwargs):
if len(args) == 1:
if isinstance(args[0], str):
self.name = args[0]
kwargs['name'] = args[0]
elif isinstance(args[0], int):
self.face_id = args[0]
kwargs['faceId'] = args[0]
super().__init__(**kwargs)
super().__init__(*args, **kwargs)
else:
super().__init__(*args, **kwargs)

def __eq__(self, other):
return isinstance(other, Face) and \
Expand Down Expand Up @@ -194,7 +195,7 @@ async def from_local(
else:
raise ValueError("请指定图片路径或图片内容!")
import base64
img = cls(base64=base64.b64encode(content).decode())
img = cls(base64=base64.b64encode(cast(bytes, content)).decode())
return img

@classmethod
Expand Down Expand Up @@ -462,7 +463,7 @@ async def from_local(
else:
raise ValueError("请指定语音路径或语音内容!")
import base64
img = cls(base64=base64.b64encode(content).decode())
img = cls(base64=base64.b64encode(cast(bytes, content)).decode())
return img


Expand Down

0 comments on commit fbdafe1

Please sign in to comment.