From 1061632290b7437d64c95708ceff795a32750b0f Mon Sep 17 00:00:00 2001 From: Hide_D Date: Mon, 22 May 2023 01:41:35 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=8B=A8=EC=88=9C=ED=95=9C=20=EA=B3=B5?= =?UTF-8?q?=EC=A7=80=EC=9A=A9=20=EA=B0=9C=EC=9D=B8=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EC=A0=84=EC=86=A1=20=EA=B8=B0=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/Message.php | 56 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/hwe/sammo/Message.php b/hwe/sammo/Message.php index abbff2f8..591aea8d 100644 --- a/hwe/sammo/Message.php +++ b/hwe/sammo/Message.php @@ -376,6 +376,62 @@ class Message throw new \RuntimeException('이곳에 올 수 없습니다.'); } + /** + * @param int[]|MessageTarget[]|int $targets + * @param string $msg + */ + public static function sendPrivateMsgAsNotice(array|int $targets, string $msg): void{ + $src = new MessageTarget(0, '', 0, 'System', '#000000'); + if(is_int($targets)){ + $targets = [$targets]; + } + + $reqTargetGeneralIDList = []; + $objTargets = []; + + foreach($targets as $target){ + if($target instanceof MessageTarget){ + $objTargets[] = $target; + continue; + } + if(!is_int($target)){ + throw new \InvalidArgumentException('올바르지 않은 타입'); + } + + $reqTargetGeneralIDList[] = $target; + } + + if($reqTargetGeneralIDList){ + $db = DB::db(); + $rawGenerals = $db->query('SELECT no, name, nation, imgsvr, picture FROM general WHERE no in %li', $reqTargetGeneralIDList); + foreach($rawGenerals as $rawGeneral){ + $staticNation = getNationStaticInfo($rawGeneral['nation']); + $objTarget = new MessageTarget( + $rawGeneral['no'], + $rawGeneral['name'], + $rawGeneral['nation'], + $staticNation['name'], + $staticNation['color'], + GetImageURL($rawGeneral['imgsvr'], $rawGeneral['picture']) + ); + $objTargets[] = $objTarget; + } + } + + foreach($objTargets as $dest){ + $msg = new Message( + MessageType::private, + $src, + $dest, + $msg, + new \DateTime(), + new \DateTime('9999-12-31'), + [] + ); + $msg->send(true); + } + } + public function send(bool $sendDestOnly=false):int{ [$receiverMailbox, $receiveID] = $this->sendToReceiver(); if(!$receiveID && !$sendDestOnly){