Giter VIP home page Giter VIP logo

oicq's Introduction

oicq

npm version dm node engine discord

  • QQ(安卓)协议基于Node.js的实现,使用CQHTTP风格的API
  • 高度抽象地封装了大部分常用功能,支持最低node版本为 v12.16
  • 若你不熟悉Node.js或不会组织代码,可通过 template 创建一个简单的应用程序
  • API参考文档 / 事件参考文档 / wiki列表

Install:

> npm i oicq  # or > yarn add oicq

Usage:

const { createClient } = require("oicq");
const account = 123456789;
const client = createClient(account);

//监听上线事件
client.on("system.online", () => console.log("Logged in!"));

//监听消息并回复
client.on("message", (event) => event.reply("hello world"));

/****************************************
 * 手机QQ扫描二维码登录(与下面的密码登录二选一)
 * 优点是不需要过滑块和设备锁
 * 缺点是万一token失效,无法自动登录,需要重新扫码
 */
client.on("system.login.qrcode", function (event) {
  process.stdin.once("data", () => {
    this.login(); //扫码后按回车登录
  });
}).login(); //这里不填写密码

//-------------------------------------------------------------------------

/****************************************
 * 密码登录
 * 缺点是需要过滑块,可能会报环境异常
 * 优点是一劳永逸
 */
client.on("system.login.slider", function (event) { //监听滑动验证码事件
  process.stdin.once("data", (input) => {
    this.sliderLogin(input); //输入ticket
  });
}).on("system.login.device", function (event) { //监听登录保护验证事件
  process.stdin.once("data", () => {
    this.login(); //验证完成后按回车登录
  });
}).login("password"); //需要填写密码或md5后的密码

常用功能:

client.sendGroupMsg(gid, "hello") //群聊
client.sendPrivateMsg(uid, "hello") //私聊
client.deleteMsg(id) //撤回
client.setGroupKick(gid, uid) //踢人
client.setGroupBan(gid, uid, 3600) //禁言

全局安装并启动:

可作为 http-api 或调试程序使用

> npm i -g oicq
> oicq <account>

其他:

group:236172566

oicq's People

Contributors

14kay avatar clansty avatar cloud370 avatar goodspeed34 avatar juergenie avatar steve-xmh avatar takayama-lily avatar thesnowfield avatar

Watchers

 avatar

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.