forked from CyberShadow/DFeed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdfeed.d
85 lines (71 loc) · 2.78 KB
/
dfeed.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/* Copyright (C) 2011, 2012 Vladimir Panteleev <vladimir@thecybershadow.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
module dfeed;
import std.file;
import std.getopt;
import std.stdio;
import ae.net.asockets;
import common;
import web;
// Sources
import newsgroups;
import mailinglists;
import stackoverflow;
import feed;
import reddit;
// Sinks
import ircsink;
import messagedb;
// Captcha engine
import recaptcha;
void main(string[] args)
{
getopt(args,
"q|quiet", &common.quiet);
// Create sources
startNNTP();
new MailingLists();
new StackOverflow("d");
new Feed("Planet D", "http://planetd.thecybershadow.net/_atom.xml");
new Feed("Wikipedia", "http://en.wikipedia.org/w/api.php?action=feedwatchlist&allrev=allrev&hours=1&"~readText("data/wikipedia.txt")~"&feedformat=atom", "edited");
//new Feed("GitHub", "https://github.com/"~readText("data/github.txt"), null); // TODO: HTTPS
new Feed("GitHub", "http://thecybershadow.net/d/ghfeed.php", null);
// new Reddit("programming", `(^|[^\w\d\-:*=])D([^\w\-:*=]|$)`);
// new Feed("Twitter-WalterBright", "http://twitter.com/statuses/user_timeline/18061210.atom", null, 120);
// new Feed("Twitter-incomputable", "http://twitter.com/statuses/user_timeline/155425162.atom", null, 120);
// new Feed("Twitter-D_programming", "http://twitter.com/statuses/user_timeline/148794328.atom", null, 120);
// new Feed("Twitter-DigitalMars", "http://twitter.com/statuses/user_timeline/148481064.atom", null, 120);
// Create sinks
new IrcSink();
new MessageDBSink();
// Start web server
new WebUI();
startNewsSources();
socketManager.loop();
if (!common.quiet)
writeln("Exiting.");
}
/// Avoid any problems (bugs or missed messages) caused by downloader/listener running
/// simultaneously or sequentially by doing the following:
/// 1. Note NNTP server time before starting downloader (sync)
/// 2. Download new messages
/// 3. Start listener with querying for new messages since the download START.
void startNNTP()
{
auto downloader = new NntpDownloader("news.digitalmars.com", NntpDownloader.Mode.fullPurge);
auto listener = new NntpListenerSource("news.digitalmars.com");
downloader.handleFinished = &listener.startListening;
}