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

Class FileFix

jnode-core/src/jnode/robot/FileFix.java:45–286  ·  view source on GitHub ↗

Простой filefix @author kreon

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected