Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块 #81

Open
huan opened this issue Apr 22, 2021 · 61 comments
Open

开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块 #81

huan opened this issue Apr 22, 2021 · 61 comments

Comments

@huan
Copy link
Member

huan commented Apr 22, 2021

开源软件供应链点亮计划

“开源软件供应链点亮计划-暑期2021”(以下简称 暑期2021)是由中科院软件所与 openEuler 社区共同举办的一项面向高校学生的暑期活动,旨在鼓励在校学生积极参与开源软件的开发维护,促进国内优秀开源软件社区的蓬勃发展。

根据项目的难易程度和完成情况,参与者还可获取“开源软件供应链点亮计划-暑期2021”活动奖金和奖杯。

官网:https://summer.iscas.ac.cn

Wechaty

Wechaty 是一个开源聊天机器人框架SDK,具有高度封装、高可用的特性,支持NodeJs, Python, Go 和Java 等多语言版本。在过去的5年中,服务了数万名开发者,收获了 Github 的 9600 Star。同时配置了完整的DevOps体系并持续按照Apache 的方式管理技术社区。

项目名称

开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块

背景介绍

Wechaty 社区目前已经支持微信、Whatsapp、企业微信、飞书等常见流行即时通讯工具,并且能够通过多语言 SDK (比如 Python Wechaty) 进行调用。

QQ 是国内和微信并列的两大聊天软件。我们在本次 Summer 2021 的项目中,Wechaty 希望可以实现对 QQ Chatbot 的支持。通过 Wechaty Puppet 的接口,可以将 QQ 进行 RPA 封装,使其成为 wechaty-puppet-qq 供 Wechaty 开发者方便接入 QQ 平台,使其成为 Wechaty 可以使用的社区生态模块。

需求介绍

使用 https://github.com/wechaty/wechaty-puppet-mock 项目作为模版,参考社区其他的 Wechaty Puppet Provider 代码模块,对 QQ 进行规划、RPA选型、原型测试,和最终的代码封装。

这里有一个专门讲解如何开发 Wechaty Puppet Provider 的 workshop 视频,它以 wechaty-puppet-official-account 作为例子,做了从0到1的入门讲解:Wechaty Workshop for Puppet Makers: How to make a Puppet for Wechaty。通过观看这一个小时的视频,应该可以系统性的了解如何完成构建一个 Wechaty Puppet Provider 模块。

在初期开发中,能够实现文本消息的接收和发送,即可完成原型验证 POC 。

还可以参考以下链接:

  1. TypeScript Puppet Official Documentation: https://wechaty.github.io/wechaty-puppet/typedoc/classes/puppet.html
  2. Wechaty Puppet Specification: https://wechaty.js.org/docs/specs/puppet
  3. https://github.com/wechaty/wechaty-puppet-mock

项目难度

中(奖金:9000元)

导师联系方式

  1. 李佳芮: Wechaty co-creator, Founder & CEO of Juzi.BOT (rui@chatie.io)
  2. 李卓桓:Wechaty creator, Tencent TVP of Chatbot (huan@chatie.io)

项目产出目标

  1. 每日代码 commit
  2. 每周提交一份 report (回复本 issue)
  3. 每两周一次在线会议
  4. 发布 Git Repo wechaty-puppet-qq
  5. 可以通过 Wechaty 加载 wechaty-puppet-qq 模块,并通过 QQ RPA 底层,实现文本消息的收发功能
  6. 提供一个 examples/ding-dong-bot.ts ,完成“接收到文字消息ding时,自动回复消息dong"的功能
  7. 配置 GitHub Actions 实现自动化测试* (可选)

项目技术栈

  1. TypeScript programming language
  2. Git
  3. RPA

Links

@anaivebird
Copy link

开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块
一、详细方案

  在初期开发中,能够实现文本消息的接收和发送,即可完成原型验证 POC 。

  • 实现方案
    通过对Wechaty Puppet Provider和wechaty-puppet-mock项目等进行了解和学习,并对已有项目进行梳理,多和导师进行沟通,实现通过 Wechaty 加载 wechaty-puppet-qq模块,并包装oicq项目,实现文本消息的收发功能,提供一个 examples/ding-dong-bot.ts ,完成“接收到文字消息ding时,自动回复消息dong"等功能。

二.项目开发时间计划

  • 第一阶段(7月-8月)
    a) 7.1-7.10
    先和导师沟通,并观看Wechaty Puppet Provider 的 workshop 视频,熟悉Wechaty Puppet Provider的业务流程,并对自己目前还没有掌握的nodejs、npm、typescript等内容进行快速的了解和学习,对时间安排做好具体的规划
    b) 7.11-8.15
    开始正式进行代码的prototyping,先完成基础的功能,完成通过 Wechaty 加载 wechaty-puppet-5g-qq 模块,并通过oicq项目实现的qq协议,实现文本消息的收发功能。每周协同导师进行功能的开发和完善

  • 第二阶段(8月-10月)
    在现有基础上,滑动验证码登陆、设备锁、qq登陆风控等问题进行调研和排查
    a) 8.16-9.30
    继续完善功能,完成“接收到文字消息ding时,自动回复消息dong"的功能,不断总结和完善功能列表。
    b) 10.1-10.30
    如果还有功能模块未完成则继续优化代码,梳理项目,如果时间充足,可以尝试完成一下配置 GitHub Actions 实现自动化测试的任务。

@anaivebird
Copy link

[开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块] 进度报告

日期:2021-07-18

本周完成的成果

  • 列出将要进行开发的功能模块
  • node.js qq protocol client implement(based on takayama-lily/oicq)
  • Puppeteer
  • puppet for qq wrapper
  • 设备信息存储
  • 滑块登陆
  • 完成项目的初期报告

本周遇到的困难和需要配合的地方

  • 在push期初报告时,对npm的使用还是很不熟练,特别是package.json等文件的标准,还有github pull request的流程
  • 本周我主要在进行组内科研项目的研究,所以项目进展不大

下周的开发计划和预计成果

  • 着手对oicq模块进行初步的调用和连接

其他需要说明和同步的事项

暂无

@huan
Copy link
Member Author

huan commented Jul 19, 2021

Some links, just FYI:

  1. 开发一个简单的QQ机器人: "酷Q是国内一个运维了很久的QQ机器人软件" have we tried this project? Is there anyone who knows how good is it?
  2. MsgIPC是通过Hook的方式截取QQ消息并通过zeromq发布的一款dll插件

@anaivebird
Copy link

开发一个简单的QQ机器人:
https://cloud.tencent.com/developer/article/1623861

"酷Q是国内一个运维了很久的QQ机器人软件" have we tried this project, is there anyone knows how good is it?

Yeah, that's a famous project (but not open source) whose author decided to stop working on it due to other author received lawsuit by Tencent. Its legendary code is no longer valid, but later developers made project like go-cqhttp which is API compatible and open source

@huan
Copy link
Member Author

huan commented Jul 19, 2021

I'm sorry to hear that the author of CoolQ decides not to maintain it anymore.

I believe the community effort will continue to make the QQ chatbot long live, like the oicq project which you are working on looks great.

Looking forward to seeing the first ding/dong bot for your wechaty-puppet-qq project!

@anaivebird
Copy link

[开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块] 进度报告

日期:2021-07-25

本周完成的成果

  • 阅读wechaty-puppet-lark的代码结构
  • 申请注册并配置lark机器人
  • 对wechaty-puppet-wechat的代码类依赖结构和函数调用链进行了探究
  • 对ES2016的Promise和await为代表的异步写法进行了系统性学习 (javascript-es6-promises-for-beginners)

本周遇到的困难和需要配合的地方

  • 没法给飞书机器人发消息
    image

下周的开发计划和预计成果

  • 直接尝试完成对wechaty-qq-puppet的ding dong

其他需要说明和同步的事项

未来可以通过视频讲解wechaty、puppet等类之间的调用关系

@huan
Copy link
Member Author

huan commented Jul 28, 2021

I hope the ding/dong bot for qq puppet will be available soon!

@huan
Copy link
Member Author

huan commented Aug 3, 2021

Hi @anaivebird,

It seems that you have failed to submit your weekly report on time, please submit as soon as you can to fix this problem.

Do not miss the deadline is your responsibility for our OSPP'21 project, and it will be one of the important evaluations to your final score.

I also want to learn about the process of the ding/dong bot for qq, please update, I hope you have some outcomes for now.

Thank you very much.

@anaivebird
Copy link

When I write class PuppetQQ extends Puppet, lots of methods must be implemented, otherwise typescript error will be thrown.

Non-abstract class 'PuppetQQ' does not implement inherited abstract member 'contactSelfName' from class 'Puppet'.ts(2515)

Any good advice on this point?

@huan
Copy link
Member Author

huan commented Aug 9, 2021

Hi @anaivebird ,

  1. Please submit your delayed work report for the past week, and the week before past week (total 2), which is required from you by the Wechaty OSPP'21 project.
  2. For your question about "lots of methods must be implemented", you can refer to the code at here

Please let me know when you can finish the reports, and please keep in mind that it's time to submit the mid-term report as well.

Thank you very much.

@anaivebird
Copy link

[开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块] 进度报告

日期:2021-08-02

本周完成的成果

  • oicq单文件运行
  • typescript继承、构造器
  • 重点研究wechaty-puppet-official-account和wechaty-puppet-lark的源代码

本周遇到的困难和需要配合的地方

下周的开发计划和预计成果

  • 跑通ding dong,并完成对环境变量中QQ号和密码的读取以及扫码功能

其他需要说明和同步的事项

暂无

@anaivebird
Copy link

[开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块] 进度报告

日期:2021-08-09

本周完成的成果

  • 继续研究wechaty-puppet-official-account和wechaty-puppet-lark的源代码
  • 完成QQ,ding dong基础(但没有小号所以无法登录)
    image

本周遇到的困难和需要配合的地方

  • 需要一个登录后不会被风控,也不会被封号的QQ号,大号暂时不敢测试

下周的开发计划和预计成果

  • 用QQ小号跑通ding dong,并支持群中ding dong

其他需要说明和同步的事项

暂无

@huan
Copy link
Member Author

huan commented Aug 9, 2021

It's great to see you have submitted the working report for the past two weeks, as well as hearing from you that you will actively take part in writing the middle-term report.

I hope you can finish the ding-dong bot soon by following your proposed plan/milestones with this project, and make sure to "每周协同导师进行功能的开发和完善" by submitting GitHub issues and Pull Requests:

第一阶段(7月-8月)
a) 7.1-7.10
先和导师沟通,并观看Wechaty Puppet Provider 的 workshop 视频,熟悉Wechaty Puppet Provider的业务流程,并对自己目前还没有掌握的nodejs、npm、typescript等内容进行快速的了解和学习,对时间安排做好具体的规划
b) 7.11-8.15
开始正式进行代码的prototyping,先完成基础的功能,完成通过 Wechaty 加载 wechaty-puppet-5g-qq 模块,并通过oicq项目实现的qq协议,实现文本消息的收发功能。每周协同导师进行功能的开发和完善

@anaivebird
Copy link

ok, got it. I'm currently attentive to the following to working up the ding-dong.

your question about "lots of methods must be implemented", you can refer to the code at here

@anaivebird
Copy link

currently, bridging oicq and wechaty events will be my priority, since ding dong has worked. Also, polishing code will be priority of my work this week.
image

on oicq, their event system looks like these:
`const bot = require("oicq").createClient(this.QQNumber)

bot.on("system.login.qrcode", function (this:any) {
  console.info("press enter after scanning the QR code");
  process.stdin.once("data", () => {
    console.log('enter pressed, try to login')
    this.login()
  })
})
.on("system.login.error", function (this:any, error: any) {
  if (error.code < 0)
    this.login()
})
.login()


bot.on("message", function (e: any) {
  console.log('got message', e.raw_message)
  if (e.raw_message === "hello") {
    e.reply("hello world")
  }
})`

system.login.qrcode seem to equivalent of wechaty's onScan
message is equivalent of wechaty's message

@anaivebird
Copy link

It seems it I need to extend EventEmitter to implement the event transform between oicq and wechaty like this

image

@huan
Copy link
Member Author

huan commented Aug 9, 2021

Great progress, congratulations!

I believe what the most important you need focusing to do is the below two tasks:

  1. Prepare to create a repo with the template from https://github.com/wechaty/wechaty-puppet-mock with the name wechaty-puppet-oicq
  2. Make the ding-dong-bot.ts work with your new puppet.

After you finish the above two tasks, then we will be able to prepare to publish it to the NPM, and then we will be able to start working the ding-dong-bot.ts with Wechaty.

@anaivebird
Copy link

Hi, I'm currently referring to this, and found the puppet-message-processing-flow is both well-designed and much sophisticated for me to understand. So, it will take me more hours to capture the whole message processing flow.

What most confuse me is how to construct a message with message text, sender id and other informations?

  // where is message id from?
  qq_puppet.emit('message', {
    messageId: '123456',
  })
// following code is error in typescript, so what is correct way to construct a message payload 
// and emit it to puppet event which should be received by onMessage function on ding-dong.ts

this.oicq_bot.on("message", function (e: oicqMessagePayload) {
   console.log('got message', e.raw_message)

   const payload: MessagePayload = {
     e.user_id,
     id: e.message_id,
     e.raw_message,
     timestamp: Date.now(),
     toId,
     type: MessageType.Text,
   }
}

@anaivebird
Copy link

About 1:20:00 of the video tutorial solved my problem about message processing pipeline of wechaty-puppet.

@anaivebird
Copy link

puppet method messageRawPayload called before bot received first message, so messageId could not be found on messageStore and program crashed with key not found error

image

image

@anaivebird
Copy link

anaivebird commented Aug 10, 2021

contact-mock.ts emitted the message event
image

@anaivebird
Copy link

vscode plugin eslint must be installed for tslint check so that code could pass pre-push hook check.
image

@huan
Copy link
Member Author

huan commented Aug 12, 2021

@anaivebird
Copy link

All of these three finished, except that CI can't become green due to QQ login QR code couldn't be scanned when CI try to run "npm run start".

@anaivebird
Copy link

Also blog is still on progress, but it will be delivered soon.

@anaivebird
Copy link

[开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块] 进度报告

日期:2021-08-15

本周完成的成果

  • 修改成功:将登录的QQ好作为环境变量传入puppet
  • 完成QQ,并ding dong的live demo,并上传到了Youtube
  • 完成了中期项目报告

本周遇到的困难和需要配合的地方

  • 暂无

下周的开发计划和预计成果

  • 进一步对OnScan事件根据WeChaty需要的格式进行修改
  • 完成中期报告博客,并上传wechaty.js.org的repo

其他需要说明和同步的事项

暂无

@anaivebird
Copy link

中期报告: WECHATY PUPPET OICQ (基于OICQ项目的QQ机器人)

项目信息

项目名称

开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块

项目背景

Wechaty 社区目前已经支持微信、Whatsapp、企业微信、飞书等常见流行即时通讯工
具,并且能够通过多语言 SDK (比如 Python Wechaty) 进行调用。
QQ 是国内和微信并列的两大聊天软件。我们在本次 Summer 2021 的项目中,Wechaty
希望可以实现对 QQ Chatbot 的支持。通过 Wechaty Puppet 的接口,可以将 QQ 进行 RPA 封装,使其成为 wechaty-puppet-qq 供 Wechaty 开发者方便接入 QQ 平台,使其成
为 Wechaty 可以使用的社区生态模块。

方案描述

使用 https://github.com/wechaty/wechaty-puppet-mock 项目作为模版,参考社区其他
的 Wechaty Puppet Provider 代码模块,对 QQ 进行规划、RPA 选型、原型测试,和最终
的代码封装。
构建一个 Wechaty Puppet Provider 模块。 在初期开发中,能够实现文本消息的接收和发送,即可完成原型验证 POC。

项目技术栈

  1. TypeScript programming language
  2. Git
  3. RPA

时间规划

  • 第一阶段(7月-8月)

    • 7.1-7.10(已如期完成)

      先和导师沟通,并观看Wechaty Puppet Provider 的 workshop 视频,熟悉Wechaty Puppet Provider的业务流程,并对自己目前还没有掌握的nodejs、npm、typescript等内容进行快速的了解和学习,对时间安排做好具体的规划

    • 7.11-8.15(已如期完成)

      开始正式进行代码的prototyping,先完成基础的功能,完成通过 Wechaty 加载 wechaty-puppet-5g-qq 模块,并通过oicq项目实现的qq协议,实现文本消息的收发功能。每周协同导师进行功能的开发和完善

  • 第二阶段(8月-10月)

    在现有基础上,滑动验证码登陆、设备锁、qq登陆风控等问题进行调研和排查

    • 8.16-9.30(即将完成)

      将CI(持续集成)的测试跑通,如果时间充足,可以尝试完成一下配置 GitHub Actions 实现自动化测试的任务。

    • 10.1-10.30(即将完成)

      继续完善功能,将消息接收,扩展到群聊天消息、图片消息等领域。

项目进度

已完成部分

  1. wechaty.js.org的博客的配置
  2. npm项目包的安装
  3. typescript开发环境的熟悉
  4. github pull request使用的全流程
  5. wechaty-puppet-oicq模块的ding dong的完成(扫码即可运行QQ机器人,发送ding给机器人,即可收到dong的消息)

完全按照有计划顺利进行,还略有加快。

遇到的困难与解决

  • 中途实习繁忙和生病导致拉下两周进度

    虽然中间有生病,拉下两周,但也已经通过提高效率,重点攻克项目难点,成功赶上进度,并略有提前。

  • wechaty消息处理链路相对复杂,难以理解

    通过咨询项目导师和wechaty飞书机器人负责人等途径,观看社区livecoding视频,对消息处理进行快速学习,并通过编码实践,最终成功将oicq的事件和消息格式转换为了wechaty的messageRawPay,也加深了对框架架构设计的理解。

  • 遇到QQ风控
    通过途径弄到了一些QQ小号方便测试。

后续工作安排

按照原计划继续进行,并且尽可能对图片消息、语音消息等增加支持,使wechaty-puppet-oicq成为事件和API支持非常详细的机器人协议提供端。

@lijiarui
Copy link
Member

评审结果

  • 项目完成度:整个项目按照原定方案在实施。在项目实施过程中,完成了puppet底层的技术选型和基础的代码提交,同时完成了 NPM 的发布,完成情况较好。
  • 学生参与度:学生暑期安排较多,并在中途生病,后期重新进行进度跟进,参与度较好
  • 代码贡献量:已完成初步的模块收发消息的开发,并准备了 NPM 的发布,代码贡献量较好。
  • 综合评价及建议:总体来说项目完成情况不错,按照既定的规划稳定实施,项目功能模块也在逐步的完成。存在的问题如下:
    • 1、项目目前还未涉及到qq通讯录的获取,后期有待完善;
    • 2、尚未调整 CI 到通过测试,后续需要完善
  • 最终评审结果:“通过”

@huan
Copy link
Member Author

huan commented Sep 10, 2021

Thanks for the update.

实习结束回收mac之后,本地暂无linux系统做开发,需要安装linux系统

I'd like to suggest that you can try our community server:

You can use this server for development.

And the most important work is to make the ding/dong bot workable with our wechaty-getting-start repo.

The ding/dong bot should be finished before the mid-term report, which has already been delayed. I hope you can finish it soon.

Related steps:

  1. Publish wechaty-puppet-oicq to npm
  2. run WECHATY_PUPPET=wechaty-puppet-oicq npm start successfully with our ding/dong bot

@anaivebird
Copy link

image
Wechaty Getting Started project broken on gitpod, prohibiting WECHATY_PUPPET=wechaty-puppet-oicq npm start to run.

@huan
Copy link
Member Author

huan commented Sep 10, 2021

The latest wechaty needs at least Node.js v14, v16 are recommended.

I Will fix the GitPod later, before that, you can upgrade the Node.js by yourself.

The wechaty getting started GitPod has been upgraded with Wechaty version 0.69. Please try it and let me know if it works for you.

huan added a commit to wechaty/wechaty that referenced this issue Sep 10, 2021
huan added a commit to wechaty/getting-started that referenced this issue Sep 10, 2021
@anaivebird
Copy link

Even through wechaty-puppet-oicq already uploaded to npm

Start https://github.com/wechaty/wechaty-getting-started with "wechaty": "^0.69.37" still throw error:

image

CustomError: Cannot find package '/workspace/wechaty-getting-started/node_modules/wechaty-puppet-oicq/' imported from /workspace/wechaty-getting-started/node_modules/wechaty/dist/esm/src/puppet-manager.js
    at legacyMainResolve (/workspace/wechaty-getting-started/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:301:9)
    at packageResolve (/workspace/wechaty-getting-started/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:767:14)
    at moduleResolve (/workspace/wechaty-getting-started/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:815:18)
    at Object.defaultResolve (/workspace/wechaty-getting-started/node_modules/ts-node/dist-raw/node-esm-resolve-implementation.js:929:11)
    at /workspace/wechaty-getting-started/node_modules/ts-node/src/esm.ts:68:38
    at Generator.next (<anonymous>)
    at /workspace/wechaty-getting-started/node_modules/ts-node/dist/esm.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/workspace/wechaty-getting-started/node_modules/ts-node/dist/esm.js:4:12)
    at resolve (/workspace/wechaty-getting-started/node_modules/ts-node/dist/esm.js:32:16)
