GithubHelp home page GithubHelp logo

songtianyi / wechat-go Goto Github PK

View Code? Open in Web Editor NEW
1.8K 87.0 340.0 309 KB

go version wechat web api and message framework for building wechat robot

License: MIT License

Go 100.00%
wechat golang web api robot bot framework

wechat-go's Introduction

wechat-go

Build Status Join the chat at https://gitter.im/wechat-go/Lobby Go Report Card codebeat badge license

使用前阅读:

  • 17年6月下旬前登陆过web网页版的微信可以使用此框架,验证微信是否支持web版本API,请点击https://wx.qq.com/ ,扫码验证即可,假如出现无法登陆,则不适用于此框架

介绍

微信web版API的go实现,模拟微信网页版的登录/联系人/消息收发等功能,可以完全接管微信收到的消息, 并定制自己的发送内容

  • 支持多用户(多开)
  • 支持掉线后免扫码重登
  • 功能以插件的形式提供,可以根据用户(比如付费情况)选择加载或者不加载某插件
  • 插件编写简单, 可定制性强, 无需关心API和消息分发,二次开发极为方便
  • 对于加载的插件, 使用机器人的终端用户可以通过微信聊天界面动态开启/关闭.
  • 目前已提供头像(性别/年龄)识别, gif搜索, 笑话大全, "阅后即焚", 消息跨群转发, 中英互译等多个有趣插件
  • 可以发送图片/文字/gif/视频/表情等多种消息
  • 支持Linux/MacOSX/Windows, 树莓派也可以:)

获取源码

mkdir -p $GOPATH/src/golang.org/x
cd $GOPATH/src/golang.org/x
git clone https://github.com/golang/net.git

go get -u -v github.com/songtianyi/wechat-go
cd $GOPATH/src/github.com/songtianyi/wechat-go
go get ./...

编译并运行

linux/mac

go build examples/linux/terminal_bot.go
./terminal_bot

windows

windows版本需要在非windows系统使用交叉编译来生成, 生成之后在windows下运行

GOOS=windows GOARCH=amd64 go build examples/windows/windows_bot.go
./windows_bot.exe
扫码图片需要用软件打开,路径在输出日志内.

示例项目

go-aida

区别

  • go-aida是拥有扫码页面的功能性机器人
  • wechat-go实现了微信的API, 并提供了易用的消息框架, 但并不是可运行程序
  • 只需少量代码即可基于wechat-go创建一个属于自己的个性化机器人,对于更复杂的需求(扫码页面等)可以使用go-aida
  • wechat-go专注在API的稳定性/框架的易用性/通用插件这三方面
  • go-aida专注在机器人的个性化定制上

示例代码

基于wechat-go创建自定义的机器人
package main

import (
	"github.com/songtianyi/rrframework/logs"
	"github.com/songtianyi/wechat-go/plugins/wxweb/faceplusplus"
	"github.com/songtianyi/wechat-go/plugins/wxweb/gifer"
	"github.com/songtianyi/wechat-go/plugins/wxweb/replier"
	"github.com/songtianyi/wechat-go/plugins/wxweb/switcher"
	"github.com/songtianyi/wechat-go/wxweb"
)

func main() {
	// 创建session, 一个session对应一个机器人
	// 二维码显示在终端上
	session, err := wxweb.CreateSession(nil, nil, wxweb.TERMINAL_MODE)
	if err != nil {
		logs.Error(err)
		return
	}

	// 注册插件, 所有插件默认是开启的
	faceplusplus.Register(session)
	replier.Register(session)
	switcher.Register(session)
	gifer.Register(session)

	// 你也可以自己选择关闭插件里的handler(消息处理器)
	session.HandlerRegister.DisableByName("faceplusplus")

	// 登录并接收消息
	if err := session.LoginAndServe(false); err != nil {
		logs.Error("session exit, %s", err)
	}
}

插件列表

switcher

一个管理插件的插件

#关闭某个插件, 在微信聊天窗口输入
disable faceplusplus
#开启某个插件, 在微信聊天窗口输入
enable faceplusplus
#查看所有插件信息, 在微信聊天窗口输入
dump
faceplusplus

对收到的图片做面部识别,返回性别和年龄

gifer

以收到的文字消息为关键字做gif搜索,返回gif图, 注意返回的gif可能尺度较大,比如文字消息中包含“污”等关键词。

replier

对收到的文字/图片消息,做自动应答,回复固定文字消息

