Example #1
0
def refine_at_group_msg(ctx: GroupMsg) -> _AtGroupMsg:
    """群回复消息"""
    if not isinstance(ctx, GroupMsg):
        raise InvalidContextError('Expected `GroupMsg`, but got `%s`' % ctx.__class__)
    if ctx.MsgType == MsgTypes.AtMsg:
        return _AtGroupMsg(ctx)
    return None
Example #2
0
def refine_pic_group_msg(ctx: GroupMsg) -> _PicGroupMsg:
    """群图片/表情包消息"""
    if not isinstance(ctx, GroupMsg):
        raise InvalidContextError('Expected `GroupMsg`, but got `%s`' % ctx.__class__)
    if ctx.MsgType == MsgTypes.PicMsg:
        return _PicGroupMsg(ctx)
    return None
Example #3
0
def refine_reply_group_msg(ctx: GroupMsg) -> _ReplyGroupMsg:
    """群回复消息"""
    if not isinstance(ctx, GroupMsg):
        raise InvalidContextError('Expected `GroupMsg`, but got `%s`' % ctx.__class__)
    if ctx.MsgType in (MsgTypes.ReplyMsg, MsgTypes.ReplyMsgA):  # Workaround for naming errors
        return _ReplyGroupMsg(ctx)
    return None
Example #4
0
def refine_file_friend_msg(ctx: FriendMsg) -> _FriendFileMsg:
    """好友文件消息"""
    if not isinstance(ctx, FriendMsg):
        raise InvalidContextError('Expected `FriendMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.MsgType == MsgTypes.FriendFileMsg:
        return _FriendFileMsg(ctx)
    return None
Example #5
0
def refine_reply_friend_msg(ctx: FriendMsg) -> _ReplyFriendMsg:
    """好友回复消息"""
    if not isinstance(ctx, FriendMsg):
        raise InvalidContextError('Expected `FriendMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.MsgType in (MsgTypes.ReplyMsg, MsgTypes.ReplyMsgA):
        return _ReplyFriendMsg(ctx)
    return None
Example #6
0
def refine_RedBag_friend_msg(ctx: FriendMsg) -> _RedBagFriendMsg:
    """好友红包消息"""
    if not isinstance(ctx, FriendMsg):
        raise InvalidContextError('Expected `FriendMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.MsgType == MsgTypes.RedBagMsg:
        return _RedBagFriendMsg(ctx)
    return None
Example #7
0
def refine_pic_friend_msg(ctx: FriendMsg) -> _PicFriendMsg:
    """好友图片/表情包消息"""
    if not isinstance(ctx, FriendMsg):
        raise InvalidContextError('Expected `FriendMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.MsgType == MsgTypes.PicMsg:
        return _PicFriendMsg(ctx)
    return None
Example #8
0
def refine_video_friend_msg(ctx: FriendMsg) -> _VideoFriendMsg:
    """好友视频消息"""
    if not isinstance(ctx, FriendMsg):
        raise InvalidContextError('Expected `FriendMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.MsgType == MsgTypes.VideoMsg:
        return _VideoFriendMsg(ctx)
    return None
Example #9
0
def refine_group_admin_event_msg(ctx: EventMsg) -> _GroupAdminEventMsg:
    """管理员变更事件"""
    if not isinstance(ctx, EventMsg):
        raise InvalidContextError('Expected `EventMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.EventName == EventNames.ON_EVENT_GROUP_ADMIN:
        return _GroupAdminEventMsg(ctx)
    return None
Example #10
0
def refine_group_shut_event_msg(ctx: EventMsg) -> _GroupShutEventMsg:
    """群禁言事件"""
    if not isinstance(ctx, EventMsg):
        raise InvalidContextError('Expected `EventMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.EventName == EventNames.ON_EVENT_GROUP_SHUT:
        return _GroupShutEventMsg(ctx)
    return None
Example #11
0
def refine_friend_delete_event_msg(ctx: EventMsg) -> _FriendDeleteEventMsg:
    """删除好友事件"""
    if not isinstance(ctx, EventMsg):
        raise InvalidContextError('Expected `EventMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.EventName == EventNames.ON_EVENT_FRIEND_DELETE:
        return _FriendDeleteEventMsg(ctx)
    return None
Example #12
0
def refine_friend_revoke_event_msg(ctx: EventMsg) -> _FriendRevokeEventMsg:
    """好友撤回消息事件"""
    if not isinstance(ctx, EventMsg):
        raise InvalidContextError('Expected `EventMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.EventName == EventNames.ON_EVENT_FRIEND_REVOKE:
        return _FriendRevokeEventMsg(ctx)
    return None
Example #13
0
def refine_group_revoke_event_msg(ctx: EventMsg) -> _GroupRevokeEventMsg:
    """群成员撤回消息事件"""
    if not isinstance(ctx, EventMsg):
        raise InvalidContextError('Expected `EventMsg`, but got `%s`' %
                                  ctx.__class__)
    if ctx.EventName == EventNames.ON_EVENT_GROUP_REVOKE:
        return _GroupRevokeEventMsg(ctx)
    return None