Fixed chat-replies doesn't work. Fixes #71.
This commit is contained in:
parent
c78fc5a60d
commit
5d32a4577c
1 changed files with 8 additions and 7 deletions
|
|
@ -336,17 +336,18 @@ bool checkForKeywords (char *message, char *reply) {
|
||||||
|
|
||||||
// check is keyword has occurred in message
|
// check is keyword has occurred in message
|
||||||
if (strstr (message, keyword.chars ()) != nullptr) {
|
if (strstr (message, keyword.chars ()) != nullptr) {
|
||||||
StringArray &replies = factory.usedReplies;
|
StringArray &usedReplies = factory.usedReplies;
|
||||||
|
|
||||||
if (replies.length () >= factory.replies.length () / 2) {
|
if (usedReplies.length () >= factory.replies.length () / 2) {
|
||||||
replies.clear ();
|
usedReplies.clear ();
|
||||||
}
|
}
|
||||||
else if (!replies.empty ()) {
|
|
||||||
|
if (!factory.replies.empty ()) {
|
||||||
bool replyUsed = false;
|
bool replyUsed = false;
|
||||||
const String &choosenReply = factory.replies.random ();
|
const String &choosenReply = factory.replies.random ();
|
||||||
|
|
||||||
// don't say this twice
|
// don't say this twice
|
||||||
for (auto &used : replies) {
|
for (auto &used : usedReplies) {
|
||||||
if (used.contains (choosenReply)) {
|
if (used.contains (choosenReply)) {
|
||||||
replyUsed = true;
|
replyUsed = true;
|
||||||
break;
|
break;
|
||||||
|
|
@ -356,7 +357,7 @@ bool checkForKeywords (char *message, char *reply) {
|
||||||
// reply not used, so use it
|
// reply not used, so use it
|
||||||
if (!replyUsed) {
|
if (!replyUsed) {
|
||||||
strcpy (reply, choosenReply.chars ()); // update final buffer
|
strcpy (reply, choosenReply.chars ()); // update final buffer
|
||||||
replies.push (choosenReply); // add to ignore list
|
usedReplies.push (choosenReply); // add to ignore list
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue