{"id":21558714,"url":"https://github.com/ghostzero/animechatclient","last_synced_at":"2025-06-11T02:06:23.518Z","repository":{"id":82068384,"uuid":"223007925","full_name":"ghostzero/AnimeChatClient","owner":"ghostzero","description":null,"archived":false,"fork":false,"pushed_at":"2019-11-20T19:08:21.000Z","size":272,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T03:43:52.992Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ghostzero.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-11-20T19:06:43.000Z","updated_at":"2019-11-20T19:08:23.000Z","dependencies_parsed_at":null,"dependency_job_id":"b1150516-fa08-46d0-87d8-2e8c9fd30cc1","html_url":"https://github.com/ghostzero/AnimeChatClient","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostzero%2FAnimeChatClient","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostzero%2FAnimeChatClient/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostzero%2FAnimeChatClient/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostzero%2FAnimeChatClient/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ghostzero","download_url":"https://codeload.github.com/ghostzero/AnimeChatClient/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ghostzero%2FAnimeChatClient/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259184740,"owners_count":22818267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-24T08:15:38.629Z","updated_at":"2025-06-11T02:06:23.464Z","avatar_url":"https://github.com/ghostzero.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"```java\npackage me.ghostzero.chat;\n\nimport com.mashape.unirest.http.HttpResponse;\nimport com.mashape.unirest.http.JsonNode;\nimport com.mashape.unirest.http.Unirest;\nimport com.mashape.unirest.http.exceptions.UnirestException;\nimport io.socket.client.Socket;\nimport io.socket.emitter.Emitter;\nimport me.ghostzero.chat.api.ChatClient;\nimport me.ghostzero.chat.api.socket.Event;\nimport me.ghostzero.chat.api.socket.SocketClient;\nimport me.ghostzero.chat.api.socket.emitters.AsyncEmit;\nimport me.ghostzero.chat.api.socket.events.EventHandler;\nimport me.ghostzero.chat.api.socket.events.EventListener;\nimport me.ghostzero.chat.api.socket.responses.ChatLine;\nimport org.json.JSONException;\nimport org.json.JSONObject;\nimport org.junit.Test;\nimport org.junit.runner.RunWith;\nimport org.powermock.core.classloader.annotations.PowerMockIgnore;\nimport org.powermock.modules.junit4.PowerMockRunner;\n\n@RunWith(PowerMockRunner.class)\n@PowerMockIgnore(\"javax.net.ssl.*\")\npublic class ChatClientUnitTest implements EventListener {\n\n    private SocketClient socketClient;\n    private ChatClient chatClient;\n\n    @Test\n    public void testSendCommand() throws Exception {\n        HttpResponse\u003cJsonNode\u003e jsonResponse = Unirest.post(\"https://hitagi.ghostzero.moe/api/exec\")\n            .field(\"username\", \"Twillux\")\n            .field(\"args\", \".help\")\n            .asJson();\n\n        String message = jsonResponse.getBody().getObject().getString(\"message\");\n\n        System.out.println(\"Message: \" + message);\n    }\n\n    /**\n     *\n     * @throws Exception\n     */\n    @Test\n    public void testChatClient() throws Exception {\n        chatClient = new ChatClient.Builder()\n            .withSessionId(\"s%3AttZ7YKcPFPwkBjRYBsn4wHqaUumt5MsY.X2QZ23jd8Y0YwFxUmV5Lo9DAyRtNFZew2%2FnWMQeJVQ8\")\n            .build();\n\n        socketClient = chatClient.buildSocketClient();\n\n        socketClient.getEventManager().registerEvents(this);\n\n        socketClient.getSocket().on(Socket.EVENT_CONNECT, new Emitter.Listener() {\n            @Override\n            public void call(Object... args) {\n                System.out.println(\"Connected to Socket!\");\n\n                socketClient.joinRoom(\"Strand\");\n            }\n        }).on(Socket.EVENT_DISCONNECT, new Emitter.Listener() {\n            @Override\n            public void call(Object... args) {\n                System.out.println(\"Disconnected from Socket.\");\n            }\n        }).on(Socket.EVENT_MESSAGE, new Emitter.Listener() {\n            @Override\n            public void call(Object... args) {\n                System.out.println(\"System message: \" + args[0].toString());\n            }\n        });\n\n        socketClient.connect();\n\n        System.in.read();\n    }\n\n    @EventHandler\n    public void onChatLine(ChatLine event) {\n        System.out.println(String.format(\"Chat Event {name: %s, line: %s}\", event.getUser(), event.getChatLine()));\n\n        // block system messages\n        if (event.getFestername() == null) return;\n        // block message processing from hitagi and commands\n        if (event.getFestername().equals(\"Hitagi\") || !event.getChatLine().startsWith(\".\")) return;\n\n        try {\n            System.out.println(String.format(\"[Waifu Handler] Exec '%s' as %s\", event.getChatLine(), event.getFestername()));\n            HttpResponse\u003cJsonNode\u003e jsonResponse = Unirest.post(\"https://hitagi.ghostzero.moe/api/exec\")\n                .field(\"username\", event.getFestername())\n                .field(\"args\", event.getChatLine())\n                .asJson();\n\n            JSONObject jsonObject = jsonResponse.getBody().getObject();\n\n            if (jsonObject.has(\"message\") \u0026\u0026 jsonObject.getString(\"message\").length() \u003e 0) {\n                final String message = jsonObject.getString(\"message\");\n                System.out.println(\"[Waifu Handler] Reply back: \" + message);\n                socketClient.emitAsync(new AsyncEmit() {\n                    @Override\n                    public void run() throws Exception {\n                        JSONObject jsonObject = new JSONObject();\n                        jsonObject.put(\"chatLine\", message);\n                        socketClient.getSocket().emit(Event.EVENT_NEW_CHAT_LINE, jsonObject);\n                    }\n                }, 0);\n            }\n\n        } catch (UnirestException e) {\n            System.out.println(\"[Waifu Handler] Error exec (unirest e): \" + e.getMessage());\n        } catch (JSONException e) {\n            System.out.println(\"[Waifu Handler] Error exec (json e): \" + e.getMessage());\n        }\n    }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostzero%2Fanimechatclient","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fghostzero%2Fanimechatclient","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fghostzero%2Fanimechatclient/lists"}