Chat Log Collection System (CLCS)
send-chat-log
This API sends chat logs to Chat log collection system.
- Request URL
Commercial Server URL https://clcs.qpyou.cn/chat/api/v1/send-chat-log Sandbox Server URL https://sandbox-clcs.qpyou.cn/chat/api/v1/send-chat-log HTTP Method POST Content-Type application/json - Request Body
Field Name Type Required Description game_key String Y The key value (16 characters) created from the company id and the game id. You can get this key on AI Service > Chat Abusing Detection > Game Management > Confirm Encryption Key in the Hive Console. The company id and game id can also be obtained in the Hive console AI service > Chat Abusing Detection > Game Management.
Example) abcdefghijklmnop
chat_log object Y the array or the collection of encrypted messages and the chat_count. - chat_log object
Field Name Type Required Description chat_count int Y The number of msg in the msg_array.
Ex) 32 (The chat_count and the size of msg_array containing encrypted msgs must be the same.)msg_array array Y 1 or more msg objects - msg object;
Field Name Type Required Description time_stamp string Y Convert the time of occurrence of a chat message in ISO8601 format and transmit it. If you change the chat message timestamp with the ISO8601 format, ±hh:mm will be added at the tail of the timestamp according to the time zone to which the user who sent the message belongs.
The examples of the time_stamp values according to the sender’s time zone and the chat message timestamp
- When the time zone is UTC, and the chat message timestamp is 2023-03-30 17:13:00.
- Use 2023-03-30T17:13:00+00:00 or 2023-03-30T17:13:00Z
- +00:00 can also be written as Z (YYYY-MM-DDTHH:mm:ss{.mmm}±hh:mm or YYYY-MM-DDTHH:mm:ss{.mmm}Z)
- When the time zone is KST (Korea Standard Time), and the chat message timestamp is 2023-03-30 17:13:00.
- Use 2023-03-30T17:13:00+09:00
- When the time zone is CST (Central Standard Time), and the chat message timestamp is 2023-03-30 17:13:00.
- Use 2023-03-30T17:13:00-05:00
msg string Y the JSON string encrypted with the encryption key issued from the Hive Console’s AI Service > Chat Abusing Detection > Game Management > Confirm Encryption Key (maximum size 2KB, AES256 encryption) - When the time zone is UTC, and the chat message timestamp is 2023-03-30 17:13:00.
- msg
Field Name Type Required Description time_stamp string Y Convert the time of occurrence of a chat message in ISO8601 format and transmit it. If you change the chat message timestamp with the ISO8601 format, ±hh:mm will be added at the tail of the timestamp according to the time zone to which the user who sent the message belongs.
The examples of the time_stamp values according to the sender’s time zone and the chat message timestamp
- When the time zone is UTC, and the chat message timestamp is 2023-03-30 17:13:00.
- Use 2023-03-30T17:13:00+00:00 or 2023-03-30T17:13:00Z
- +00:00 can also be written as Z (YYYY-MM-DDTHH:mm:ss{.mmm}±hh:mm or YYYY-MM-DDTHH:mm:ss{.mmm}Z)
- When the time zone is KST (Korea Standard Time), and the chat message timestamp is 2023-03-30 17:13:00.
- Use 2023-03-30T17:13:00+09:00
- When the time zone is CST (Central Standard Time), and the chat message timestamp is 2023-03-30 17:13:00.
- Use 2023-03-30T17:13:00-05:00
room_num int Y the chat room number Example) 123342
lang_code int Y the language code
Korean (ko) : 1, English (en): 2, Japanese (ja): 3, Simplified Chinese: 4, Traditional Chinese: 5, España(es): 6, Russia (ru): 7, German (de): 8, French (fr): 9, Portuguese (pt): 10, Italian (it): 11, Thai (th): 12, Indonesian (id): 13, Turkish (tr): 14, Malaysian (ms): 15, Vietnamese (vi): 16chat_msg string Y the chatting contents
eg) Hello! The weather is good today.chat_mode int Y The chat types
Example)
100: general chat
200: group (1:1~N) chatting
300: whisper
4NN: the custom chat type defined by the game studiochannel_user_id int Y the user’s ID (playerId) in the game - When the time zone is UTC, and the chat message timestamp is 2023-03-30 17:13:00.
- Response
Field Name Type Description result object the container for the output result result_code string Result Code result_msg string the result message - Result Code
result_code result_msg Description 200 Success The log transfer was successfully finished. 500 Incorrect request There is an error in your request. Please check the request URL and the required request variables are correct. 501 The number of messages does not match The number of messages and the chat_count do not match. The chat_count and the length of msg_array must match. 502 Incorrect secret key Invalid secret key value.
Please go to the Hive Console’s AI Service > Chat Abusing Detection > Game Management > Confirm Encryption Key and check the encryption key value.503 Unregistered game key Invalid game key value.
Please go to the Hive Console’s AI Service > Chat Abusing Detection > Game Management > Confirm Encryption Key and check the game key value.506 System error This error occurs when the chat log collection system is down for maintenance. 507 The size of the message is too large The size of the message is too large. The maximum size of msg_array is 2KB. - Examples
- Python
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253import requestsimport jsonfrom Crypto.Cipher import AESfrom Crypto.Util.Padding import padimport base64game_key = <GAME_KEY>secret_key = <SECRET_KEY>aes = AES.new(secret_key, AES.MODE_ECB)url = "https://clcs.qpyou.cn/chat/api/v1/send-chat-log"# message encryptiondef encrypt_msg(room_num:int,lang_code:int,chat_msg:str,chat_mode:int,channel_user_id:int) -> str:json_data = {"time_stamp":"2023-02-20T10:22:10+09:00", # datetime.now().isoformat()"room_num":room_num,"lang_code":lang_code,"chat_msg":chat_msg,"chat_mode":chat_mode,"channel_user_id":channel_user_id}json_str = json.dumps(json_data)padded_str = pad(json_str.encode("utf-8"),AES.block_size)encrypted_data = aes.encrypt(padded_str)encrypted_data_b64 = base64.b64encode(encrypted_data).decode("utf-8")return encrypted_data_b64# Define json payloadjson_payload = {"game_key": game_key,"chat_log":{"chat_count": N, # the size of msg_array"msg_array":[{"time_stamp":"2023-02-20T10:22:10+09:00","msg":encrypt_msg(room_num,lang_code,.......)},{"time_stamp":"2023-02-20T10:22:10+09:00","msg":encrypt_msg(room_num,lang_code,.......)}, ...]}}def call_curl_post(url, json_payload):headers = {'Content-type': 'application/json'}response = requests.post(url, data=json.dumps(json_payload), headers=headers)# function callcall_curl_post(url=url, json_payload) - Java
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576import java.util.Collections;import java.util.HashMap;import java.util.Map;import javax.crypto.Cipher;import javax.crypto.spec.SecretKeySpec;import org.apache.tomcat.util.codec.binary.Base64;import org.springframework.http.HttpHeaders;import org.springframework.http.MediaType;import net.minidev.json.JSONObject;public class SampleCode {private String gameKey = <GAME_KEY>;private String secretKey = <SECRET_KEY>;private String url = "https://clcs.qpyou.cn/chat/api/v1/send-chat-log"public void callCurlPost() {RestTemplate restTemplate = new RestTemplate();HttpHeaders headers = new HttpHeaders();headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON_UTF8));headers.setContentType(MediaType.APPLICATION_JSON);Map<String, Object> parameters = new HashMap<>();parameters.put("game_key", gameKey);parameters.put("chat_log", "{\"chat_count\" : N //msg_array list size,\"msg_array\":[{\"time_stamp\":\"2023-02-20T10:22:10+09 :00\", \"msg\":encrypt_msg(,,....)},{\"time_stamp\":\"2023-02-20T10:22:10+09:00\", \"msg \":encrypt_msg(,,....)}, ...]}");JSONObject jsonParam = getJsonStringFromMap(parameters);HttpEntity<JSONObject> requestEntity = new HttpEntity<>(jsonParam, headers);ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.POST, requestEntity, String.class);System.out.println("Response status code: " + response.getStatusCode());System.out.println("Response body: " + response.getBody());}// message encryptionprivate String encrypt_msg(int room_num, int lang_code, String chat_msg, int chat_mode, int charnnel_user_id) throws Exception {Map<String,Object> map = new HashMap<String,Object>();map.put("time_stamp", "2023-02-20T10:22:10+09:00"); //# "%Y-%m-%d %H:%M:%S",map.put("room_num", room_num);map.put("lang_code", lang_code);map.put("chat_msg", chat_msg);map.put("chat_mode", chat_mode);map.put("charnnel_user_id", charnnel_user_id);JSONObject encrypt_json = new JSONObject(map);String encrypt_str = encrypt_json.toJSONString();return encrypt(encrypt_str, secret_key);}// encryptionprivate String encrypt(String plainText, String key) throws Exception {byte[] keyBytes = key.getBytes("UTF-8");SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");cipher.init(Cipher.ENCRYPT_MODE, keySpec);byte[] encryptedBytes = cipher.doFinal(plainText.getBytes("UTF-8"));return Base64.encodeBase64String(encryptedBytes);}private static JSONObject getJsonStringFromMap( Map<String, Object> map){JSONObject jsonObject = new JSONObject();for( Map.Entry<String, Object> entry : map.entrySet() ) {String key = entry. getKey();Object value = entry. getValue();jsonObject. put(key, value);}return jsonObject;}} - Curl
123456789101112131415161718192021222324252627282930//TEST CALLcurl-d '{"game_key": company key,"chat_log":{"chat_count" : 1,"msg_array":[{"2023-02-20T10:22:10+09:00", "msg":"Encrypted text"}]}}'-H "Content-Type: application/json"-X POST https://test-clcs.qpyou.cn/chat/api/v1/send-chat-log//HEADERPOST https://clcs-qpyou.cn/v1/chat/send-chat-logHost: clcs-qpyou.cnUser-Agent: curl/7.43.0Accept: */*Content-Type: application/json//BODY{"game_key":"abcdefghijklmnop","chat_log":{"chat_count" : 2,"msg_array":[{"time_stamp":"2023-02-20T10:22:10+09:00","msg":"yBDyG1rCthbkXCSpSgGM+ZfHs/B3bZtnxq7f6BOPX2c1Bk8xRAwF6HbkDeN/9prpqeD......"},{"time_stamp":"2023-02-20T10:22:10+09:00","msg":"yBDyG1rCthbkXCSpSgGM+ZfHs/B3bZtnxq7f6BOPX2c1Bk8xRAwF6HbkDeN....."}]}} - result
123456{"result":{"result_code":"100","result_msg":"success"}}
- Python