laosj

随机获取一张美女图片, 在聊天窗口输入

美女
joker

获取一则笑话, 在聊天窗口输入

笑话
revoker

消息撤回插件, 3s后自动撤回手机端所发的文本消息. 机器人发出的消息需要自己在对应插件里写撤回逻辑.

system

处理消息撤回/红包等系统提示

forwarder

消息跨群转发, 在插件里修改群名的全拼即可.

youdao

中英互译插件, 基于有道翻译API

verify

自动接受好友请求, 可以按条件过滤

share

资源(纸牌屋)自动分发示例

config

配置管理插件 设置配置, 在聊天窗口输入

set config key value

查看配置,在聊天窗口输入

get config key

在代码中使用配置

import "github.com/songtianyi/wechat-go/kv"
func demo() {
	kv.KVStorageInstance.Set("key", "value")
	v := kv.KVStorageInstance.Get("key")
	if v == nil {
		return
	}
	// v.(string) etc.
}

制作自己的插件

自定义插件的两个原则

  • 一个插件只完成一个功能,不在一个插件里加入多个handler
  • 插件默认开启

插件示例

package demo // 以插件名命令包名

import (
	"github.com/songtianyi/rrframework/logs" // 导入日志包
	"github.com/songtianyi/wechat-go/wxweb"  // 导入协议包
)

// 必须有的插件注册函数
// 指定session, 可以对不同用户注册不同插件
func Register(session *wxweb.Session) {
	// 将插件注册到session
	// 第一个参数: 指定消息类型, 所有该类型的消息都会被转发到此插件
	// 第二个参数: 指定消息处理函数, 消息会进入此函数
	// 第三个参数: 自定义插件名,不能重名,switcher插件会用到此名称
	session.HandlerRegister.Add(wxweb.MSG_TEXT, wxweb.Handler(demo), "textdemo")

	// 开启插件
	if err := session.HandlerRegister.EnableByName("textdemo"); err != nil {
		logs.Error(err)
	}
}

// 消息处理函数
func demo(session *wxweb.Session, msg *wxweb.ReceivedMessage) {

	// 可选: 可以用contact manager来过滤, 比如过滤掉没有保存到通讯录的群
	// 注意,contact manager只存储了已保存到通讯录的群组
	contact := session.Cm.GetContactByUserName(msg.FromUserName)
	if contact == nil {
		logs.Error("ignore the messages from", msg.FromUserName)
		return
	}

	// 可选: 根据消息类型来过滤
	if msg.MsgType == wxweb.MSG_IMG {
		return
	}

	// 可选: 根据wxweb.User数据结构中的数据来过滤
	if contact.PYQuanPin != "songtianyi" {
		// 比如根据用户昵称的拼音全拼来过滤
		return
	}

	// 可选: 过滤和自己无关的群组消息
	if msg.IsGroup && msg.Who != session.Bot.UserName {
		return
	}

	// 取出收到的内容
	// 取text
	logs.Info(msg.Content)
	//// 取img
	//if b, err := session.GetImg(msg.MsgId); err == nil {
	//	logs.Debug(string(b))
	//}

	// anything

	// 回复消息
	// 第一个参数: 回复的内容
	// 第二个参数: 机器人ID
	// 第三个参数: 联系人/群组/特殊账号ID
	session.SendText("plugin demo", session.Bot.UserName, wxweb.RealTargetUserName(session, msg))
	// 回复图片和gif 参见wxweb/session.go

}

wechat-go's People

Contributors

dvrkps avatar forthxu avatar gitter-badger avatar jqs7 avatar laike9m avatar liuchenrang avatar qighliu29 avatar songtianyi avatar yangboz avatar yusank avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wechat-go's Issues

重构需求收集

wechat-go重构

重构目标

  • 提高消息收发稳定性
    • 添加免扫码重登
  • 提高代码质量,力求对学习golang的同学有参考价值
    • 添加测试代码
    • 添加java风格的builder
    • 集成go-swagger
    • 集成api模块, api添加认证,添加更加丰富的api接口,比如发消息
    • 重写并集成页面, 之前分开是为了避免一个项目模块太多,过于复杂,现在看来是多虑了。分开之后反而增加了使用难度,大部分人都不愿意深入到代码细节来使用这个东西,所以重构之后打包到一起 越简单越好
    • 命令行工具(目前是使用者自己写main文件 编译 运行)
      • 可以daemon形式运行, 支持启动参数
      • http(s) toolkit, 可以动态enable/disable插件,去掉在聊天窗口的插件管理功能(体验太差)
    • github page(待定)
  • 降低使用难度,让使用者0负担,让开发者能够快速上手开发插件
    • 将go-aida集成进来
    • 补充文档
    • 增强windows下的体验,electron?

