refactoring
This commit is contained in:
@@ -1,21 +1,23 @@
|
||||
package com.github.netricecake;
|
||||
|
||||
import com.github.netricecake.kakao.KakaoApi;
|
||||
import com.github.netricecake.kakao.TalkClient;
|
||||
import com.github.netricecake.kakao.TalkHandler;
|
||||
import com.github.netricecake.kakao.exception.*;
|
||||
import com.github.netricecake.kakao.structs.ChatRoom;
|
||||
import com.github.netricecake.kakao.structs.Member;
|
||||
import com.github.netricecake.kakao.structs.Message;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
//TIP 코드를 <b>실행</b>하려면 <shortcut actionId="Run"/>을(를) 누르거나
|
||||
// 에디터 여백에 있는 <icon src="AllIcons.Actions.Execute"/> 아이콘을 클릭하세요.
|
||||
import java.util.Map;
|
||||
|
||||
public class Main {
|
||||
|
||||
static String email = "invalid@example.com";
|
||||
static String email = "invalid@example.com"; // 이메일 말고 전화번호도 가능
|
||||
static String password = "example";
|
||||
static String deviceName = "SM-X930"; // 갤럭시 탭 s11 울트라, 지원되는 태블릿 모델명 넣으세요
|
||||
static String deviceUuid = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; // 64자 랜덤 hex-string, 이것도 에시니까 무조건 다른걸로 바꾸세요.
|
||||
static String deviceUuid = "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"; // 64자 랜덤 hex-string
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
TalkClient client = new TalkClient(email, password, deviceName, deviceUuid, new TalkHandler() {
|
||||
@@ -60,6 +62,28 @@ public class Main {
|
||||
getTalkClient().sendMessage(room, member.getName() + "님이 나갔습니다.");
|
||||
}
|
||||
});
|
||||
client.connect();
|
||||
|
||||
try {
|
||||
client.connect();
|
||||
} catch (InvalidDeviceNameException e) {
|
||||
System.out.println("서브 디바이스 로그인을 지원하지 않는 디바이스입니다.");
|
||||
} catch (InvalidDeviceUUIDException e) {
|
||||
System.out.println("Device UUID는 64자리 hex string이어야 합니다.");
|
||||
} catch (BadCredentialsException e) {
|
||||
System.out.println("이메일(전화번호)이나 비밀번호가 틀렸습니다.");
|
||||
} catch (BookingFailedException e) {
|
||||
System.out.println("Booking 서버와의 통신을 실패했습니다.");
|
||||
} catch (LoginFailedException e) {
|
||||
System.out.println("카카오톡 서버와 연결을 실패했습니다. 로그인 정보 파일을 삭제 후 다시 시도해보세요.");
|
||||
} catch (UnregisteredDeviceException e) {
|
||||
System.out.println("디바이스 등록이 필요합니다.");
|
||||
Map.Entry<String, Integer> registerInfo = KakaoApi.generatePasscode(email, password, deviceName, deviceUuid);
|
||||
System.out.println("카카오톡 앱에서 " + registerInfo.getValue() + "초 안에 코드를 입력해주세요. 코드 : " + registerInfo.getKey());
|
||||
boolean registerResult = KakaoApi.registerDevice(email, password, deviceUuid);
|
||||
if (!registerResult) {
|
||||
System.out.println("디바이스 등록 실패");
|
||||
}
|
||||
System.out.println("디바이스 등록 성공, 다시 실행하세요.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user