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).

1  
!7
2  
3  
cmodule PollTwitterSearch > DynPrintLogAndEnabled {
4  
  S query = "#javascript";
5  
  transient new Set<Long> seen;
6  
  
7  
  transient AsyncTwitter asyncTwitter;
8  
  
9  
  start-thread {
10  
    if (!enabled) ret;
11  
    vm_cleanPrints();
12  
    
13  
    Twitter twitter = twitter4j_init();
14  
    
15  
    asyncTwitter = new AsyncTwitterFactory().getInstance(twitter);
16  
    asyncTwitter.addListener(new TwitterAdapter {
17  
      public void searched(QueryResult qr) enter {
18  
        pcall {
19  
          L<Status> tweets = qr.getTweets();
20  
          //print("Have Tweets: " + l(tweets));
21  
  
22  
          new Set<Long> seen2;
23  
          bool first = true;
24  
          for (Status t : tweets) {
25  
            long id = t.getId();
26  
            seen2.add(id);
27  
            continue if seen.contains(id);
28  
            if (first) { first = false; printWithMS("NEW TWEETS"); }
29  
            
30  
            User usr = t.getUser();
31  
            print("  " + localDateWithMilliseconds(t.getCreatedAt()) + " " + id + " " + (usr == null ? "none" : "@" + usr.getScreenName() + " // " + usr.getName()) + ": " + escapeNewLines(t.getText()));
32  
          }
33  
          setField(seen := seen2);
34  
        }
35  
      }
36  
    });
37  
    
38  
    print("Looping");
39  
    repeat with sleep 5 {
40  
      if (enabled) {
41  
        //print("Searching");
42  
        asyncTwitter.search(new Query(query));
43  
      }
44  
    }
45  
  }
46  
}

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: 326 / 628
Version history: 14 change(s)
Referenced in: [show references]