09:28:25 ERR Wechaty start() exception: Cannot find package '/workspace/wechaty-getting-started/node_modules/wechaty-puppet-oicq/' imported from /workspace/wechaty-getting-started/node_modules/wechaty/dist/esm/src/puppet-manager.js
09:28:25 ERR StarterBot Error: Cannot find package '/workspace/wechaty-getting-started/node_modules/wechaty-puppet-oicq/' imported from /workspace/wechaty-getting-started/node_modules/wechaty/dist/esm/src/puppet-manager.js

@huan
Copy link
Member Author

huan commented Sep 12, 2021

The Wechaty Getting Started repo is running with ES Modules mode by default, which requires the puppet need to support ESM too.

See:

Please try to understand the above issue first, then prepare to transfer the wechaty-puppet-oicq repo to Wechaty org. After that, I can take a look at it and try to fix it.

Thank you very much.

@huan
Copy link
Member Author

huan commented Sep 21, 2021

@anaivebird You have missed the weekly report again, may I ask you that when could we receive it?

It is very important for our project that you can follow your plan and report in the schedule so that we can know how your work is going on.

Please make sure you can submit the update in time in the following weeks, or we will think you have done nothing in that week.

Thank you very much.

@anaivebird
Copy link

[开发支持 QQ 聊天软件的 Wechaty Puppet Provider 模块] 进度报告

