Let Bot learn the speeches and emoticons of group friends!
A learning plug-in that allows Bot to automatically select historical quotes or emoticons to reply based on the regularity of group members' comments.
After installing this plug-in, it will not be effective immediately. You need to give the Bot some time to accumulate group chat records.
After learning to a certain extent, the plug-in will become a chatty king. Grab all the weird comments and emoticons from group friends .
This plug-in is also equipped with a Web UI
background management for the Bot owner to modify the configuration, and supports group configuration.
This plug-in only works with OneBot V11
adapter and group chat .
Open the command line in the root directory of the nonebot2 project and enter the following commands to install
nb plugin install nonebot-plugin-learning-chat
Unlike other imperative plug-ins, this plug-in only has 2 commands for managing Bots in group chats.
instruction | Example | effect |
---|---|---|
Turn on/off learning | @bot Turn on learningLearn to speakLearn quicklyTurn off learningDon’t learnShut up | Turn on or off the learning ability of this group (requires Aite Robot) |
Disable replies | @bot can'tdamecan't say this | To disable a learned reply, you will not say this sentence again in the future. You need to have administrator rights on Aite Robot and reply to the robot's speech. |
This plug-in will record the speeches of group members in the database and respond according to the regular speeches of group members.
Whenever a group member makes a new comment, the plug-in will record this comment as one of the optional replies to the previous comment, then search the database for historical replies to this comment that meet the conditions, and select one of them to reply to.
The following is a simple example:
群友1:诶嘿
群友2:诶嘿是什么意思啊
群友1:诶嘿
群友2:诶嘿是什么意思啊
群友1:诶嘿
群友2:诶嘿是什么意思啊
群友1:诶嘿
群友2:诶嘿是什么意思啊
Every time someone says诶嘿
, someone says诶嘿是什么意思啊
This set of conversations can be regarded as regular speech (the same is true for emoticons) .
诶嘿是什么意思啊
will be learned as a reply of诶嘿
4 times, and诶嘿
will be learned as a reply of诶嘿是什么意思啊
3 times.
In the default configuration, a reply needs to be learned 4 times before it is listed as one of the optional answers.
Therefore, in the future, when a group friend says诶嘿
the plug-in will search the data for replies with learning times greater than 4. If there is one type of诶嘿是什么意思啊
", there will be a probability of replying诶嘿是什么意思啊
"
In short, this plug-in is a more advanced repeater and QA Q&A person. If your group friends do not speak with obvious regularity, the effect of this plug-in may be poor.
The plug-in also has the functions of repeating and speaking actively.
As the name suggests, it is repetition. When group members reread a certain number of times (default is 3), the plug-in will reread accordingly.
In the following cases, even if the number of times is reached, the replay will not follow:
Every minute, the plug-in will rank the popularity of group chats, select a group, and randomly send one or more historical statements of the group.
The more active the group is during the day, the easier it is to trigger active comments after the group becomes quiet . epilepsy Warm up.
Conditions for taking the initiative to speak:
After the active speech is judged to be successful, the message will be randomly selected from the historical chat records of the group and sent.
This plug-in uses yml
files as configuration files. Because it requires dynamic modification and group configuration, Nonebot's .env
form of configuration is not used.
The yml
configuration file is located in Bot目录/data/learing_chat/learning_chat.yml
, but I personally recommend that you use Web UI
background management to modify the configuration.
The function of each configuration item is introduced in detail in the background management page . Here are just a few:
Configuration items | default value | illustrate |
---|---|---|
Group chat learning switch | true | As the name suggests |
Block words | [ ] | Chat history containing these words will not be learned |
Block user | [ ] | Chat history associated with these users will not be learned |
Cross-group reply threshold | 3 | When N groups all have the same reply, it will be used as a global reply. |
Maximum number of learning times | 6 | The maximum number of times that learning replies can be accumulated |
Custom dictionary | [ ] | Add custom words so that word segmentation can identify uncollected words |
reply threshold | 4 | How many times do you need to learn it before it becomes one of the optional responses? |
Repeat threshold | 3 | How many times did the group members repeat the reading before they continued to repeat it? |
Active speaking threshold | 5 | Probability of taking the initiative to speak |
Some configurations are global configurations, and some can be configured in groups . Please check the background management for details.
This plug-in provides a simple Web UI
background management. You can perform the following in the background management:
Web UI
is enabled by default. Visit http://127.0.0.1:nb端口/learning_chat/login
to log in.
chat
admin
After successful login, you will be redirected to the background management page http://127.0.0.1:nb端口/learning_chat/admin
.
After logging in, please modify the default username, password, and token key used for encryption.
pip install ujson
pip install jieba_fast
DEBUG
level log to view the plug-in's learning and recovery process.