• This repository has been archived on 05/Jun/2018
  • Stars
    star
    1,814
  • Rank 25,594 (Top 0.6 %)
  • Language
    Java
  • License
    MIT License
  • Created about 10 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🗯 wechat-api by java7.

wechat-api

wechat-api 是微信个人号的Java版本API,让个人号具备更多能力,提供方便的接口调用。

在线文档

@biezhi on zhihu

特性

  • 使用简单,引入依赖即可
  • 支持本地图片和终端输出二维码
  • 本地自动登录
  • 支持文本、图片、视频、撤回消息等
  • 支持发送文本、图片、附件
  • 注解绑定消息监听
  • 群聊、单聊支持
  • 添加好友验证
  • 撤回消息获取
  • JDK7+

使用

本地开发的同学请先安装 lombok 插件并确保你的JDK环境是1.7+

引入 maven 依赖

<dependency>
    <groupId>io.github.biezhi</groupId>
    <artifactId>wechat-api</artifactId>
    <version>1.0.6</version>
</dependency>

构建自己的小机器人

public class HelloBot extends WeChatBot {
    
    public HelloBot(Config config) {
        super(config);
    }
    
    @Bind(msgType = MsgType.TEXT)
    public void handleText(WeChatMessage message) {
        if (StringUtils.isNotEmpty(message.getName())) {
            log.info("接收到 [{}] 的消息: {}", message.getName(), message.getText());
            this.sendMsg(message.getFromUserName(), "自动回复: " + message.getText());
        }
    }
    
    public static void main(String[] args) {
        new HelloBot(Config.me().autoLogin(true).showTerminal(true)).start();
    }
    
}

Bot API

/**
 * 给文件助手发送消息
 *
 * @param msg 消息内容
 * @return 发送是否成功
 */
boolean sendMsgToFileHelper(String msg);

/**
 * 给某个用户发送消息
 *
 * @param name 用户UserName
 * @param msg  消息内容
 * @return 发送是否成功
 */
boolean sendMsg(String name, String msg);

/**
 * 根据名称发送消息
 *
 * @param name 备注或昵称,精确匹配
 * @param msg  消息内容
 * @return 发送是否成功
 */
boolean sendMsgByName(String name, String msg);

/**
 * 给某个用户发送图片消息
 *
 * @param name    用户UserName
 * @param imgPath 图片路径
 * @return 发送是否成功
 */
boolean sendImg(String name, String imgPath);

/**
 * 根据名称发送图片消息
 *
 * @param name    备注或昵称,精确匹配
 * @param imgPath 图片路径
 * @return 发送是否成功
 */
boolean sendImgName(String name, String imgPath);

/**
 * 给用户发送文件
 *
 * @param name     用户UserName
 * @param filePath 文件路径
 * @return 发送是否成功
 */
boolean sendFile(String name, String filePath);

/**
 * 根据名称发送文件消息
 *
 * @param name     备注或昵称,精确匹配
 * @param filePath 文件路径
 * @return 发送是否成功
 */
boolean sendFileName(String name, String filePath);

更多API见文档

TODO

  1. 接收位置
  2. 撤回消息查看
  3. 发送文件消息
  4. 多线程处理消息

开源协议

MIT

More Repositories

1

java-bible

🍌 我的技术摘要
HTML
2,984
star
2

30-seconds-of-java8

30 seconds to collect useful Java 8 snippet.
Java
2,368
star
3

learn-java8

💖《跟上 Java 8》视频课程源码
Java
1,382
star
4

oh-my-email

📪 可能是最小的 Java 邮件发送库了,支持抄送、附件、模板等功能。
Java
711
star
5

profit

🤔 biezhi 在线打赏系统,开启你的要饭生涯。
Java
404
star
6

write-readable-code

🗾 编写可读代码的艺术代码仓库
Java
401
star
7

elves

🎊 Design and implement of lightweight crawler framework.
Java
317
star
8

anima

Minimal database operation library.
Java
227
star
9

java-library-examples

💪 example of common used libraries and frameworks, programming required, don't fork man.
Java
215
star
10

excel-plus

❇️ Improve the productivity of the Excel operation library. https://hellokaton.github.io/excel-plus/#/
Java
191
star
11

gorm-paginator

gorm pagination extension
Go
154
star
12

java-tips

🍓 Java 语言编程技巧、最佳实践
Java
149
star
13

gitmoji-plugin

Choose the right emoji emoticon for git commit, make git log commit more interesting.
Kotlin
112
star
14

java11-examples

java 11 example code
Java
98
star
15

telegram-bot-api

🤖 telegram bot api by java, help you quickly create a little robot.
Java
85
star
16

code-fonts

编程语言中流行的 8 款代码字体
PHP
63
star
17

lets-golang

《给 Java 程序员的 Go 私房菜》源码仓库
Go
62
star
18

oh-mybatis

