Last active
January 10, 2021 09:32
-
-
Save vizv/97ea9b176f70c9db4e7ce7cb633af149 to your computer and use it in GitHub Desktop.
Kemonomimi Bot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
AUTH_KEY='' | |
QQ='' | |
SESSION_KEY="$(http :8080/auth "authKey=${AUTH_KEY}" | jq -r .session)" | |
[ "$(http :8080/verify "sessionKey=${SESSION_KEY}" "qq=${QQ}" | jq '.code')" = 0 ] || exit 1 | |
echo "SESSION_KEY=${SESSION_KEY}" | |
while true; do | |
sleep 1 | |
MESSAGES="$(http :8080/fetchLatestMessage "sessionKey==${SESSION_KEY}" 'count==2')" | |
LEN="$(echo "$MESSAGES" | jq '.data | length')" | |
for I in $(seq 0 $(("$LEN" - 1))); do | |
MESSAGE="$(echo "$MESSAGES" | jq ".data[${I}]")" | |
echo "DEBUG: $(echo "$MESSAGE" | jq -r '.type')" | |
echo "$(echo "$MESSAGE" | jq -c '.messageChain[]')" | |
echo | |
[ "$(echo "$MESSAGE" | jq -r '.type')" = 'GroupMessage' ] || continue | |
GROUP_ID="$(echo "$MESSAGE" | jq '.sender.group.id')" | |
INPUT="$(echo "$MESSAGE" | jq -r '.messageChain[1].text')" | |
[ "$INPUT" = 'cat' ] && http :8080/sendImageMessage \ | |
"sessionKey=${SESSION_KEY}" \ | |
"group:=${GROUP_ID}" \ | |
"urls:=[$(http https://nekos.life/api/v2/img/neko | jq .url)]" \ | |
-p '' | |
[ "$INPUT" = 'fox' ] && http :8080/sendImageMessage \ | |
"sessionKey=${SESSION_KEY}" \ | |
"group:=${GROUP_ID}" \ | |
"urls:=[$(http https://nekos.life/api/v2/img/fox_girl | jq .url)]" \ | |
-p '' | |
[ "$INPUT" = 'holo' ] && http :8080/sendImageMessage \ | |
"sessionKey=${SESSION_KEY}" \ | |
"group:=${GROUP_ID}" \ | |
"urls:=[$(http https://nekos.life/api/v2/img/holo | jq .url)]" \ | |
-p '' | |
done | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -ex | |
. ./version.env | |
rm -rf libs | |
mkdir libs | |
wget "$CORE_URL" -O libs/mirai-core-all.jar | |
wget "$CONSOLE_URL" -O libs/mirai-console.jar | |
wget "$CONSOLE_TERMINAL_URL" -O libs/mirai-console-terminal.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -ex | |
java -cp "./libs/*" net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CORE_VER='2.0-M2-2' | |
CORE_URL="https://maven.aliyun.com/repository/public/net/mamoe/mirai-core-all/${CORE_VER}/mirai-core-all-${CORE_VER}-all.jar" | |
CONSOLE_VER='2.0-M2' | |
CONSOLE_URL="https://maven.aliyun.com/repository/public/net/mamoe/mirai-console/${CONSOLE_VER}/mirai-console-${CONSOLE_VER}-all.jar" | |
CONSOLE_TERMINAL_VER='2.0-M2' | |
CONSOLE_TERMINAL_URL="https://maven.aliyun.com/repository/public/net/mamoe/mirai-console-terminal/${CONSOLE_TERMINAL_VER}/mirai-console-terminal-${CONSOLE_TERMINAL_VER}-all.jar" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment