heathrow 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +58 -0
- data/README.md +205 -0
- data/bin/heathrow +42 -0
- data/bin/heathrowd +283 -0
- data/docs/ARCHITECTURE.md +1172 -0
- data/docs/DATABASE_SCHEMA.md +685 -0
- data/docs/DEVELOPMENT_WORKFLOW.md +867 -0
- data/docs/DISCORD_SETUP.md +142 -0
- data/docs/GMAIL_OAUTH_SETUP.md +120 -0
- data/docs/PLUGIN_SYSTEM.md +1370 -0
- data/docs/PROJECT_PLAN.md +1022 -0
- data/docs/README.md +417 -0
- data/docs/REDDIT_SETUP.md +174 -0
- data/docs/REPLY_FORWARD.md +182 -0
- data/docs/WHATSAPP_TELEGRAM_SETUP.md +306 -0
- data/heathrow.gemspec +34 -0
- data/heathrowd.service +21 -0
- data/img/heathrow.svg +95 -0
- data/img/rss_threaded.png +0 -0
- data/img/sources.png +0 -0
- data/lib/heathrow/address_book.rb +42 -0
- data/lib/heathrow/config.rb +332 -0
- data/lib/heathrow/database.rb +731 -0
- data/lib/heathrow/database_new.rb +392 -0
- data/lib/heathrow/event_bus.rb +175 -0
- data/lib/heathrow/logger.rb +122 -0
- data/lib/heathrow/message.rb +176 -0
- data/lib/heathrow/message_composer.rb +399 -0
- data/lib/heathrow/message_organizer.rb +774 -0
- data/lib/heathrow/migrations/001_initial_schema.rb +248 -0
- data/lib/heathrow/notmuch.rb +45 -0
- data/lib/heathrow/oauth2_smtp.rb +254 -0
- data/lib/heathrow/plugin/base.rb +212 -0
- data/lib/heathrow/plugin_manager.rb +141 -0
- data/lib/heathrow/poller.rb +93 -0
- data/lib/heathrow/smtp_sender.rb +204 -0
- data/lib/heathrow/source.rb +39 -0
- data/lib/heathrow/sources/base.rb +74 -0
- data/lib/heathrow/sources/discord.rb +357 -0
- data/lib/heathrow/sources/gmail.rb +294 -0
- data/lib/heathrow/sources/imap.rb +198 -0
- data/lib/heathrow/sources/instagram.rb +307 -0
- data/lib/heathrow/sources/instagram_fetch.py +101 -0
- data/lib/heathrow/sources/instagram_send.py +55 -0
- data/lib/heathrow/sources/instagram_send_marionette.py +104 -0
- data/lib/heathrow/sources/maildir.rb +606 -0
- data/lib/heathrow/sources/messenger.rb +212 -0
- data/lib/heathrow/sources/messenger_fetch.js +297 -0
- data/lib/heathrow/sources/messenger_fetch_marionette.py +138 -0
- data/lib/heathrow/sources/messenger_send.js +32 -0
- data/lib/heathrow/sources/messenger_send.py +100 -0
- data/lib/heathrow/sources/reddit.rb +461 -0
- data/lib/heathrow/sources/rss.rb +299 -0
- data/lib/heathrow/sources/slack.rb +375 -0
- data/lib/heathrow/sources/source_manager.rb +328 -0
- data/lib/heathrow/sources/telegram.rb +498 -0
- data/lib/heathrow/sources/webpage.rb +207 -0
- data/lib/heathrow/sources/weechat.rb +479 -0
- data/lib/heathrow/sources/whatsapp.rb +474 -0
- data/lib/heathrow/ui/application.rb +8098 -0
- data/lib/heathrow/ui/navigation.rb +8 -0
- data/lib/heathrow/ui/panes.rb +8 -0
- data/lib/heathrow/ui/source_wizard.rb +567 -0
- data/lib/heathrow/ui/threaded_view.rb +780 -0
- data/lib/heathrow/ui/views.rb +8 -0
- data/lib/heathrow/version.rb +3 -0
- data/lib/heathrow/wizards/discord_wizard.rb +193 -0
- data/lib/heathrow/wizards/slack_wizard.rb +140 -0
- data/lib/heathrow.rb +55 -0
- metadata +147 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Discord Setup Guide for Heathrow
|
|
2
|
+
|
|
3
|
+
This guide will help you set up Discord as a source in Heathrow to monitor Discord channels and servers.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
You need a Discord Bot Token. If you already have one (like from discord-irc), you can use it. Otherwise, follow the setup below.
|
|
8
|
+
|
|
9
|
+
## Creating a Discord Bot
|
|
10
|
+
|
|
11
|
+
### 1. Create a Discord Application
|
|
12
|
+
|
|
13
|
+
1. Go to https://discord.com/developers/applications
|
|
14
|
+
2. Click "New Application"
|
|
15
|
+
3. Give it a name (e.g., "Heathrow Bot")
|
|
16
|
+
4. Click "Create"
|
|
17
|
+
|
|
18
|
+
### 2. Create the Bot
|
|
19
|
+
|
|
20
|
+
1. In your application, go to the "Bot" section in the left sidebar
|
|
21
|
+
2. Click "Add Bot"
|
|
22
|
+
3. Under "Token", click "Copy" to copy your bot token
|
|
23
|
+
4. **Save this token securely** - you'll need it for Heathrow
|
|
24
|
+
|
|
25
|
+
### 3. Set Bot Permissions
|
|
26
|
+
|
|
27
|
+
1. In the "Bot" section, configure:
|
|
28
|
+
- **Public Bot**: OFF (unless you want others to add your bot)
|
|
29
|
+
- **Requires OAuth2 Code Grant**: OFF
|
|
30
|
+
- **Message Content Intent**: ON (required to read message content)
|
|
31
|
+
|
|
32
|
+
### 4. Invite Bot to Your Servers
|
|
33
|
+
|
|
34
|
+
1. Go to "OAuth2" → "URL Generator" in the left sidebar
|
|
35
|
+
2. Under "Scopes", select:
|
|
36
|
+
- `bot`
|
|
37
|
+
3. Under "Bot Permissions", select:
|
|
38
|
+
- Read Messages/View Channels
|
|
39
|
+
- Read Message History
|
|
40
|
+
4. Copy the generated URL
|
|
41
|
+
5. Open the URL in your browser
|
|
42
|
+
6. Select the server you want to add the bot to
|
|
43
|
+
7. Click "Authorize"
|
|
44
|
+
|
|
45
|
+
## Getting Channel and Server IDs
|
|
46
|
+
|
|
47
|
+
### Enable Developer Mode
|
|
48
|
+
|
|
49
|
+
1. Open Discord (app or web)
|
|
50
|
+
2. Go to Settings → Advanced
|
|
51
|
+
3. Enable "Developer Mode"
|
|
52
|
+
|
|
53
|
+
### Get Channel IDs
|
|
54
|
+
|
|
55
|
+
1. Right-click on any channel
|
|
56
|
+
2. Click "Copy Channel ID"
|
|
57
|
+
|
|
58
|
+
### Get Server/Guild IDs
|
|
59
|
+
|
|
60
|
+
1. Right-click on any server icon
|
|
61
|
+
2. Click "Copy Server ID"
|
|
62
|
+
|
|
63
|
+
## Adding Discord to Heathrow
|
|
64
|
+
|
|
65
|
+
1. In Heathrow, press 's' for Sources view
|
|
66
|
+
2. Press 'a' to add a new source
|
|
67
|
+
3. Choose "Discord"
|
|
68
|
+
4. Fill in:
|
|
69
|
+
- **Account Name**: Any name you want (e.g., "My Discord")
|
|
70
|
+
- **Bot Token**: Your bot token (starts with MTM...)
|
|
71
|
+
- **Is Bot Token?**: Yes (leave checked)
|
|
72
|
+
- **Channel IDs**: Comma-separated list of channel IDs to monitor
|
|
73
|
+
- Example: `123456789012345678,234567890123456789`
|
|
74
|
+
- **Guild/Server IDs**: Optional - monitors all channels in these servers
|
|
75
|
+
- **Messages per fetch**: 20 (or adjust as needed)
|
|
76
|
+
- **Check interval**: 60 seconds (or adjust as needed)
|
|
77
|
+
|
|
78
|
+
## Configuration Examples
|
|
79
|
+
|
|
80
|
+
### Monitor Specific Channels Only
|
|
81
|
+
```
|
|
82
|
+
Channel IDs: 123456789012345678,234567890123456789
|
|
83
|
+
Guild IDs: (leave empty)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### Monitor All Channels in a Server
|
|
87
|
+
```
|
|
88
|
+
Channel IDs: (leave empty)
|
|
89
|
+
Guild IDs: 345678901234567890
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Monitor Mix of Both
|
|
93
|
+
```
|
|
94
|
+
Channel IDs: 123456789012345678
|
|
95
|
+
Guild IDs: 456789012345678901
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Using an Existing discord-irc Bot
|
|
99
|
+
|
|
100
|
+
If you already have discord-irc running (like in your weechat setup), you can reuse the same bot token:
|
|
101
|
+
|
|
102
|
+
1. Find your discord-irc config (usually `~/.config/discord-irc.json`)
|
|
103
|
+
2. Copy the `discordToken` value
|
|
104
|
+
3. Note the channel IDs from `channelMapping`
|
|
105
|
+
4. Use these in Heathrow
|
|
106
|
+
|
|
107
|
+
## Troubleshooting
|
|
108
|
+
|
|
109
|
+
### "403 Forbidden" Errors
|
|
110
|
+
- The bot doesn't have permission to read that channel
|
|
111
|
+
- Re-invite the bot with proper permissions
|
|
112
|
+
- Check if the channel is private and the bot has access
|
|
113
|
+
|
|
114
|
+
### No Messages Appearing
|
|
115
|
+
- Check the bot has "Read Message History" permission
|
|
116
|
+
- Verify the channel IDs are correct
|
|
117
|
+
- Ensure the bot is actually in the server
|
|
118
|
+
|
|
119
|
+
### "401 Unauthorized"
|
|
120
|
+
- Your bot token is invalid or expired
|
|
121
|
+
- Double-check you copied the complete token
|
|
122
|
+
- Regenerate the token if needed
|
|
123
|
+
|
|
124
|
+
## Security Notes
|
|
125
|
+
|
|
126
|
+
- **Never share your bot token** - anyone with it can control your bot
|
|
127
|
+
- Bot tokens don't expire unless you regenerate them
|
|
128
|
+
- Consider using a separate bot for Heathrow if you use Discord bots elsewhere
|
|
129
|
+
- The bot can only see channels it has access to
|
|
130
|
+
|
|
131
|
+
## Rate Limits
|
|
132
|
+
|
|
133
|
+
Discord has rate limits to prevent abuse:
|
|
134
|
+
- Don't set polling interval below 30 seconds
|
|
135
|
+
- The integration fetches max 100 messages per channel per request
|
|
136
|
+
- If you hit rate limits, you'll see 429 errors - increase the polling interval
|
|
137
|
+
|
|
138
|
+
## Privacy Considerations
|
|
139
|
+
|
|
140
|
+
- The bot can see all messages in channels it has access to
|
|
141
|
+
- Messages are stored locally in Heathrow's database
|
|
142
|
+
- Consider informing server members if monitoring shared servers
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# Gmail OAuth2 Setup Guide for Heathrow
|
|
2
|
+
|
|
3
|
+
To use Gmail as a source in Heathrow, you need to set up OAuth2 authentication. This is required because Gmail no longer supports simple username/password authentication for third-party apps.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
1. **oauth2.py script**: Download from https://github.com/google/gmail-oauth2-tools/blob/master/python/oauth2.py
|
|
8
|
+
- Save it to `~/bin/oauth2.py` (or another location you prefer)
|
|
9
|
+
- Make it executable: `chmod +x ~/bin/oauth2.py`
|
|
10
|
+
|
|
11
|
+
2. **Python 3**: The oauth2.py script requires Python 3
|
|
12
|
+
|
|
13
|
+
3. **Safe directory**: Create a directory for your OAuth files (e.g., `~/.heathrow/mail`)
|
|
14
|
+
- This directory will store your credentials and refresh token
|
|
15
|
+
- Make sure it's only readable by you: `chmod 700 ~/.heathrow/mail`
|
|
16
|
+
|
|
17
|
+
## Setup Steps
|
|
18
|
+
|
|
19
|
+
### 1. Create a Google Cloud Project
|
|
20
|
+
|
|
21
|
+
1. Go to https://console.cloud.google.com/
|
|
22
|
+
2. Create a new project (e.g., "heathrow-mail")
|
|
23
|
+
3. Note the project name for later
|
|
24
|
+
|
|
25
|
+
### 2. Configure OAuth Consent Screen
|
|
26
|
+
|
|
27
|
+
1. In the Google Cloud Console, go to "APIs & Services" → "OAuth consent screen"
|
|
28
|
+
2. Choose "External" as the user type
|
|
29
|
+
3. Fill in the required fields:
|
|
30
|
+
- App name: "Heathrow Mail Fetcher" (or your preference)
|
|
31
|
+
- User support email: Your email address
|
|
32
|
+
- Developer contact: Your email address
|
|
33
|
+
4. Click "Save and Continue"
|
|
34
|
+
5. Add scope: `https://mail.google.com/`
|
|
35
|
+
6. Click "Save and Continue" (skip test users)
|
|
36
|
+
7. Click "Back to Dashboard"
|
|
37
|
+
|
|
38
|
+
### 3. Enable Gmail API
|
|
39
|
+
|
|
40
|
+
1. Go to "APIs & Services" → "Library"
|
|
41
|
+
2. Search for "Gmail API"
|
|
42
|
+
3. Click on it and press "Enable"
|
|
43
|
+
|
|
44
|
+
### 4. Create OAuth2 Credentials
|
|
45
|
+
|
|
46
|
+
1. Go to "APIs & Services" → "Credentials"
|
|
47
|
+
2. Click "+ CREATE CREDENTIALS" → "OAuth client ID"
|
|
48
|
+
3. Choose "Web application" as the application type
|
|
49
|
+
4. Name it (e.g., "Heathrow OAuth")
|
|
50
|
+
5. Under "Authorized redirect URIs", add: `https://oauth2.dance/`
|
|
51
|
+
6. Click "Create"
|
|
52
|
+
7. Download the JSON file
|
|
53
|
+
|
|
54
|
+
### 5. Save Credentials
|
|
55
|
+
|
|
56
|
+
1. Rename the downloaded JSON file to match your email address:
|
|
57
|
+
- Example: `youremail@gmail.com.json`
|
|
58
|
+
2. Move it to your safe directory:
|
|
59
|
+
- `mv ~/Downloads/client_secret_*.json ~/.heathrow/mail/youremail@gmail.com.json`
|
|
60
|
+
|
|
61
|
+
### 6. Generate Refresh Token
|
|
62
|
+
|
|
63
|
+
1. Run the oauth2.py script with your credentials:
|
|
64
|
+
```bash
|
|
65
|
+
cd ~/.heathrow/mail
|
|
66
|
+
oauth2.py --generate_oauth2_token \
|
|
67
|
+
--client_id=YOUR_CLIENT_ID \
|
|
68
|
+
--client_secret=YOUR_CLIENT_SECRET \
|
|
69
|
+
--scope=https://mail.google.com/
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
2. The script will give you a URL - open it in your browser
|
|
73
|
+
3. Authorize the application
|
|
74
|
+
4. Copy the authorization code from the redirect page
|
|
75
|
+
5. Paste it into the terminal
|
|
76
|
+
6. The script will output a refresh token
|
|
77
|
+
|
|
78
|
+
### 7. Save Refresh Token
|
|
79
|
+
|
|
80
|
+
1. Create a text file with your email name:
|
|
81
|
+
- Example: `youremail@gmail.com.txt`
|
|
82
|
+
2. Put ONLY the refresh token in this file (no other text)
|
|
83
|
+
3. Save it in your safe directory
|
|
84
|
+
|
|
85
|
+
## File Structure
|
|
86
|
+
|
|
87
|
+
After setup, your safe directory should contain:
|
|
88
|
+
```
|
|
89
|
+
~/.heathrow/mail/
|
|
90
|
+
├── youremail@gmail.com.json # OAuth2 credentials from Google
|
|
91
|
+
└── youremail@gmail.com.txt # Refresh token (single line)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Adding to Heathrow
|
|
95
|
+
|
|
96
|
+
Now you can add Gmail as a source in Heathrow:
|
|
97
|
+
|
|
98
|
+
1. Press 's' to go to Sources view
|
|
99
|
+
2. Press 'a' to add a new source
|
|
100
|
+
3. Choose "Gmail (OAuth2)"
|
|
101
|
+
4. Fill in:
|
|
102
|
+
- Account Name: Any name you want
|
|
103
|
+
- Gmail Address: youremail@gmail.com
|
|
104
|
+
- Safe Directory: ~/.heathrow/mail
|
|
105
|
+
- OAuth2 Script: ~/bin/oauth2.py
|
|
106
|
+
- Leave other fields as default
|
|
107
|
+
|
|
108
|
+
## Troubleshooting
|
|
109
|
+
|
|
110
|
+
- **"Token retrieval failed"**: Check that both .json and .txt files exist and are named correctly
|
|
111
|
+
- **"Authentication failed"**: Your refresh token may have expired - regenerate it
|
|
112
|
+
- **No new messages**: Gmail might already be marked as read by another client
|
|
113
|
+
- **SSL errors**: Make sure you have the gmail_xoauth gem installed: `gem install gmail_xoauth`
|
|
114
|
+
|
|
115
|
+
## Security Notes
|
|
116
|
+
|
|
117
|
+
- Keep your safe directory secure (`chmod 700`)
|
|
118
|
+
- Never share your refresh token or credentials JSON
|
|
119
|
+
- The refresh token doesn't expire unless you revoke it
|
|
120
|
+
- You can revoke access at https://myaccount.google.com/permissions
|