项目issue梳理

  • 整理需求
    • 公众号文章接口支持
    • 消息推送,通过API接口来实现
    • 插件动态注入,目前是静态注入 动态开关
    • 修改联系人备注
  • 整理待解决问题
    • 插件作用范围,目前有关群组的插件只对已经保存到通讯录的群组生效
    • 插件加载失败退出程序,目前需要开发者自己判断插件加载函数的返回值,不友好
    • 联系人列表不全
    • 使用者长时间不扫码,提示不友好
    • @群成员 发送消息
    • 群管插件增强
    • 支持自定义Logger

同类项目梳理

命名规范

微信接口梳理

数据结构标准化

模块划分

微信接口重构

添加人类行为模拟引擎

消息引擎重构

插件引擎重构

各插件重写

页面重写并集成到wechat-go

主动发起消息是否支持?

package main

import (
    "fmt"
    "time"

    "github.com/songtianyi/wechat-go/wxweb"
)

func main() {
    s, _ := wxweb.CreateSession(nil, nil, wxweb.TERMINAL_MODE)
    go func() {
        for {
            if s.Bot != nil {
                fmt.Println(s.SendText("Hello", s.Bot.UserName, "foo"))
            }
            time.Sleep(time.Second)
        }
    }()
    s.LoginAndServe(false)
}

尝试用这种方式提交无法成功。

*[E] session exit, json: cannot unmarshal number 2147586143 into Go value of type int**

[pi@raspberrypi ~/c/wechat-go/tests] $ uname -a
Linux raspberrypi 4.4.21-v7+ #911 SMP Thu Sep 15 14:22:38 BST 2016 armv7l GNU/Linux
[pi@raspberrypi ~/c/wechat-go/tests] $
[pi@raspberrypi ~/c/wechat-go/tests] $ go version
go version go1.7.3 linux/arm
[pi@raspberrypi ~/c/wechat-go/tests] $

~
[pi@raspberrypi ~/c/wechat-go/tests] $ go run test.go
2017/04/28 12:41:53 [D] AfPX6FT9Gw==

2017/04/28 12:41:57 [E] invalid response, window.code=201;
2017/04/28 12:42:09 [D] &{2147483647 @403654952e7d01e4edbcf418f042774c cp4 /cgi-bin/mmwebwx-bin/webwxgeticon?seq=541739479&username=@403654952e7d01e4edbcf418f042774c&skey=@crypt_b31d43c3_df0d7355e9ba022aaf84cff4bc66db3c 0 0 [] 0 0 1 become an old man, filled with regret, waiting to die alone 0 0 0 0 0 2 1 17 0 0 0 0}
2017/04/28 12:42:13 [E] session exit, json: cannot unmarshal number 2147586143 into Go value of type int

总是出现 handlers for key [51] not registered

2017/07/08 08:46:29 [W] handlers for key [51] not registered
2017/07/08 08:46:29 [W] handlers for key [51] not registered

看了一下51是 wechat init message,然后我在自己的插件里加了一条

session.HandlerRegister.Add(wxweb.MSG_INIT, wxweb.Handler(demo), "receiver")

但警告信息仍然在。不知道这个警告的含义是什么,以及该怎么处理才能消除。谢谢!

add to switcher the 管理插件的插件

Hi @songtianyi,

The new plugin that I'm writting (#34) need more functionalities to switcher the 管理插件的插件. So far it supports:

#关闭某个插件, 在微信聊天窗口输入
disable faceplusplus
#开启某个插件, 在微信聊天窗口输入
enable faceplusplus
#查看所有插件信息, 在微信聊天窗口输入
dump

Please (consider) adding one more command to it,

config [plugin] more config strings for the plugin

and have a way for the plugin to take the more config strings for the plugin and do its own configuration.

I need to pass two integers to my plugin for its configuration, which I can take care of it myself when I get the string.

Thanks for consideration!

接受到群消息时,如果发消息人不是我的好友,取不到群里发消息人的昵称

接受到群消息时,如果发消息人不是我的好友,取不到群里发消息人的昵称。

