MCPcopy Create free account
hub / github.com/annmuor/jnode / AreaFix

Class AreaFix

jnode-core/src/jnode/robot/AreaFix.java:41–405  ·  view source on GitHub ↗

@author kreon

Source from the content-addressed store, hash-verified

39 *
40 */
41public class AreaFix extends AbstractRobot {
42 private static final Pattern LIST = Pattern.compile("^%LIST$",
43 Pattern.CASE_INSENSITIVE);
44 private static final Pattern QUERY = Pattern.compile("^%QUERY$",
45 Pattern.CASE_INSENSITIVE);
46 private static final Pattern ADD = Pattern.compile("^%?\\+?(\\S+)$",
47 Pattern.CASE_INSENSITIVE);
48 private static final Pattern REM = Pattern.compile("^%?\\-(\\S+)$",
49 Pattern.CASE_INSENSITIVE);
50 private static final Pattern RESCAN = Pattern.compile(
51 "^%RESCAN (\\S+) (\\d+)$", Pattern.CASE_INSENSITIVE);
52 private static final Pattern ADD_RESCAN = Pattern.compile(
53 "^%?\\+?(\\S+) /r=(\\d+)$", Pattern.CASE_INSENSITIVE);
54
55 private static final Pattern AFXPASS = Pattern.compile("^%AFXPASS (\\S+)$",
56 Pattern.CASE_INSENSITIVE);
57 private static final Pattern PKTPASS = Pattern.compile("^%PKTPASS (\\S+)$",
58 Pattern.CASE_INSENSITIVE);
59 private static final Pattern IGNOREPKTPWD = Pattern.compile(
60 "^%IGNOREPKTPWD (on|off)$", Pattern.CASE_INSENSITIVE);
61
62 @Override
63 public void execute(FtnMessage fmsg) throws Exception {
64 Link link = getAndCheckLink(fmsg);
65 if (link == null) {
66 return;
67 }
68
69 StringBuilder reply = new StringBuilder();
70 for (String line : fmsg.getText().split("\n")) {
71 line = line.toLowerCase();
72 if (HELP.matcher(line).matches()) {
73 FtnTools.writeReply(fmsg,
74 MessageFormat.format("{0} help", getRobotName()),
75 help());
76 } else if (LIST.matcher(line).matches()) {
77 FtnTools.writeReply(fmsg,
78 MessageFormat.format("{0} list", getRobotName()),
79 list(link));
80 } else if (QUERY.matcher(line).matches()) {
81 FtnTools.writeReply(fmsg,
82 MessageFormat.format("{0} query", getRobotName()),
83 query(link));
84 } else {
85 Matcher m = REM.matcher(line);
86 if (m.matches()) {
87 String area = m.group(1);
88 reply.append(rem(link, area));
89 continue;
90 }
91 m = ADD.matcher(line);
92 if (m.matches()) {
93 String area = m.group(1);
94 reply.append(add(link, area));
95 continue;
96 }
97 m = RESCAN.matcher(line);
98 if (m.matches()) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected