https://github.com/txthinkinginc/zhi.js
Bot of Zhi
https://github.com/txthinkinginc/zhi.js
bot chat chatbot instant-messaging zhi
Last synced: over 1 year ago
JSON representation
Bot of Zhi
- Host: GitHub
- URL: https://github.com/txthinkinginc/zhi.js
- Owner: TxThinkingInc
- License: mit
- Created: 2025-01-14T02:24:58.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-02-26T03:48:55.000Z (over 1 year ago)
- Last Synced: 2025-02-26T04:28:04.626Z (over 1 year ago)
- Topics: bot, chat, chatbot, instant-messaging, zhi
- Language: JavaScript
- Homepage: https://www.txthinking.com/zhi.html
- Size: 8.79 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Bot of Zhi
https://www.txthinking.com/zhi.html
## Install bun via [nami](https://github.com/txthinking/nami)
```
nami install bun bun.plus
```
## Make AvatarUUID
> You only need to make AvatarUUID once for each Chat
```
import zhi from 'https://raw.githubusercontent.com/TxThinkingInc/zhi.js/refs/heads/master/lib.js';
var BotToken = "" // get from https://www.txthinking.com/zhi.html
var ChatUUID = "" // get from https://www.txthinking.com/zhi.html
var Key = "" // your Chat Key
var UserUUID = "" // get from https://www.txthinking.com/zhi.html
var avatar = "" // local avatar image path
var b = await Bun.file(avatar).bytes()
var res = await fetch(`https://upload.zhi.shiliew.com/?ChatUUID=${ChatUUID}&Kind=avatar&Token=${BotToken}`, {
method: "PUT",
body: await zhi.encrypt_file(Key, ChatUUID, UserUUID, b),
})
if (res.status != 200) {
throw await res.text()
}
var AvatarUUID = await res.text()
console.log(AvatarUUID)
```
```
bun --preload ~/.nami/bin/_bun_import_url.js your.js
```
## Run Bot
```
import Bot from 'https://raw.githubusercontent.com/TxThinkingInc/zhi.js/refs/heads/master/bot.js'
var bot = await Bot.init("Bot Token", [ // get from https://www.txthinking.com/zhi.html, one Bot Token can be used in multiple Chats
{
ChatUUID: "", // get from https://www.txthinking.com/zhi.html
Key: "", // your Chat Key
UserUUID: "", // get from https://www.txthinking.com/zhi.html
Name: "", // bot name
AvatarUUID:"", // AvatarUUID you maked
},
])
await bot.connect()
bot.on_message(function(m) { // must call this method, ACK will be responded inside.
console.log(m)
})
await bot.send_text("The ChatUUID", "Hello")
bot.close()
```
```
bun --preload ~/.nami/bin/_bun_import_url.js your.js
```