Skip to Main Contents

R.O.H.A.N.2

공식 포럼

Content

자동프로그래밍 사용자 검색하는거 만들어 봤어요. 정확하지는 않지만 화이팅하세요!

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using UnityEngine;

public class ChatMonitor : MonoBehaviour
{
   // 불량 유저의 발언을 판별하기 위한 키워드와 패턴
   private List<string> suspiciousPatterns = new List<string>
   {
       @"\b!fhgks_wkehdwjsxnwnd\b",   // !fhgks_wkehdwjsxnwnd
       @"\bfhgks_Rodna\b",            // fhgks_Rodna
       @"\b\d+만루비\s*=\s*\d+원\b",   // "몇만루비=얼마원" 형태
       @"\b할인카톡\b"                // 할인카톡
   };

   // 불량 유저 목록을 저장
   private HashSet<string> flaggedUsers = new HashSet<string>();

   // 특정 유저가 채팅을 할 때마다 이 메서드를 호출하여 감시
   public void CheckUserChat(string userId, string chatContent)
   {
       foreach (string pattern in suspiciousPatterns)
       {
           // 정규 표현식으로 키워드가 포함되어 있는지 확인
           if (Regex.IsMatch(chatContent, pattern, RegexOptions.IgnoreCase))
           {
               FlagUser(userId, chatContent);
               break;
           }
       }
   }

   // 불량 유저로 등록하고 메시지를 출력하는 함수
   private void FlagUser(string userId, string reason)
   {
       if (!flaggedUsers.Contains(userId))
       {
           flaggedUsers.Add(userId);
           Debug.Log($"불량 유저 발견! 유저 ID: {userId}, 사유: {reason}");
       }
   }

   // 불량 유저 목록을 확인하는 메서드
   public void PrintFlaggedUsers()
   {
       Debug.Log("불량 유저 목록:");
       foreach (string userId in flaggedUsers)
       {
           Debug.Log($"- {userId}");
       }
   }

   // 테스트용 예제
   void Start()
   {

       // 불량 유저 목록 출력
       PrintFlaggedUsers();
   }
}
 

댓글 0

0/3000

건의 게시판

통합 검색

바로가기

신고
제목
작성자
사유를 선택해주세요.
기본 메세지 팝업 샘플 입니다.