Magren

Magren

Idealist & Garbage maker 🛸
twitter
jike

About Yuan-bot🤖

oicq is an implementation of the QQ (Android) protocol based on Node.js, providing common QQ functions.
yuan-bot is a QQ bot based on oicq, written in TypeScript and using MongoDB as the database. The project has just been created and only focuses on the essence messages of the Q group. The content will be gradually enriched in the future.

Github link: yuan-bot

This article is a record of the development log of this project.

Background#

I have a group in my QQ, which is a game group I played during high school and college.
Everyone in the group is good at playing and has a pleasant way of speaking. In order to remember every word spoken by each buddy, we made use of the essence message feature of QQ and framed every silly classic quote on this essence message list.
At this point, the content of the essence message is no longer essence, and we secretly call it dregs
message.png

Because of my youthful arrogance, the buddies framed on the list were all in agony (of course, some people enjoyed it, I won't say who, but everyone who knows knows), and they all accused the administrators of having a hidden agenda! The administrator should be punished according to the demands of the group members!

But as the saying goes, the higher the climb, the harder the fall. The despicable group management not only ignored the accusations of the group members, but also launched dregs merchandise on the 8th anniversary of the group's establishment (fortunately, I also got one), and awarded trophies to the group members with the most dregs, vigorously promoting the dregs culture. Coupled with the disintegration of the group members' opinions, the voices of opposition in the group gradually disappeared, and everyone became a jokester.

At this point, the dregs culture reached a climax since the establishment of the group.
bag.jpg
medal.jpg

As the dregs culture gradually became popular, the number of dregs also continued to rise, and the group management discovered some problems

  • The number of dregs reached a maximum of 1000, and some dregs messages must be deleted in order to continue adding new ones, resulting in the loss of some historical dregs of the group
  • Under such a large number, the essence messages of the QQ group do not have functions such as statistics or viewing by time. Each time the statistics are done manually, it consumes manpower
  • ...

Yuan-Bot was created to solve the above problems, for the sake of dregs and fun.

Launch#

git clone https://github.com/Magren0321/yuan-bot.git

pnpm install

pnpm run serve

Process#

As a front-end developer, I instinctively chose Node.js for the technology, and found this library called oicq, which is an Android QQ implementation based on Node.js. It is also the most comprehensive library I have found in terms of functionality. For specific usage, it is better to refer to its Api reference than to listen to me.

Essence Data#

The group object encapsulated by oicq itself does not encapsulate the group essence data (or it seems that no open source library has achieved this, perhaps because the audience is too small and the usage frequency is not high, so it has not been considered). So I had to do it myself.
I used Fiddler to capture the essence data interface of the PC version of QQ, and then used the login interface provided by oicq to obtain the Cookie, and put it into the request header to obtain the essence message data.
By the way, I also made a PR to oicq (another PR to water)

Then I encountered another problem. When there is a new essence message in the group, I cannot listen to the tips in the group through oicq. I found that someone had raised an issue about this in August last year, but it seems that it has not been resolved yet.
The original plan was to store the new essence message in the server's database in real time after listening to the addition of the essence message. But now I can only switch to another solution, using an interval timer to request the data at regular intervals, record the timestamp of the latest message, and filter out the old content.
Although I think this method is a bit stupid, but for now I haven't thought of any other way to implement this feature.

Commands#

This is relatively easy to solve. Just listen to the messages of the specified group, encapsulate a class, use a string as the key in the class, and use the corresponding method as the value. After receiving a message, pass the message as the key. If it exists in the class, execute the corresponding method.
image.jpg

That's about it for the implementation, it can be said to be ordinary, without any highlights 🤡

Finally (maybe not the end yet?#

The functionality of yuan-bot will continue to be enriched and iterated in the future (but now I have started working, so the progress may be relatively slow)
🙏 Thanks to oicq for providing the interface and documentation
🛸 Power by Magren and made with love

To Be Continued.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.