接受到群消息时,logs.Info(“%+v”, msg)

好几个信息为nil

    mm, err := wxweb.CreateMemberManagerFromGroupContact(session, contact)
if err != nil {
	logs.Debug(err)
	return
}
who := mm.GetContactByUserName(msg.Who)

发消息的人和我是好友,who里有内容,不是好友,who为nil

登录状态,如果手机在增加一个公众号,服务无法在使用

2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7
2017/09/05 14:56:57 [I] webpush.wx.qq.com 0 7

获取完整联系人列表(人数大于1558)

首先感谢作者的分享,最近使用中发现一个问题:我的需求是获取所有好友信息(总共3000人)。
看了下应该是通过getcontact这个API返回的response,但是返回就1558个。
进一步研究发现有过seq参数(初始为0),试了下用第一次返回的seq作为参数再请求一次getcontact,返回为空。
不知道有没有朋友遇到这个问题,是否有办法实现我这个需求?

The login & error correction logic

Hi @songtianyi,

Please use this main.go to replace the one in my https://github.com/suntong/wx-go/tree/master/cmd/wx-go and see what you get.

I was trying to straight-out the login/re-login logic and work flow of wechat-go, and this is what i get when I tried to send "3824":

2017/12/20 19:31:32 [I] AcAIgEEJcA==
QRCode here
2017/12/20 19:32:01 [W] login response, window.code=408;
2017/12/20 19:32:01 [E] session exit, login response, window.code=408;
2017/12/20 19:32:30 [W] login response, window.code=201;
2017/12/20 19:32:45 [I] &{28490913... 
login successful on second attempt
...
2017/12/20 19:35:27 [I] webpush.web.wechat.com 0 2
2017/12/20 19:35:28 [W] no handlers for key [51]
2017/12/20 19:35:58 [I] webpush.web.wechat.com 0 0
2017/12/20 19:35:58 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1513816528000&deviceid=e219888375988845&r=1513816528000&sid=Blz45ePCcGpesIXo&skey=%40crypt_73c0b781_d641e4f28e65c0a46ca2be960effa5e3&synckey=1_667596270%7C2_667600694%7C3_667600570%7C11_667600646%7C13_667390534%7C201_1513816527%7C203_1513808070%7C1000_1513816443%7C1001_1513815314&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2017/12/20 19:36:28 [I] webpush.web.wechat.com 0 0
2017/12/20 19:36:28 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1513816558000&deviceid=e219888375988845&r=1513816558000&sid=Blz45ePCcGpesIXo&skey=%40crypt_73c0b781_d641e4f28e65c0a46ca2be960effa5e3&synckey=1_667596270%7C2_667600694%7C3_667600570%7C11_667600646%7C13_667390534%7C201_1513816527%7C203_1513808070%7C1000_1513816443%7C1001_1513815314&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

The above error shows up right after I sent "3824", and they are the error I've been experiencing when it didn't work for me on my first try.

I don't think changing the external login logic should affect my plugin's internal behavior. So I need your help to figure out why it work and why it didn't. -- As I suspected in #34, I've always been scanning-in on the second attempt. I.e., after I saw the time out error in my console. whereas you must have been always scan-in right away. Could such minor difference make such huge impact?

Anyway, apparently the above main.go is not working for me. Could you see if you can make it work (for both first & second attempt) please?

Thanks

转发消息时内容格式不正确

你好,我使用手机发送了一个表情,日志有显示接收到消息 msg.Content 为:

<span class=\"emoji emoji1f49f\"></span>

将此消息再次转发给别人时,内容显示的不在是一个表情,而是一串:

\u003cspan class=\\\"emoji emoji1f49f\\\"\u003e\u003c/span\u003e

如何保证发送表情时(如:💯 ),能正常转发,同样的在转发一个Link类型分享消息时,也存在同样问题。

谢谢。

不能获取群组信息

登录成功之后我立刻使用Cm.GetGroupContacts()获取已经保存到群聊列表的群组,实际上有4个群组保存到通讯录了,然而获取的个数是0。

我的猜测是,是否是因为通讯录列表尚未同步完成?如果是,那么有没有接口可以知道这个同步完成了没有?谢谢!

重复消息?

同一个消息被接收多次, 间歇性出现
image

如图, 有些正常, 有些两次, 还有一些编码有问题

examples/emed_web 无法运行

报错 open /public/gdJLVy36up==.jpg: permission denied

有个办法可以避免报错,就是自己创建public文件夹而不是由wechat-go去创建,但是还是改一下这个问题比较好。

session exit, session down, sel 4%

在阿里云内新开一个 tmux session,半小时内一定会出现

session exit, session down, sel 4%

本地无法重现。

稍微看了下代码,这里 如果 sel 不是 0 或者 7 就直接报错退出。然而在 itchat 对应的逻辑是这么写的:

                i = sync_check(self)
                if i is None:
                    self.alive = False
                elif i == '0':
                    pass
                else:
                    msgList, contactList = self.get_msg()
                    if msgList:
                        msgList = produce_msg(self, msgList)
                        for msg in msgList:
                            self.msgList.put(msg)
                    if contactList:
                        chatroomList, otherList = [], []
                        for contact in contactList:
                            if '@@' in contact['UserName']:
                                chatroomList.append(contact)
                            else:
                                otherList.append(contact)
                        chatroomMsg = update_local_chatrooms(self, chatroomList)
                        chatroomMsg['User'] = self.loginInfo['User']
                        self.msgList.put(chatroomMsg)
                        update_local_friends(self, otherList)
                retryCount = 0

sync_check 返回的 i 就是 wechat-go 里的 sel,并没有非 0 或 7 就退出的逻辑。

我并不了解微信里这些数字的含义,您可否再看一下这里是否一定有必要退出呢?谢谢。

Debug level

Please add a "Debug level" control to wechat-go so as to control the level of logging to console, as the following is too much, if we want to keep the session going on for hours and even days:

2017/12/20 19:39:38 [I] webpush.web.wechat.com 0 2
2017/12/20 19:40:05 [I] webpush.web.wechat.com 0 0
2017/12/20 19:40:07 [I] webpush.web.wechat.com 0 2
2017/12/20 19:40:34 [I] webpush.web.wechat.com 0 0
2017/12/20 19:41:00 [I] webpush.web.wechat.com 0 0
2017/12/20 19:41:26 [I] webpush.web.wechat.com 0 0
2017/12/20 19:41:50 [I] webpush.web.wechat.com 0 2
2017/12/20 19:41:51 [W] no handlers for key [47]
2017/12/20 19:42:17 [I] webpush.web.wechat.com 0 0
2017/12/20 19:42:43 [I] webpush.web.wechat.com 0 0
2017/12/20 19:43:10 [I] webpush.web.wechat.com 0 0
2017/12/20 19:43:36 [I] webpush.web.wechat.com 0 0
2017/12/20 19:44:02 [I] webpush.web.wechat.com 0 0
2017/12/20 19:44:28 [I] webpush.web.wechat.com 0 0
2017/12/20 19:44:29 [I] webpush.web.wechat.com 0 2
2017/12/20 19:44:56 [I] webpush.web.wechat.com 0 0
2017/12/20 19:45:08 [I] webpush.web.wechat.com 0 2
2017/12/20 19:45:35 [I] webpush.web.wechat.com 0 0
2017/12/20 19:46:01 [I] webpush.web.wechat.com 0 0
2017/12/20 19:46:28 [I] webpush.web.wechat.com 0 0
2017/12/20 19:46:54 [I] webpush.web.wechat.com 0 0
2017/12/20 19:47:20 [I] webpush.web.wechat.com 0 0
2017/12/20 19:47:46 [I] webpush.web.wechat.com 0 0
2017/12/20 19:48:12 [I] webpush.web.wechat.com 0 0
2017/12/20 19:48:38 [I] webpush.web.wechat.com 0 0
2017/12/20 19:49:04 [I] webpush.web.wechat.com 0 0
2017/12/20 19:49:31 [I] webpush.web.wechat.com 0 0
2017/12/20 19:49:57 [I] webpush.web.wechat.com 0 0
2017/12/20 19:50:23 [I] webpush.web.wechat.com 0 0
2017/12/20 19:50:49 [I] webpush.web.wechat.com 0 0
2017/12/20 19:51:15 [I] webpush.web.wechat.com 0 0
2017/12/20 19:51:22 [I] webpush.web.wechat.com 0 2
2017/12/20 19:51:49 [I] webpush.web.wechat.com 0 0
2017/12/20 19:52:15 [I] webpush.web.wechat.com 0 0
2017/12/20 19:52:41 [I] webpush.web.wechat.com 0 0
2017/12/20 19:53:07 [I] webpush.web.wechat.com 0 0
2017/12/20 19:53:33 [I] webpush.web.wechat.com 0 0
2017/12/20 19:53:59 [I] webpush.web.wechat.com 0 0
2017/12/20 19:54:22 [I] webpush.web.wechat.com 0 2
2017/12/20 19:54:50 [I] webpush.web.wechat.com 0 0
2017/12/20 19:55:16 [I] webpush.web.wechat.com 0 0
2017/12/20 19:55:42 [I] webpush.web.wechat.com 0 0
2017/12/20 19:56:08 [I] webpush.web.wechat.com 0 0
2017/12/20 19:56:34 [I] webpush.web.wechat.com 0 0
2017/12/20 19:57:00 [I] webpush.web.wechat.com 0 0
2017/12/20 19:57:01 [I] webpush.web.wechat.com 0 2
2017/12/20 19:57:02 [W] no handlers for key [43]
2017/12/20 19:57:28 [I] webpush.web.wechat.com 0 0
2017/12/20 19:57:54 [I] webpush.web.wechat.com 0 0
2017/12/20 19:58:04 [I] webpush.web.wechat.com 0 2
2017/12/20 19:58:31 [I] webpush.web.wechat.com 0 0
2017/12/20 19:58:57 [I] webpush.web.wechat.com 0 0
2017/12/20 19:59:09 [I] webpush.web.wechat.com 0 2
2017/12/20 19:59:36 [I] webpush.web.wechat.com 0 0
2017/12/20 20:00:02 [I] webpush.web.wechat.com 0 0
2017/12/20 20:00:28 [I] webpush.web.wechat.com 0 0
2017/12/20 20:00:54 [I] webpush.web.wechat.com 0 0
2017/12/20 20:01:09 [I] webpush.web.wechat.com 0 2
2017/12/20 20:01:31 [I] webpush.web.wechat.com 0 2
2017/12/20 20:01:58 [I] webpush.web.wechat.com 0 0
2017/12/20 20:02:10 [I] webpush.web.wechat.com 0 2
2017/12/20 20:02:11 [W] no handlers for key [47]
2017/12/20 20:02:38 [I] webpush.web.wechat.com 0 0
2017/12/20 20:03:04 [I] webpush.web.wechat.com 0 0
2017/12/20 20:03:30 [I] webpush.web.wechat.com 0 0
2017/12/20 20:03:56 [I] webpush.web.wechat.com 0 0
2017/12/20 20:04:00 [I] webpush.web.wechat.com 0 2
2017/12/20 20:04:27 [I] webpush.web.wechat.com 0 0
2017/12/20 20:04:53 [I] webpush.web.wechat.com 0 0
2017/12/20 20:05:19 [I] webpush.web.wechat.com 0 0
2017/12/20 20:05:37 [I] webpush.web.wechat.com 0 2
2017/12/20 20:06:05 [I] webpush.web.wechat.com 0 0
2017/12/20 20:06:31 [I] webpush.web.wechat.com 0 0
2017/12/20 20:06:57 [I] webpush.web.wechat.com 0 0
2017/12/20 20:07:23 [I] webpush.web.wechat.com 0 0
2017/12/20 20:07:49 [I] webpush.web.wechat.com 0 0
2017/12/20 20:08:14 [I] webpush.web.wechat.com 0 0
2017/12/20 20:08:40 [I] webpush.web.wechat.com 0 0
2017/12/20 20:09:07 [I] webpush.web.wechat.com 0 0
2017/12/20 20:09:32 [I] webpush.web.wechat.com 0 0
2017/12/20 20:09:51 [I] webpush.web.wechat.com 0 2
2017/12/20 20:10:18 [I] webpush.web.wechat.com 0 0
2017/12/20 20:10:44 [I] webpush.web.wechat.com 0 0
2017/12/20 20:11:10 [I] webpush.web.wechat.com 0 0
2017/12/20 20:11:40 [I] webpush.web.wechat.com 0 0

we can finalize the details later...

连发消息会被吞

如果像这样发:

session.SendText("大家好,现在是早晨7点30分。", session.Bot.UserName, group.UserName)
session.SendText("大家好,现在是早晨7点30分。", session.Bot.UserName, group.UserName)
session.SendText("大家好,现在是早晨7点30分。", session.Bot.UserName, group.UserName)

第二条消息就被微信吃了。
如果休息一下就没事了:

session.SendText("大家好,现在是早晨7点30分。", session.Bot.UserName, group.UserName)
time.Sleep(time.Second * 1)
session.SendText("大家好,现在是早晨7点30分。", session.Bot.UserName, group.UserName)
time.Sleep(time.Second * 1)
session.SendText("大家好,现在是早晨7点30分。", session.Bot.UserName, group.UserName)

实测连发给不同用户不会被吞,如这样是可以的:

session.SendText("大家好,现在是早晨7点30分。", session.Bot.UserName, group.UserName)
session.SendText("大家好,现在是早晨7点30分。", session.Bot.UserName, anothergroup.UserName)
session.SendText("大家好,现在是早晨7点30分。", session.Bot.UserName, group.UserName)

请问能否在在SendText的时候主动加个延时或者控制一下前后间隔?

你在readme里应该

你在readme里应该写清楚,这是什么项目,用来做什么,应用场景是 什么。
我觉得我应该对你这个感兴趣,但不知道这是做什么的?

微信web端登录账号被封

前一天拿go-aida项目测试了一两小时,第二天再登录就封了。

[E] session exit, xc.Ret != 0, <error><ret>1203</ret><message>当前登录环境异常。为了你的帐号安全,暂时不能登录web微信。你可以通过Windows微信、Mac微信或者手机客户端微信登录。</message></error>

Using terminal_bot

Same as issues#11, I did:

go build examples/linux/terminal_bot.go
./terminal_bot

运行正常扫码网页登录,然后就看到命令行一堆日志

2017/11/22 06:51:20 [I] entering synccheck loop
2017/11/22 06:51:50 [I] webpush.web.wechat.com 0 0
2017/11/22 06:51:50 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1511351480000&deviceid=e020835203446392&r=1511351480000&sid=99FIil9hg4bBx3oe&skey=%40crypt_73c0b781_67708c6d636e654a635ad9cc2b305a50&synckey=1_667580454%7C2_667580845%7C3_667580399%7C1000_1511345522&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2017/11/22 06:52:20 [I] webpush.web.wechat.com 0 0
2017/11/22 06:52:20 [E] Get https://webpush.web.wechat.com/cgi-bin/mmwebwx-bin/synccheck?_=1511351510000&deviceid=e020835203446392&r=1511351510000&sid=99FIil9hg4bBx3oe&skey=%40crypt_73c0b781_67708c6d636e654a635ad9cc2b305a50&synckey=1_667580454%7C2_667580845%7C3_667580399%7C1000_1511345522&uin=2849091348: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
2017/11/22 06:52:50 [I] webpush.web.wechat.com 0 0

没搞懂 how to verify that it is working fine.

我在聊天窗口输入

美女

but nothing happened.

same for "笑话".

How to verify that it is working fine? Thx.

New plugin welcome?

I'm planing to write a new plugin for your excellent package.
Would you accept PR for it?

I can provide more details if interested.

thx

Wechat ban the wx.qq.com officially

It will return plain text after scanned the qrcode . Wechat just says:

<error><ret>1203</ret><message>For account security, newly registered WeChat accounts are unable to log in to Web WeChat. To use WeChat on a computer, use Windows WeChat or Mac WeChat at http://wechat.com</message></error>

请问怎样获取好友的用户名?

比如我有个好友用户名是yanyuanvip,但Message报文中的原文是:

UserName: @1ce4dc3864239ea574adfde537dc50a0

你知道怎样获取原始的用户名吗?

如何发送Link类型的消息

想要像在微信里一样, 在微信里打开一个链接, 发送给朋友之后, 朋友收到的就是个链接类型的消息, 而不只是一个 url地址, 请问这样的需求能否实现, 如果可以的话, 该怎么做呢, thx

好像登录不了啊

2017/08/01 23:07:39 [I] QcMAj_vkwQ==
2017/08/01 23:08:12 [W] login response, window.code=408;
2017/08/01 23:08:12 [E] session exit, login response, window.code=408;
2017/08/01 23:08:12 [I] trying re-login with cache
2017/08/01 23:08:12 [E] re-login error, Post /webwxinit?pass_ticket=&r=1501600092&skey=: unsupported protocol scheme ""
2017/08/01 23:08:15 [I] trying re-login with cache
2017/08/01 23:08:15 [E] re-login error, Post /webwxinit?pass_ticket=&r=1501600095&skey=: unsupported protocol scheme ""
2017/08/01 23:08:18 [I] trying re-login with cache
2017/08/01 23:08:18 [E] re-login error, Post /webwxinit?pass_ticket=&r=1501600098&skey=: unsupported protocol scheme ""
2017/08/01 23:08:23 [I] AY19yPPqmA==
2017/08/01 23:08:56 [W] login response, window.code=408;
2017/08/01 23:08:56 [E] session exit, login response, window.code=408;
2017/08/01 23:08:56 [I] trying re-login with cache
2017/08/01 23:08:56 [E] re-login error, Post /webwxinit?pass_ticket=&r=1501600136&skey=: unsupported protocol scheme ""
2017/08/01 23:08:59 [I] trying re-login with cache
2017/08/01 23:08:59 [E] re-login error, Post /webwxinit?pass_ticket=&r=1501600139&skey=: unsupported protocol scheme ""
2017/08/01 23:09:02 [I] trying re-login with cache
2017/08/01 23:09:02 [E] re-login error, Post /webwxinit?pass_ticket=&r=1501600142&skey=: unsupported protocol scheme ""

扫码登陆失败了

Terminal 里提示这个报错:

2017/05/09 09:29:55 [E] invalid response, window.code=201;
2017/05/09 09:30:00 login failed:expected element type <error> but have <script>

不能获取群组信息

songtianyi,
你好,我正在学习你的代码。我测试时发现,在forwarder.go文件中,
执行下列步骤时,一直出错
var contact *wxweb.User if msg.FromUserName == session.Bot.UserName { contact = session.Cm.GetContactByUserName(msg.ToUserName) } else { contact = session.Cm.GetContactByUserName(msg.FromUserName) } if contact == nil { return }
这里的contact始终为nil,而这时的contactUserName即是以@@开头的群组的username,不知道大家没有遇到过这个问题。

朋友圈支持?

谢谢项目的开发,看起来很不错 :)
想问一下有计划对朋友圈的支持么?这个在技术上是否可行?