🎈 A simple web app to generate mybatis code.
Java
60
star
19

terse

🍋 my typecho blog theme, Concise UI
CSS
59
star
20

hellokaton.com

✍️ https://hellokaton.com source code
HTML
46
star
21

webp-io

🌚 general format images and webp transform each other
Java
44
star
22

redis-dqueue

redis base delay queue
Java
44
star
23

oh-my-request

🔮 simple request library by java8
Java
43
star
24

oh-my-session

🍖 distributed session storage scheme, using redis to store data.
Java
42
star
25

swing-generate

🙊 Swing development code generator
Java
36
star
26

ss-panel

🐒 java shadowsocks panel(java版本shadowsocks面板)
HTML
34
star
27

industry-glossary

汇集行业英文术语,让你命名不在困难。
33
star
28

freechat

🐶 online anonymous chat application.
CSS
29
star
29

grice

🐜 A simple web document engine written by java.
CSS
29
star
30

goinx

💞 Multi-domain proxy by golang, fuck gfw proxy
Go
28
star
31

springmvc-plupload

🍃 Springmvc and servlet shard to upload demo
JavaScript
27
star
32

lowb

🤦🏻‍♂️ teach you to develop command-line source code using NodeJS
JavaScript
27
star
33

geekbb

😎 Geek dev club.
JavaScript
26
star
34

keeper

Java
25
star
35

mini-jq

🍣 mininal jquery, you don't need jquery!
JavaScript
21
star
36

spring-boot-examples

🕷 spring boot and spring cloud examples
Java
20
star
37

bye-2017

👋 Bye! my 2017
CSS
19
star
38

weather-cli

💊 weather command-line programs written in Golang.
Go
18
star
39

go-examples

🍄 learning golang code
Go
16
star
40

oh-my-jvm

☕️ using golang write jvm
Go
16
star
41

nice

🐹 使用blade开发的一款简洁的图片社交应用
Java
16
star
42

blog

blog source code
SCSS
16
star
43

learn-cute-netty

《可爱的Netty》源码仓库
Java
15
star
44

eve

👻 everyday explore, Github / HackNews / V2EX / Medium / Product Hunt.
Go
13
star
45

blade-cli

🐳 blade mvc cli application
Go
13
star
46

agon

🦉 my golang utilities, log json config and other
Go
12
star
47

wechat-api-examples

wechat-api examples, used java8.
Java
12
star
48

telegram-lottery

🤖 A telegram lottery bot that helps you achieve random rewards for group activities.
Go
11
star
49

java8-best-practices

java8 best practices source code.
Java
11
star
50

runcat_pyside

Python PySide6 of RunCat_for_windows
Python
10
star
51

dbkit

🚧 convenient implement of Database timing backup tool.
Go
10
star
52

lets-python

🍭 learning Python code
Python
9
star
53

java-2048

🎲 Java swing of 2048
Java
9
star
54

mapper-spring-boot-starter

通用mapper+pagehelper的spring boot starter
Java
9
star
55

blade-lattice

🔐 lightweight authentication and authorization, born for Blade.
Java
9
star
56

writty

🌝 A garbage writing platform, has given up.
Java
9
star
57

java-clojure-syntax-comparison

⚔️ Comparison of some code snippets in the Java and Clojure.
9
star
58

emojis

this is emoji images
8
star
59

ppocr-api

飞桨 OCR API Docker 镜像
Python
7
star
60

show-code

🌝 show github repositories card with html
JavaScript
7
star
61

probe

exploring the world beyond the wall, netty4 based proxy service.
Java
7
star
62

oh-my-monitor

🌈 C/S mode server monitoring (discontinuation of maintenance)
Java
6
star
63

moe

😛 simple cli spinner by golang.
Go
5
star
64

witty

🐝 witty is a smart golang robot
Go
5
star
65

gow

🙄 gow!!! a micro go web framework.
Go
5
star
66

primer-series

从入门到放弃系列衬衫生成器
CSS
5
star
67

spring-boot-starter-jetbrick

🐥 jetbrick-template的spring-boot starter
5
star
68

fastapi-tutorial

Here are some sample programs for me to learn fastapi.
Python
5
star
69

helidon-examples

💣 helidon framework example
Java
5
star
70

hellokaton

3
star
71

bar

🍺 static website builder written by golang
Go
3
star
72

tomato-clock

JavaScript
2
star
73

findor

🌟 let the world find you !
2
star
74

vite-react-mpa-example

React + Vite multi page application example
TypeScript
2
star
75

typecho-theme-modernist

a typecho theme modernist
PHP
2
star
76

homebrew-tap

Homebrew tap for biezhi/eve
Ruby
1
star
77

clojure-todo-list

The todo-list application that used clojure + ring
Clojure
1
star
78

juejun-alfred-workflow

a simple juejin alfred workflow example
Python
1
star