日期:2021-09-21

本周完成的成果

  1. 重新修改中期报告的pull request
  2. 在CentOS7机器上安装ruby和jekyll(用于预览中期报告)
  3. 调研图片接收

本周遇到的困难和需要配合的地方

  1. 中期报告修改在PR上讨论,和预览看到的实际效果有些差异,对话中导师想要的效果和我的理解可能不太一样,一次次来回比较费时间(已经来时上十次)

下周的开发计划和预计成果

  1. 把puppet仓库转移到官方
  2. 扫码并入OnScan事件

其他需要说明和同步的事项

@huan
Copy link
Member Author

huan commented Sep 22, 2021

Thanks for the update.

把puppet仓库转移到官方
扫码并入OnScan事件

It's great to see your plan and hope you can follow it this week.

中期报告修改在PR上讨论,和预览看到的实际效果有些差异,对话中导师想要的效果和我的理解可能不太一样,一次次来回比较费时间(已经来时上十次)

Please try to help yourself to figure out a better way to communicate based on GitHub because this is the way the open-source community works with.

提供一个 examples/ding-dong-bot.ts ,完成“接收到文字消息ding时,自动回复消息dong"的功能

And don't forget that the mid-term milestone is the ding/dong bot, which we have mentioned lots of times in our previous discussions (and your plan has been delayed serval weeks, which should be noticed by us for now):

The ding/dong bot should be finished before the mid-term report, which has already been delayed. I hope you can finish it soon.

Related steps:

  1. Publish wechaty-puppet-oicq to npm
  2. run WECHATY_PUPPET=wechaty-puppet-oicq npm start successfully with our ding/dong bot

@anaivebird
Copy link

image
A strange problem both occurred on lastest gitpod and my CentOS7 server.

@huan
Copy link
Member Author

huan commented Sep 23, 2021

This is a breaking change introduced by the wechaty-puppet@0.45.8 module.

We have deprecated them:

npm deprecate 'wechaty-puppet@0.45.8' "should not introduce breaking change"

I have fixed it and it should be ok if you can get the wechaty-puppet@0.45.9:

$ npm ls wechaty-puppet
└── wechaty-puppet@0.45.9 

@anaivebird
Copy link

image
Sorry, how to update wechaty-puppet to 0.45.9?

@huan
Copy link
Member Author

huan commented Sep 23, 2021

You do not need to update anything, a re-install should be enough.

Run the following command should get the right version for you:

rm -fr node_modules package-lock.json
npm install

Please let me know if it works.

@anaivebird
Copy link

image
Thanks a lot, it worked.

But working with WECHATY_PUPPET=wechaty-puppet-oicq still not works, any advice for further development? ESM branch code has been released to wechaty-puppet-oicq@0.1.5

image

@huan
Copy link
Member Author

huan commented Sep 23, 2021

Great to know that the wechaty-puppet issue has been fixed, and the ESM for puppet oicq has been merged and published!

For your new problem, could you please file another issue for it so that we can have a clear thread for each topic?

You can link all your work issues/prs to one issue so that you can get an index of all of them.

P.S. paste an Image is not good practice because it's very hard to read and search. Paste text is more preferred.

Thank you very much.

@anaivebird
Copy link

@anaivebird
Copy link

wechaty-getting-started worked with wechaty-puppet-oicq@0.1.6

image

Originally posted by @anaivebird in wechaty/puppet-oicq#5 (comment)

@anaivebird
Copy link

@anaivebird
Copy link

anaivebird commented Oct 4, 2021

unnecessary logging from oicq problem fixed

The log from oicq has been disabled. The screen looks like:


[anelderly@pubgyes wechaty-getting-started]$ npm start

> wechaty-getting-started@0.13.13 start /home/anelderly/wechaty-getting-started
> cross-env NODE_OPTIONS='--no-warnings --loader=ts-node/esm' node examples/ding-dong-bot.ts

14:58:26 INFO Config registering process.on("unhandledRejection") for development/debug
14:58:26 VERB Config constructor()
14:58:27 VERB wechaty-puppet-service monkeyPatchMetadataFromHttp2Headers()
14:58:27 VERB ResolverWechaty setup()
14:58:27 VERB Wechaty constructor()
14:58:27 VERB StateSwitch constructor(Wechaty, "{"log":{"enableTimestamp":true,"logLevel":4,"prefixFilter":{}}}")
14:58:27 VERB StateSwitch constructor(WechatyReady, "{"log":{"enableTimestamp":true,"logLevel":4,"prefixFilter":{}}}")
14:58:27 VERB Wechaty on(scan, listener) registering... listenerCount: 0
14:58:27 VERB Wechaty on(login, listener) registering... listenerCount: 0
14:58:27 VERB Wechaty on(logout, listener) registering... listenerCount: 0
14:58:27 VERB Wechaty on(message, listener) registering... listenerCount: 0
14:58:27 VERB Wechaty <wechaty-puppet-oicq>(ding-dong-bot) start() v0.69.58 is starting...
14:58:27 VERB Wechaty id: ckucaxjgf0000y2mi1jkhgpok
14:58:27 VERB StateSwitch <WechatyReady> off(true) <- (true)
14:58:27 VERB StateSwitch <Wechaty> on(pending) <- (false)
14:58:27 VERB MemoryCard constructor("ding-dong-bot")
14:58:27 VERB MemoryCard getStorage() for storage type: N/A
14:58:27 VERB getStorage name: ding-dong-bot, options: {"type":"file"}
14:58:27 VERB StorageFile constructor(ding-dong-bot, ...)
14:58:27 VERB StorageBackend constructor(ding-dong-bot, { type: file })
14:58:27 VERB MemoryCard load() from storage: StorageFile</home/anelderly/wechaty-getting-started/ding-dong-bot.memory-card.json>
14:58:27 VERB StorageFile load() from /home/anelderly/wechaty-getting-started/ding-dong-bot.memory-card.json
14:58:27 VERB Wechaty init() getRavenDsn() return undefined, skipped.
14:58:27 VERB Wechaty initPuppet() 
14:58:27 VERB MemoryCard multiplex(puppet)
14:58:27 VERB MemoryCard static multiplex(MemoryCard<ding-dong-bot>, puppet)
14:58:27 VERB MemoryCard constructor({"name":"ding-dong-bot","multiplex":{"name":"puppet","parent":{"options":{"name":"ding-dong-bot"},"name":"ding-dong-bot","payload":{"\rpuppet\nPUPPET_WECHAT":[{"name":"MM_WX_SOUND_STATE","value":"1","domain":"wx.qq.com","path":"/","expires":-1,"size":18,"httpOnly":false,"secure":false,"session":true,"sameParty":false,"sourceScheme":"Secure","sourcePort":443},{"name":"MM_WX_NOTIFY_STATE","value":"1","domain":"wx.qq.com","path":"/","expires":-1,"size":19,"httpOnly":false,"secure":false,"session":true,"sameParty":false,"sourceScheme":"Secure","sourcePort":443},{"name":"mm_lang","value":"en","domain":".wx.qq.com","path":"/","expires":1632424665,"size":9,"httpOnly":false,"secure":true,"session":false,"sameParty":false,"sourceScheme":"Secure","sourcePort":443}]},"multiplexNameList":[],"storage":{"name":"ding-dong-bot","options":{"type":"file"},"absFileName":"/home/anelderly/wechaty-getting-started/ding-dong-bot.memory-card.json"}}}})
14:58:27 VERB PuppetManager resolve({puppet: wechaty-puppet-oicq, puppetOptions: undefined})
14:58:27 VERB PuppetManager resolveName(wechaty-puppet-oicq)
14:58:27 VERB Puppet constructor({}) #0
14:58:27 VERB StateSwitch constructor(PuppetOICQ, "{"log":{"enableTimestamp":true,"logLevel":4,"prefixFilter":{}}}")
14:58:27 VERB MemoryCard constructor(undefined)
14:58:27 VERB MemoryCard getStorage() for storage type: N/A
14:58:27 VERB MemoryCard load() from storage: N/A
14:58:27 VERB MemoryCard load() no storage
14:58:27 VERB Puppet constructor() watchdog timeout set to 60 seconds
14:58:27 VERB HotImport callerResolve(., /home/anelderly/wechaty-puppet-oicq/node_modules/wechaty-puppet/dist/src/puppet.js)
14:58:27 VERB Puppet constructor() childClassPath=/home/anelderly/wechaty-getting-started/file:/home/anelderly/wechaty-puppet-oicq/dist/esm/src
14:58:27 VERB PuppetOICQ constructor("{}")
14:58:27 VERB Puppet setMemory()
14:58:27 VERB Wechaty initPuppetEventBridge(Puppet#0<PuppetOICQ>(ding-dong-bot))
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(friendship) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(login) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(logout) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(message) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(room-invite) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(room-join) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(room-leave) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(room-topic) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(scan) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(dirty) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(dong) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(error) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(heartbeat) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(ready) (listenerCount:0) registering...
14:58:27 VERB Wechaty initPuppetEventBridge() puppet.on(reset) (listenerCount:0) registering...
14:58:27 VERB Wechaty wechatifyUserModules(Puppet#0<PuppetOICQ>(ding-dong-bot))
14:58:27 VERB PuppetOICQ start()
14:58:27 VERB StateSwitch <PuppetOICQ> on(pending) <- (false)
14:58:27 VERB Wechaty on(heartbeat, listener) registering... listenerCount: 0
14:58:27 VERB StateSwitch <Wechaty> on(true) <- (pending)
14:58:27 INFO StarterBot Starter Bot Started.

QR code here, then

enter pressed, try to login
14:58:39 VERB StateSwitch <PuppetOICQ> on(true) <- (pending)
14:58:39 VERB PuppetOICQ login()
14:58:39 VERB Puppet login(1962099319)
14:58:39 VERB Contact load(1962099319) init pool
14:58:39 VERB PuppetOICQ contactRawPayload(1962099319)
14:58:39 INFO StarterBot Contact<划水狗> login
15:01:20 VERB Message static load(MoiqpQAAcvxeiMgTYVqmwAA=)
15:01:20 VERB Message constructor(MoiqpQAAcvxeiMgTYVqmwAA=) for class WechatifiedMessage
15:01:20 VERB Message ready()
15:01:20 VERB Puppet messagePayload(MoiqpQAAcvxeiMgTYVqmwAA=)
15:01:20 VERB Contact load(847817381) init pool
15:01:20 VERB PuppetOICQ contactRawPayload(847817381)
15:01:20 VERB Puppet selfId()
15:01:20 INFO StarterBot Message#Text[🗣Contact<Li Dao>] ding
15:01:20 VERB Message say(dong)
15:01:20 VERB Puppet selfId()
15:01:20 VERB Puppet selfId()
15:01:20 VERB Message mentionList()
15:01:20 VERB Puppet selfId()

Originally posted by @anaivebird in wechaty/puppet-oicq#9 (comment)

@anaivebird
Copy link

anaivebird commented Oct 4, 2021

Contact list from oicq has be adapted to contactPayload and contactRawPayloadParser

Contact list could be successfully loaded from oicq and be compatible with wechaty puppet contactPayload:

for (const [id, friend] of this.fl.entries()) {
  puppetThis.contactStore[id.toString()] = friend
}
  async contactRawPayload (_contactId: string): Promise<any> {
    log.verbose('PuppetOICQ', 'contactRawPayload(%s)', _contactId)
    return this.contactStore[_contactId]!
  }

  async contactRawPayloadParser (_rawPayload: any): Promise<ContactPayload> {
    const genderStringToType: { [key: string]: ContactGender } = {
      female: ContactGender.Female,
      male: ContactGender.Male,
      unknown: ContactGender.Unknown,
    }

    return {
      avatar : 'unknown',
      gender : genderStringToType[_rawPayload.sex]!,
      id     : _rawPayload.user_id,
      name   : _rawPayload.nickname,
      phone : ['unkown'],
      type   : ContactType.Individual,
    }
  }

@anaivebird
Copy link

anaivebird commented Oct 4, 2021

wechaty-puppet-oicq is now perfectly compatible with ding-dong bot in wechaty-getting-started

Totally fixed wechaty-getting-started compatibility with this puppet after calling this.login() correctly with this.login(this.qq.toString())

image

Originally posted by @anaivebird in wechaty/puppet-oicq#11 (comment)

@anaivebird
Copy link

结项 Demo Day 视频

结项汇报:https://youtu.be/Z2IIPe0FLA4
Live Code:https://youtu.be/TbIgFhSWVxI

国内版 Demo Day 视频

结项汇报:https://www.iqiyi.com/v_1f3m7rhczog.html
Live Code:http://www.iqiyi.com/v_1uv2wbi4p44.html

@huan
Copy link
Member Author

huan commented Oct 6, 2021

Your video presentation is great, thank you very much for your efforts in implementing the wechaty puppet oicq!

I believe this puppet will be able to help lots of developers who want to automate their works on QQ by building an easy to use Wechaty QQ bot!

@lijiarui
Copy link
Member

期末评审

  • 项目完成度:按照原定方案实施项目,情况完成优秀
  • 学生参与度:评价学生在项目实施过程中积极参与,并按照社区规范提交完整报告和视频
  • 代码贡献量:评价学生在该项目中,完成 wechatu-puppet-oicq repo 的ding-dong 工鞥呢,并成功发布 npm 包,同时配置完成自动化测试,贡献量符合社区要求
  • 综合评价及建议:整体如期完成,期待未来:
    • 可以支持其他格式的消息收发
    • Puppet 读取 stdin 的问题需要解决
    • Puppet 希望可以通过 MemoryCard 存取重启之间的 session 数据

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants