5 Star 18 Fork 1

Memory_Leak / wxbot

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

WXBot

wxbot是使用Kotlin基于网页版微信开发的微信SDK。

示例

发送消息

import cn.fuser.tool.net.QRPrinter
import java.io.File

fun main(args: Array<String>) {
    val auth = AuthValidator({ QRPrinter(it).print(System.err) }).validate()
    val bot = WXBot(auth)
    bot.heartbeat()
    val members = bot.contact().list.filter { it.userName.startsWith("@@") }
    members.forEach({
        // 发送文本消息    
        bot.sendText(it.userName, it.userName)
        // 发送图片消息
        bot.sendImg(it.userName, File("****"))
    })
}

转发消息

package cn.fuser.vx.wxbot

import cn.fuser.tool.net.Log
import cn.fuser.tool.net.QRPrinter

fun main(args: Array<String>) {
    val auth = AuthValidator({ QRPrinter(it).print(System.err) }).validate()
    val bot = WXBot(auth)
    bot.heartbeat()
	// 根据昵称查找用户
    val members = bot.contact().list.find { it.nickName.startsWith("***") }
    bot.registerHandler(SimpleMessageHandler {
        Log.info("message[%d] %s: %s", it.msgType, it.fromUserName, it.content)
        if (it.msgType != 1) return@SimpleMessageHandler
		// userName以@@开头则为微信群消息
        val content = if (it.fromUserName.startsWith("@@")) it.content.substringAfter(":<br/>") else it.content
        bot.sendText(members!!.userName, content)
    })
}

关于二维码扫描

wxbot根据Python版本的kdepp/tty_qr.py实现了输出二维码为字画的工具cn.fuser.tool.QRPrinter,可输出二维码到控制台.

亦可实现(BufferedImage) -> Unit传入AuthValidator进行其它操作. 控制台输出二维码效果如下: 控制台输出二维码效果

author: @Memory_Leak

Repository Comments ( 3 )

Sign in to post a comment

About

个人微信号接口(Kotlin版本) expand collapse
Kotlin and 2 more languages
Cancel

Releases

No release

wxbot

Contributors

All

Activities

Load More
can not load any more
Kotlin
1
https://git.oschina.net/irealing/wxbot.git
git@git.oschina.net:irealing/wxbot.git
irealing
wxbot
wxbot
master

Search