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

45
LINES

< > BotCompany Repo | #1017623 // Follow-up/No follow-up [Tag Telegram Messages, OK]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (15588L/113K).

!7

sclass FollowUp > DynModule {
  start {
    dm_useLocalMechListCopies();
  }
  
  visualize {
    final Set<S> followUps = asHashSet(map dropLeadingHash(extractSingleStarMatches("* is a follow-up message",
      concatLists(mL("Facts about Telegram messages"), lines((S) call(dm_get_newFacts(), 'text))))));
      
    new L<L> data;
    for (TelegramMsg msg : serverTelegramLog())
      if (nempty(msg.globalID))
        data.add(ll(msg.globalID, escapeNewLines(msg.text), followUps.contains(msg.globalID)));
        
    final L<S> cols = ll("Global ID", "Text", "Is Follow-Up");
    
    final JTable table = sexyTable();
    Pair<Object[][], O[]> p = fillTableWithData_makeData(data, cols);
    setTableModel(table, new DefaultTableModel(p.a, p.b) {
      public Class getColumnClass(int column) {
        return or(_getClass(getValueAt(0, column)), S.class);
      }
      
      public bool isCellEditable(int rowIndex, int columnIndex) {
        ret columnIndex == l(cols)-1;
      }
    });
    onTableChanged(table, voidfunc(final TableModelEvent e) {
      thread {
        O facts = dm_require_newFacts();
        int i = e.getFirstRow(), j = e.getLastRow();
        print(i + "/" + j);
        for (; i <= j; i++) {
          bool b = isTrue(print(rawCellData(table, i, l(cols)-1)));
          S id = (S) rawCellData(table, i, 0);
          call(facts, 'add, "#" + id + " is " + (b ? "a" : "not a") + " follow-up message");
          call(facts, 'remove, "#" + id + " is " + (!b ? "a" : "not a") + " follow-up message");
        }
      }
    });
    ret table;
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1017623
Snippet name: Follow-up/No follow-up [Tag Telegram Messages, OK]
Eternal ID of this version: #1017623/19
Text MD5: 8fd9e582544353751f682cb819264e44
Transpilation MD5: e8f1b87ed44cfc82d8b5689a65f0519d
Author: stefan
Category: javax / networking
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-08-02 17:15:45
Source code size: 1627 bytes / 45 lines
Pitched / IR pitched: No / No
Views / Downloads: 283 / 1289
Version history: 18 change(s)
Referenced in: [show references]