你被骗了!!只有标题和这一句话使用中文,其他的都是英文,请手动点击翻译
Type: Individual user
usage mode: Store messages and manage messages
Make for the company
Make it for yourself
Eazy to use
example:
Network error: https://github.com/wechaty/wechaty/issues?q=network+error
Rpc error: https://github.com/wechaty/go-wechaty/search?q=err%3Arpc+error%3A+code+%3D+Unavailable+desc+%3D+connection&type=issues
Api : Message, Room, Friendship
Polyglot : Go, Java, Python
Puppet Providers : WeChat, XP, WeChat4U
Puppet Services : PadLocal, WXWork
Specifications : Wechaty, Plugin, Puppet, Service, Token, Gateway
@Gateway
## windows puppet-xp port 30000
cnpm install -g wechaty@1.11 wechaty-puppet-xp
@wechaty gateway --puppet wechaty-puppet-xp --port 30000 --token insecure_559c97f1-c6a9-39b0-8f98-288b05f315cd --puppet-token f5c70044-42ea-12ca-ae78-b5ece72dde59
## save to bat
@Server
// 1. Viper Get config
// 2. viper.Getstring set Arg (wechaty-puppet-xp)
// 3. Third party robot corpus(tuling123)
// 4. WebHook(Dingding,Telegram)
// >>> config.yaml <<<
BOT:
CHAT: off
Wechaty:
WECHATY_PUPPET: wechaty-puppet-xp
...
// >>> main.go <<<
package main
import (
"github.com/spf13/viper"
"github.com/wechaty/go-wechaty/wechaty"
// ...
)
func init() {
log.SetPrefix("[WechatyBot] ") // 设置日志前缀
log.SetFlags(log.Ltime | log.Lshortfile)
success := "[\033[01;32m✓\033[0m] "
faild := "[\033[01;31m✗\033[0m] "
info := "[\033[01;33m➜\033[0m] "
rootPath, _ := os.Getwd()
viper.Set("rootPath", rootPath)
//...
if err = viper.ReadInConfig(); err != nil {
log.Printf("%v读取配置文件失败%v", os.Getenv("faild"), err)
} else {
viper.Set("success", success)
viper.Set("rootPath", rootPath)
//...
}
}
func main() {
Api.DingBot() // Check the dingding configuration
var bot = wechaty.NewWechaty(wechaty.WithPuppetOption(wp.Option{
Token: viper.GetString("Wechaty.WECHATY_PUPPET_SERVICE_TOKEN"),
Endpoint: viper.GetString("Wechaty.URL"),
}))
// 根据观察,这里不要设置 TOKEN 了,全部用Option吧,少年
// Token 要填写 WECHATY_PUPPET_SERVICE_TOKEN
bot.OnScan(onScan).
OnLogin(onLogin).
OnLogout(onLogout).
OnError(onError).
OnMessage(onMessage).
OnFriendship(onFriendShip)
bot.DaemonStart()
}
func onMessage(context *wechaty.Context, message *user.Message) {
if message.Self() {
log.Printf("%sBot Chat:%s %s \n", viper.GetString("info"), message.From().Name(), message.Text())
} else if message.From().ID() == viper.GetString("AdminID") {
if message.Text() == "chat.off" {
setEnv("CHAT", "off")
} else if message.Text() == "chat.on" {
setEnv("CHAT", "on")
} else {
Admin.Admin(context, message)
}
} else if message.Room() != nil {
if viper.GetString("CHAT") !="off"{
// Private.Chat(context, message)
message.Say(TulingBot(message.Text())) // TulingBot use tuling123 api
log.Printf("%s%s @我了 ta 说: %s, 回复了: %s", viper.GetString("info"), message.From().Name(), message.Text(), reply)
}
} else {
// 如果不是群消息,那就是联系人消息
if viper.GetString("CHAT") !="off"{
if string(message.Text())=="在吗?" {
message.Say("来了老弟!")
}
}
}
}
...............
Auth WrchatID == XRSec_MSG
WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER=true
parameter @environmentXRSec has the right to modify and interpret this article. If you want to reprint or disseminate this article, you must ensure the integrity of this article, including all contents such as copyright notice. Without the permission of the author, the content of this article shall not be modified or increased or decreased arbitrarily, and it shall not be used for commercial purposes in any way