Skip to content

Commit

Permalink
Merge pull request #38 from gunyu1019/develop
Browse files Browse the repository at this point in the history
[Deploy] Bump-up to v1.1.1
  • Loading branch information
gunyu1019 authored Jan 11, 2025
2 parents b15cb63 + 422deeb commit 343ed09
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 7 deletions.
4 changes: 2 additions & 2 deletions chzzkpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
__author__ = "gunyu1019"
__license__ = "MIT"
__copyright__ = "Copyright 2024-present gunyu1019"
__version__ = "1.1.0" # version_info.to_string()
__version__ = "1.1.1" # version_info.to_string()


class VersionInfo(NamedTuple):
Expand All @@ -58,5 +58,5 @@ def to_string(self) -> str:


version_info: VersionInfo = VersionInfo(
major=1, minor=1, micro=0, release_level=None, serial=0
major=1, minor=1, micro=1, release_level=None, serial=0
)
1 change: 1 addition & 0 deletions chzzkpy/chat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
ChatDonation,
VideoDonation,
MissionDonation,
MissionParticipationDonation,
)
from .enums import ChatType, ChatCmd
from .error import *
Expand Down
30 changes: 28 additions & 2 deletions chzzkpy/chat/donation.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class BaseDonation(ChzzkModel):
donation_type: str
weekly_rank_list: Optional[list[DonationRank]] = Field(default_factory=list)
donation_user_weekly_rank: Optional[DonationRank] = None
verified_mark: Optional[bool] = False


class ChatDonation(BaseDonation):
Expand All @@ -58,14 +59,39 @@ class VideoDonation(BaseDonation):

class MissionDonation(BaseDonation):
donation_type: Literal["MISSION"]
duration_time: int = 0
mission_donation_id: Optional[str] = None
mission_donation_type: Optional[str] = None # ALONE ?
mission_donation_type: Optional[str] = None # ALONE
mission_text: str
total_pay_amount: int

donation_id: Optional[str] # ???
participation_count: int

user_id_hash: str
nickname: str

mission_created_time: datetime.datetime
mission_start_time: Optional[datetime.datetime] = None
mission_end_time: Optional[datetime.datetime] = None
duration_time: int = 0

status: str | Literal["PENDING", "REJECTED", "APPROVED", "COMPLETED"] = None
success: bool = False


class MissionParticipationDonation(BaseDonation):
donation_type: Literal["MISSION_PARTICIPATION"]
mission_donation_id: str
mission_donation_type: str # PARTICIPATION
mission_text: str
total_pay_amount: int

related_mission_donation_id: str
donation_id: Optional[str] # ???
participation_count: int

user_id_hash: str
nickname: str

status: str | Literal["PENDING", "REJECTED", "APPROVED", "COMPLETED"] = None
success: bool = False
15 changes: 13 additions & 2 deletions chzzkpy/chat/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@
from typing import Optional, Literal, TypeVar, Generic, TYPE_CHECKING, Any
from pydantic import AliasChoices, Field, Json, ConfigDict, PrivateAttr

from .donation import BaseDonation, ChatDonation, VideoDonation, MissionDonation
from .donation import (
BaseDonation,
ChatDonation,
VideoDonation,
MissionDonation,
MissionParticipationDonation,
)
from .enums import ChatType
from .profile import Profile
from ..base_model import ChzzkModel
Expand Down Expand Up @@ -172,7 +178,12 @@ class MissionDonationExtra(MissionDonation):


class DonationMessage(
MessageDetail[ChatDonationExtra | VideoDonationExtra | MissionDonationExtra]
MessageDetail[
ChatDonationExtra
| VideoDonationExtra
| MissionDonationExtra
| MissionParticipationDonation
]
):
pass

Expand Down
5 changes: 4 additions & 1 deletion chzzkpy/chat/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from typing import Callable, Any, TYPE_CHECKING, Optional

from .blind import Blind
from .donation import MissionDonation
from .donation import MissionDonation, MissionParticipationDonation
from .enums import ChatCmd, ChatType, get_enum
from .message import (
ChatMessage,
Expand Down Expand Up @@ -179,4 +179,7 @@ def parse_event(self, data: dict[str, Any]): # For mission donation handler
self.dispatch("mission_approved", validated_data)
elif validated_data.status == "REJECTED":
self.dispatch("mission_rejected", validated_data)
elif event_type == "DONATION_MISSION_PARTICIPATION":
validated_data = MissionParticipationDonation.model_validate(data)
self.dispatch("mission_update_cost", validated_data)
return

0 comments on commit 343ed09

Please sign in to comment.