MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / checkNeedReply

Method checkNeedReply

keyword/keyword.ts:96–130  ·  view source on GitHub ↗
(message: Api.Message)

Source from the content-addressed store, hash-verified

94 text += `${htmlEscape(this.msg)}`;
95 return text;
96 }
97
98 checkNeedReply(message: Api.Message): boolean {
99 const text =
100 message.message ||
101 (message.media && "caption" in message.media
102 ? String(message.media.caption || "")
103 : "");
104 if (!text) return false;
105
106 if (this.ignore_forward && message.fwdFrom) {
107 return false;
108 }
109
110 let messageText = text;
111 let key = this.key;
112
113 if (this.regexp) {
114 try {
115 const regex = new RegExp(key, this.case ? "g" : "gi");
116 return regex.test(messageText);
117 } catch {
118 return false;
119 }
120 }
121
122 if (!this.case) {
123 messageText = messageText.toLowerCase();
124 key = key.toLowerCase();
125 }
126
127 if (this.include && messageText.includes(key)) {
128 return true;
129 }
130
131 return this.exact && messageText === key;
132 }
133

Callers 1

checkAndReplyMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected