Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

38
LINES

< > BotCompany Repo | #1022857 // AI_ClocktimeBot

JavaX fragment (include)

sclass AI_ClocktimeBot > AttractorBot {
  Long now;
  
  public void run {
    say("I can resolve clock times for you");
  }
  
  // CONFIG
  
  class Attractor1 > Attractor {
    int hour, minute;
    
    public bool matches(S s) {
      new Matches m;
      if (find3("* am", s, m) && isInteger($1)) {
        minute = 0;
        hour = parseInt($1);
        ret hour > 0;
      }
      
      if (find3("* pm", s, m) && isInteger($1)) {
        minute = 0;
        hour = parseInt($1)+12;
        ret hour > 0;
      }

      false;
    }
    
    public void run {
      say(formatInt(hour, 2) + ":" + formatInt(minute, 2));
    }
  }
  
  *() {
    standardAttractors(new Attractor1);
  }
}

Author comment

Began life as a copy of #1022834

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1022857
Snippet name: AI_ClocktimeBot
Eternal ID of this version: #1022857/1
Text MD5: 761b47237cb2e918488f54605df754ec
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-04-11 17:23:24
Source code size: 733 bytes / 38 lines
Pitched / IR pitched: No / No
Views / Downloads: 372 / 778
Referenced in: [show references]