import { Chip } from '@heroui/chip' import { getNoticeTypeName } from '@/utils/onebot' import { OB11Notice, OB11NoticeType, OneBot11FriendAdd, OneBot11FriendRecall, OneBot11GroupAdmin, OneBot11GroupBan, OneBot11GroupCard, OneBot11GroupDecrease, OneBot11GroupEssence, OneBot11GroupIncrease, OneBot11GroupMessageReaction, OneBot11GroupRecall, OneBot11GroupUpload, OneBot11Honor, OneBot11LuckyKing, OneBot11Poke } from '@/types/onebot' export interface OneBotNoticeProps { data: OB11Notice } export interface NoticeProps { data: T } const GroupUploadNotice: React.FC> = ({ data }) => { const { group_id, user_id, file } = data return ( <>
群号: {group_id}
用户ID: {user_id}
文件名: {file.name}
文件大小: {file.size} 字节
) } const GroupAdminNotice: React.FC> = ({ data }) => { const { group_id, user_id, sub_type } = data return ( <>
群号: {group_id}
用户ID: {user_id}
变动类型: {sub_type === 'set' ? '设置管理员' : '取消管理员'}
) } const GroupDecreaseNotice: React.FC> = ({ data }) => { const { group_id, operator_id, user_id, sub_type } = data return ( <>
群号: {group_id}
操作者ID: {operator_id}
用户ID: {user_id}
原因: {sub_type}
) } const GroupIncreaseNotice: React.FC> = ({ data }) => { const { group_id, operator_id, user_id, sub_type } = data return ( <>
群号: {group_id}
操作者ID: {operator_id}
用户ID: {user_id}
增加类型: {sub_type}
) } const GroupBanNotice: React.FC> = ({ data }) => { const { group_id, operator_id, user_id, sub_type, duration } = data return ( <>
群号: {group_id}
操作者ID: {operator_id}
用户ID: {user_id}
禁言类型: {sub_type}
禁言时长: {duration} 秒
) } const FriendAddNotice: React.FC> = ({ data }) => { const { user_id } = data return ( <>
用户ID: {user_id}
) } const GroupRecallNotice: React.FC> = ({ data }) => { const { group_id, user_id, operator_id, message_id } = data return ( <>
群号: {group_id}
用户ID: {user_id}
操作者ID: {operator_id}
消息ID: {message_id}
) } const FriendRecallNotice: React.FC> = ({ data }) => { const { user_id, message_id } = data return ( <>
用户ID: {user_id}
消息ID: {message_id}
) } const PokeNotice: React.FC> = ({ data }) => { const { group_id, user_id, target_id } = data return ( <>
群号: {group_id}
用户ID: {user_id}
目标ID: {target_id}
) } const LuckyKingNotice: React.FC> = ({ data }) => { const { group_id, user_id, target_id } = data return ( <>
群号: {group_id}
用户ID: {user_id}
目标ID: {target_id}
) } const HonorNotice: React.FC> = ({ data }) => { const { group_id, user_id, honor_type } = data return ( <>
群号: {group_id}
用户ID: {user_id}
荣誉类型: {honor_type}
) } const GroupMessageReactionNotice: React.FC< NoticeProps > = ({ data }) => { const { group_id, user_id, message_id, likes } = data return ( <>
群号: {group_id}
用户ID: {user_id}
消息ID: {message_id}
表情回应: {likes .map((like) => `表情ID: ${like.emoji_id}, 数量: ${like.count}`) .join(', ')}
) } const GroupEssenceNotice: React.FC> = ({ data }) => { const { group_id, message_id, sender_id, operator_id, sub_type } = data return ( <>
群号: {group_id}
消息ID: {message_id}
发送者ID: {sender_id}
操作者ID: {operator_id}
操作类型: {sub_type}
) } const GroupCardNotice: React.FC> = ({ data }) => { const { group_id, user_id, card_new, card_old } = data return ( <>
群号: {group_id}
用户ID: {user_id}
新名片: {card_new}
旧名片: {card_old}
) } const OneBotNotice: React.FC = ({ data }) => { let NoticeComponent: React.ReactNode switch (data.notice_type) { case OB11NoticeType.GroupUpload: NoticeComponent = break case OB11NoticeType.GroupAdmin: NoticeComponent = break case OB11NoticeType.GroupDecrease: NoticeComponent = break case OB11NoticeType.GroupIncrease: NoticeComponent = ( ) break case OB11NoticeType.GroupBan: NoticeComponent = break case OB11NoticeType.FriendAdd: NoticeComponent = break case OB11NoticeType.GroupRecall: NoticeComponent = break case OB11NoticeType.FriendRecall: NoticeComponent = ( ) break case OB11NoticeType.Notify: switch (data.sub_type) { case 'poke': NoticeComponent = break case 'lucky_king': NoticeComponent = break case 'honor': NoticeComponent = break } break case OB11NoticeType.GroupMsgEmojiLike: NoticeComponent = ( ) break case OB11NoticeType.GroupEssence: NoticeComponent = ( ) break case OB11NoticeType.GroupCard: NoticeComponent = break } return (
通知 {getNoticeTypeName(data.notice_type)} {NoticeComponent}
) } export default OneBotNotice