Magren

Magren

Idealist & Garbage maker 🛸
twitter
jike

About Yuan-bot🤖

oicq is a QQ (Android) protocol implemented based on Node.js, providing common functions and operations within QQ.
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 currently only focuses on the essence messages of Q groups. More content will be added in the future.

GitHub link: yuan-bot

This article is a record of the development process of this project's unofficial development log.

Background#

I have a QQ group in my QQ, which is a gaming group I joined during high school and college when I played a game called "Jian San".
Everyone in the group is good at playing the game and has a way with words. In order to remember every word spoken by each member, we made use of the essence message feature in QQ and displayed every flirtatious classic quote on this essence message list.
At this point, the content of the essence messages is no longer essence, and we secretly call it "dregs"
message.png

Because of my youthful recklessness, the members whose quotes were displayed on the list were all in agony (of course, some people enjoyed it, I won't say who, but those who understand, understand), and they all accused the administrators of having a hidden agenda! The administrators 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 administrators 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). At the same time, they awarded trophies to the member with the most dregs, vigorously promoting the dregs culture. Combined with the fact that the group members' opinions were divided, the voices of opposition in the group gradually disappeared, and everyone became a jokester.

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

As the dregs culture gradually became popular, the number of dregs continued to increase, and the group administrators discovered some problems:

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

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

Startup#

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

pnpm install

pnpm run serve

Process#

As a frontend developer, I instinctively chose Node.js for the technology. I found the library oicq, which is an Android QQ implementation based on Node.js. It is the most comprehensive library I found in terms of functionality. For specific usage, it's better to refer to its API reference.

Essence Data#

The group object encapsulated by oicq itself does not include the encapsulation of group essence data (or it seems that no open source library has achieved this yet, perhaps because the target audience is too small and the usage frequency is not high, so it has not been considered). Therefore, I had to do it myself.
I used Fiddler to capture the QQ PC client, captured the interface for essence data, 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.
I also submitted a PR to oicq (another PR submitted)

Then I encountered another problem. When there are new essence messages 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 listen for the addition of essence messages and store the new essence messages in the server's database in real-time. But now I can only use a different approach, using an interval timer to request the data at regular intervals, recording the timestamp of the latest message, and filtering out the old content.
Although I think this method is quite clumsy, I currently can't think of any other way to implement this functionality.

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 the corresponding method as the value. When a message is received, pass the message as the key. If the class exists, execute the corresponding method.

That's basically how it's implemented, it can be said to be ordinary and unremarkable 🤡

Finally (or 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.
🛸 Powered 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.