登录12小时之后就会收掉线

linux (16.04)上测试只能保持在线12小时,之后就会接受不到消息

细节

  1. SyncCheck会收到1102返回码,再也接受不到消息。

  2. 尝试在收到1102后切换到其他可用的服务也无法重连 。
    SyncSrv: "webpush.wx.qq.com",
    SyncSrv: "wx2.qq.com",

  3. 然后尝试使用定时器每隔3分钟在上面两个服务之间切换也没有作用。

  4. 新号老号测试结果都这样。

有没有人遇到一样的情况呢?谢谢指教。

新号,已实名,无法登录

返回如下:

<error><ret>1203</ret><message>为了你的帐号安全,此微信号已不允许登录网页微信。你可以使用Windows微信或Mac微信在电脑端登录。Windows微信下载地址:https://pc.weixin.qq.com Mac微信下载地址:https://mac.weixin.qq.com</message></error>

有解决办法吗?谢谢!

[bug] mkdir err, in rrframework/storage/local.go

func CreateLocalDiskStorage(dir string) StorageWrapper {
	// create dir
	if _, err := os.Stat(dir); os.IsNotExist(err) {
               // here the dirctory FileMode is error 
		os.MkdirAll(dir, os.ModePerm)
	}
	// check dir
	s := &LocalDiskStorage{
		Dir: strings.TrimSuffix(dir, "/"),
	}
	return s
}

无法获取联系人信息

现在WebWxGetContact接口获取到的联系人信息为空, 而 WebWxInit 接口则会返回联系人信息

30秒后没有扫吗登录报error

2017/09/07 11:01:32 [W] login response, window.code=408;
2017/09/07 11:01:32 [E] session exit, login response, window.code=408;
2017/09/07 11:01:32 [I] trying re-login with cache
2017/09/07 11:01:32 [E] re-login error, Post /webwxinit?pass_ticket=&r=1504753292&skey=: unsupported protocol scheme ""
2017/09/07 11:01:35 [I] trying re-login with cache
2017/09/07 11:01:35 [E] re-login error, Post /webwxinit?pass_ticket=&r=1504753295&skey=: unsupported protocol scheme ""
2017/09/07 11:01:38 [I] trying re-login with cache
2017/09/07 11:01:38 [E] re-login error, Post /webwxinit?pass_ticket=&r=1504753298&skey=: unsupported protocol scheme ""
@songtianyi

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.