I pocketed the input method users add automatic reply robot

If that FIG.,I pocketed the input method of the user group broke a Robot,As the user off the grid input method more and more,Some admiring novice more。Many common problems repeated questions,Made people battered,If you can have a robot,Like Siri as,It automatically captures those keywords and then respond to these users,Not Miya? So that users can get answers carefully edited,And I can free up more time for you to write code on behalf wan xi。

of course,Such a robot I've ever seen,So I think there must be something ready-made,Obviously,Under the first search I found this:https://github.com/zeruniverse/QQRobot author experiment to learn to do a QQ small yellow chicken,Based on Python,easy and convenient,What I like is that it can run on linux,That is, you can run on my vps。

But this is not convenient to use them,It is through the two-dimensional code scanning to login,And my vps graphics and no end ...... so I had to carry the two-dimensional code download,Too bother。Later, I passed its description link,I found this https://github.com/zeruniverse/QBotWebWrap

He integrated the above mentioned QQRobot,You can control it in the end of the page! But unfortunately,Configuration is complex,php plugin required also more,Focus is not stable,Almost out an on-line。


After pondering such a pass,I also understand how these tools hook,In fact, it cracked web QQ protocol (that is smart qq),Although advanced features can not,But the chat function properly or a duly,Such as the ability to monitor messages,AI is then sent to a third party interface to give each other feedback sent back so。This is the principle of intelligent chat robot friends!

later,I found a more active project:https://github.com/Yinzo/SmartQQBot

This principle and the same as above QQRobot,But someone has to maintain,It is also very active,Project stability。Nothing to say,According to the needs of the installation package will be able to start after,Remember to open the firewall 8888 port,Then you can use python run.py --no-gui --http start up,So it,Then open the corresponding page vps,The same scan code Login。

custom made

SmartQQBot comes with several plug-ins such as weather and within a group can be molested autoresponders plugin,You can use it to teach a fixed syntax,Then it will get back to you so,Although this can be a little my purpose,But not enough。As a special Q & A Robot,How allows users to easily add or delete it, right? Another advantage is the plug-SmartQQBot to increase functionality,It comes with several plug-ins,For example, Satoru ,We do not have this,Turn it off。Project Description There is no description,In fact, also comes with a plug-in, called tucao,This plug-in is different with Satoru,It supports user matched in the statement instead of the full text of the statement to match! Which is good,if you are willing to,Can be done naturally reply is not it?

So,We have to change this,SmartQQBot supports three message tag:

Given different labels through your function,It allows you to plug in response to the different message。

The first is to change to change messaging,I reduce the rights group messages,Control syntax is no longer detected,Only reply,At the same time to also accept whisper,There I can do this test yourself。So the code something like this:

Since tucao This plugin is for different groups of population numbers do processing,Here I have written directly to a fixed pocketed input user base group number,Not hide the,We casually look :)

Here we must note,While the program itself passed in group number is int ,But tucao are handled in accordance with str,So here to write a string。

Then whisper control functions,Here I In addition to modifying the tucao own display list function (big list simply could not send,Too,I read a number of displayed),Also added a reload function,This facilitates I change the background data of the unified add content:

In fact, the keyword is detected from the regular expression,Along expression format can guess,Add a reply is so: !learn {test}{test reply!}

Then delete it? The same format,Because it can be carried out in accordance with a plurality of random keywords Reply,So if you delete,Must correspond,Can not be left blank: !delete {test}{test reply!}

However, due to the fixed format,So see how many are needed and reload this format,Only the contents of brackets is invalid,Casually write: !reload {test}{test reply!}

At last,Since tucao itself using Python serialization,Save the file against editing,We put it into JSON format,This requires an additional package json。

Since I usually use is Python 3,So here I pulled the other items in the code used to take over,Then add:

So that you can save and change the code to load the:

At last,To configure, select load this plugin:

Then plug into the edited smart_qq_plugins In it。


if you need,All codes of this file you can copy directly here,Create a loginput.py And write to:



Original article written by Gerber drop-off:R0uter's Blog » I pocketed the input method users add automatic reply robot

Reproduced Please keep the source and description link:https://www.logcg.com/archives/2507.html

About the Author


The non-declaration,I have written articles are original,Reproduced, please indicate the link on this page and my name。


Leave a Reply

Your email address will not be published. Required fields are marked *