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

46
LINES

< > BotCompany Repo | #1023428 // Ongoing Twitter Search [Poll Version, Module]

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

Uses 911K of libraries. Click here for Pure Java version (4052L/21K).

!7

cmodule PollTwitterSearch > DynPrintLogAndEnabled {
  S query = "#javascript";
  transient new Set<Long> seen;
  
  transient AsyncTwitter asyncTwitter;
  
  start-thread {
    if (!enabled) ret;
    vm_cleanPrints();
    
    Twitter twitter = twitter4j_init();
    
    asyncTwitter = new AsyncTwitterFactory().getInstance(twitter);
    asyncTwitter.addListener(new TwitterAdapter {
      public void searched(QueryResult qr) enter {
        pcall {
          L<Status> tweets = qr.getTweets();
          //print("Have Tweets: " + l(tweets));
  
          new Set<Long> seen2;
          bool first = true;
          for (Status t : tweets) {
            long id = t.getId();
            seen2.add(id);
            continue if seen.contains(id);
            if (first) { first = false; printWithMS("NEW TWEETS"); }
            
            User usr = t.getUser();
            print("  " + localDateWithMilliseconds(t.getCreatedAt()) + " " + id + " " + (usr == null ? "none" : "@" + usr.getScreenName() + " // " + usr.getName()) + ": " + escapeNewLines(t.getText()));
          }
          setField(seen := seen2);
        }
      }
    });
    
    print("Looping");
    repeat with sleep 5 {
      if (enabled) {
        //print("Searching");
        asyncTwitter.search(new Query(query));
      }
    }
  }
}

Author comment

Began life as a copy of #1023426

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: #1023428
Snippet name: Ongoing Twitter Search [Poll Version, Module]
Eternal ID of this version: #1023428/15
Text MD5: 0891e5d2658194770033d44326fd56b7
Transpilation MD5: b585e215088cf6d027786335e95a2a08
Author: stefan
Category: javax / networking
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-06-20 05:21:43
Source code size: 1360 bytes / 46 lines
Pitched / IR pitched: No / No
Views / Downloads: 249 / 529
Version history: 14 change(s)
Referenced in: [show references]