コード例 #1
0
ファイル: InfoOperation.java プロジェクト: topriddy/javabot
 @Override
 public boolean handleMessage(final Message event) {
   final String message = event.getValue().toLowerCase();
   final Channel channel = event.getChannel();
   if (message.startsWith("info ")) {
     final String key = message.substring("info ".length());
     final Factoid factoid = dao.getFactoid(key);
     if (factoid != null) {
       DateTimeFormatter formatter = DateTimeFormatter.ofPattern(INFO_DATE_FORMAT);
       LocalDateTime updated = factoid.getUpdated();
       String formatted = formatter.format(updated);
       getBot()
           .postMessageToChannel(
               event,
               Sofia.factoidInfo(
                   key,
                   factoid.getLocked() ? "*" : "",
                   factoid.getUserName(),
                   formatted,
                   factoid.getValue()));
     } else {
       getBot().postMessageToChannel(event, Sofia.factoidUnknown(key));
     }
     return true;
   }
   return false;
 }
コード例 #2
0
ファイル: SeeLoopTest.java プロジェクト: topriddy/javabot
 public void createCircularSee2() {
   deleteSees();
   testMessage("~see1 is <see>see2", ok);
   testMessage("~see2 is <see>see3", ok);
   testMessage("~see3 is <see>see1", ok);
   testMessage("~see1", Sofia.factoidLoop("<see>see2"));
   deleteSees();
 }