Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Add mobile off pattern to PatternHandler and add info message to mobi…
Browse files Browse the repository at this point in the history
…le off message in MobileListener
  • Loading branch information
rettichlp committed Sep 13, 2023
1 parent 8d9ed9c commit f4f5ae4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public class PatternHandler {
public static final Pattern MOBILE_REMOVE_PATTERN = Pattern.compile("^((?:\\[UC])*\\w+) hat dir deine Kommunikationsgeräte abgenommen\\.$");
public static final Pattern MOBILE_GET_PATTERN = Pattern.compile("^Du hast dein Handy genommen\\.$" +
"|^((?:\\[UC])*\\w+) hat dir deine Kommunikationsgeräte wiedergegeben\\.$");
public static final Pattern MOBILE_OFF_PATTERN = Pattern.compile("^Dein Handy ist ausgeschaltet\\.$");
public static final Pattern MOBILE_TOGGLE_PATTERN = Pattern.compile("^Du hast dein Telefon (ein|aus)geschaltet\\.$" +
"|^Der Akku von deinem Handy ist leer\\.$");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,26 @@ public void onChatReceive(ChatReceiveEvent e) {
return;
}

Matcher communicationsRemoveMatcher = PatternHandler.MOBILE_REMOVE_PATTERN.matcher(msg);
if (communicationsRemoveMatcher.find()) {
Matcher mobileRemoveMatcher = PatternHandler.MOBILE_REMOVE_PATTERN.matcher(msg);
if (mobileRemoveMatcher.find()) {
hasCommunications = false;
return;
}

Matcher communicationsGetMatcher = PatternHandler.MOBILE_GET_PATTERN.matcher(msg);
if (communicationsGetMatcher.find()) {
Matcher mobileGetMatcher = PatternHandler.MOBILE_GET_PATTERN.matcher(msg);
if (mobileGetMatcher.find()) {
hasCommunications = true;
return;
}

Matcher mobileOffMatcher = PatternHandler.MOBILE_OFF_PATTERN.matcher(msg);
if (mobileOffMatcher.find()) {
if (!hasCommunications) {
p.sendInfoMessage("Dein Handy liegt bei dir zu Hause.");
}
return;
}

Matcher mobileTogglePattern = PatternHandler.MOBILE_TOGGLE_PATTERN.matcher(msg);
if (mobileTogglePattern.find()) {
hasCommunications = true;
Expand Down

0 comments on commit f4f5ae4

Please sign in to comment.