teems 0.3.2 → 0.3.3
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 +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +7 -0
- data/lib/teems/commands/meeting.rb +4 -3
- data/lib/teems/commands/messages.rb +51 -8
- data/lib/teems/commands/sync.rb +30 -3
- data/lib/teems/commands/transcripts.rb +205 -137
- data/lib/teems/formatters/format_utils.rb +3 -0
- data/lib/teems/formatters/markdown_formatter.rb +10 -1
- data/lib/teems/formatters/message_formatter.rb +7 -2
- data/lib/teems/formatters/transcript_markdown.rb +16 -12
- data/lib/teems/models/inline_image.rb +83 -0
- data/lib/teems/models/message.rb +7 -4
- data/lib/teems/models/parsing.rb +5 -0
- data/lib/teems/runner.rb +5 -0
- data/lib/teems/services/inline_image_downloader.rb +115 -0
- data/lib/teems/services/sync_engine.rb +13 -7
- data/lib/teems/services/sync_images.rb +55 -0
- data/lib/teems/support/subprocess.rb +2 -0
- data/lib/teems/version.rb +1 -1
- data/lib/teems.rb +4 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 554acde76f11331b9a92ba84e7a0972f0951b0e26f90019801550ab6767a3493
|
|
4
|
+
data.tar.gz: 39b410aaf606f2298871bb9f90f463f021dee51d08814fce7f0260d8432de8a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 209764374cdd5674d1f9d5398d33fd2bccf6a1869d0ff0ec11dd5d5202e78de3cb2a24eb3dc4a2431df348cda73ee7d928816ae1210690bdca9ba8138596fcdc
|
|
7
|
+
data.tar.gz: 06ad5d91c6ae16bb936910d5dbd1f9d6fa85df7a7bb27caaed5b652acd1ee265cd3a8408be8842aa3f2a7d6c06099c9580fa40e089a5ebd18b70d6cf91169c0d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.3.3] - 2026-10-02
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Inline images (screenshots pasted into a message) are no longer dropped when message HTML is stripped. `teems messages` lists them under the message, and `--json` includes an `images` array with the AMS URL, full-size URL, alt text, and dimensions.
|
|
7
|
+
- `teems messages --download` saves inline images alongside file attachments, fetching the original-resolution AMS view (falling back to the message's preview URL) with the skype token. The token is only sent to Teams/AMS hosts over HTTPS and is dropped on redirects elsewhere.
|
|
8
|
+
- `teems sync` records inline images in `messages.json` and renders `[image: alt (WxH)]` placeholders in `messages.md`. `teems sync --images` downloads them into each chat's `images/` directory, links them from `messages.md`, and backfills already-synced chats.
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- `teems messages <teams-url>` for a message in a group or 1:1 chat no longer fails with "Failed to fetch message"; those chats have no reply threads, so the replies endpoint's 404 now means no replies.
|
|
12
|
+
- `teems messages --json <teams-url>` no longer crashes with "no implicit conversion from nil to integer" after printing the thread.
|
|
13
|
+
|
|
3
14
|
## [0.3.2] - 2026-09-29
|
|
4
15
|
|
|
5
16
|
### Added
|
data/README.md
CHANGED
|
@@ -56,8 +56,12 @@ teems cal delete 3 # Delete event #3
|
|
|
56
56
|
teems messages <chat-id> # Read from a chat
|
|
57
57
|
teems messages <channel-id> -t <team-id> # Read from a channel
|
|
58
58
|
teems messages <chat-id> -n 50 # Show more messages
|
|
59
|
+
teems messages <chat-id> --json # JSON, including inline image refs
|
|
60
|
+
teems messages <chat-id> --download # Save attachments and pasted images
|
|
59
61
|
```
|
|
60
62
|
|
|
63
|
+
Screenshots pasted into a message are listed under it (`🖼️ image (881x179)`) and included in `--json` as `images` (AMS `url`, `full_size_url`, `alt`, `width`, `height`). `--download` saves the original-resolution image to the downloads directory as `image-<hash>-<n>.<ext>`, using your Teams skype token. The token is only sent to Teams/AMS hosts over HTTPS.
|
|
64
|
+
|
|
61
65
|
### Channels and Chats
|
|
62
66
|
|
|
63
67
|
```bash
|
|
@@ -151,8 +155,11 @@ teems activity # Show activity feed
|
|
|
151
155
|
|
|
152
156
|
```bash
|
|
153
157
|
teems sync # Sync chat history locally
|
|
158
|
+
teems sync --images # Also save pasted images beside each chat
|
|
154
159
|
```
|
|
155
160
|
|
|
161
|
+
Each chat gets `messages.md`, `messages.json`, and `chat_metadata.json` under `~/.local/share/teems/sync/chats/`. Inline images are recorded in `messages.json` and rendered in `messages.md` as `[image: alt (WxH)]`. With `--images`, they are downloaded to the chat's `images/` directory (named by AMS object id, so each is fetched once) and `messages.md` links the saved copy instead. `--images` also rewrites already-synced chats so images in older messages are backfilled.
|
|
162
|
+
|
|
156
163
|
## Global Options
|
|
157
164
|
|
|
158
165
|
| Option | Description |
|
|
@@ -613,10 +613,11 @@ module Teems
|
|
|
613
613
|
private
|
|
614
614
|
|
|
615
615
|
def output_meeting_json(target, classified)
|
|
616
|
+
call_events, recordings, transcripts = classified.values_at(:call_events, :recordings, :transcripts)
|
|
616
617
|
output_json(thread_id: target[:thread_id],
|
|
617
|
-
call_events:
|
|
618
|
-
recordings:
|
|
619
|
-
transcripts:
|
|
618
|
+
call_events: call_events.map { |event| json_call_event(event) },
|
|
619
|
+
recordings: recordings.map { |rec| rec.slice(:time, :url, :call_id) },
|
|
620
|
+
transcripts: transcripts.map { |item| item.slice(:time) })
|
|
620
621
|
0
|
|
621
622
|
end
|
|
622
623
|
|
|
@@ -14,7 +14,7 @@ module Teems
|
|
|
14
14
|
OPTIONS:
|
|
15
15
|
-t, --team ID Team ID (required for channel messages)
|
|
16
16
|
-n, --limit N Number of messages (default: 20)
|
|
17
|
-
--download Download file attachments
|
|
17
|
+
--download Download file attachments and inline images
|
|
18
18
|
-o, --output-dir Directory for downloads (default: ~/.local/share/teems/downloads)
|
|
19
19
|
-v, --verbose Show debug output
|
|
20
20
|
-q, --quiet Suppress output
|
|
@@ -23,10 +23,13 @@ module Teems
|
|
|
23
23
|
EXAMPLES:
|
|
24
24
|
teems messages 19:abc123@thread.v2 # Read chat messages
|
|
25
25
|
teems messages 19:abc123@thread.v2 -n 50 # Show 50 messages
|
|
26
|
+
teems messages 19:abc123@thread.v2 --download # Save attachments + pasted images
|
|
26
27
|
teems messages "https://teams.microsoft.com/l/message/19:abc@thread.v2/123?context=..."
|
|
27
28
|
# Show the linked message and its thread replies
|
|
28
29
|
HELP
|
|
29
30
|
|
|
31
|
+
IMAGE_ICON = "\u{1F5BC}\u{FE0F}"
|
|
32
|
+
|
|
30
33
|
# Display formatting for messages command
|
|
31
34
|
module MessagesDisplay
|
|
32
35
|
REACTION_EMOJI = {
|
|
@@ -45,6 +48,7 @@ module Teems
|
|
|
45
48
|
puts format_message_header(message)
|
|
46
49
|
puts " #{formatted_content(message)}"
|
|
47
50
|
display_attachments(message)
|
|
51
|
+
display_images(message)
|
|
48
52
|
display_reactions(message)
|
|
49
53
|
puts
|
|
50
54
|
end
|
|
@@ -66,6 +70,11 @@ module Teems
|
|
|
66
70
|
puts " #{output.gray("\u{1F4CE} #{names.join(', ')}")}"
|
|
67
71
|
end
|
|
68
72
|
|
|
73
|
+
def display_images(message)
|
|
74
|
+
summary = Formatters::FormatUtils.image_summary(message.images)
|
|
75
|
+
puts " #{output.gray("#{IMAGE_ICON} #{summary}")}" unless summary.empty?
|
|
76
|
+
end
|
|
77
|
+
|
|
69
78
|
def display_reactions(message)
|
|
70
79
|
reactions = message.reactions
|
|
71
80
|
return unless reactions.any?
|
|
@@ -85,7 +94,7 @@ module Teems
|
|
|
85
94
|
created_at: message.created_at&.iso8601,
|
|
86
95
|
importance: message.importance, reactions: message.reactions,
|
|
87
96
|
attachments: message.attachments, edited: message.edited,
|
|
88
|
-
mentions: message.mentions }
|
|
97
|
+
mentions: message.mentions, images: message.images.map(&:as_json) }
|
|
89
98
|
end
|
|
90
99
|
end
|
|
91
100
|
|
|
@@ -95,14 +104,15 @@ module Teems
|
|
|
95
104
|
|
|
96
105
|
def download_attachments(messages)
|
|
97
106
|
attachments = find_downloadable(messages)
|
|
98
|
-
|
|
107
|
+
images = inline_images(messages)
|
|
108
|
+
return puts('No downloadable attachments found') if attachments.empty? && images.empty?
|
|
99
109
|
|
|
100
|
-
execute_downloads(attachments)
|
|
110
|
+
execute_downloads(attachments, images)
|
|
101
111
|
end
|
|
102
112
|
|
|
103
|
-
def execute_downloads(attachments)
|
|
113
|
+
def execute_downloads(attachments, images)
|
|
104
114
|
dir = prepare_output_dir
|
|
105
|
-
count = attachments.sum { |att| download_one(att, dir) }
|
|
115
|
+
count = attachments.sum { |att| download_one(att, dir) } + images.sum { |entry| download_image(entry, dir) }
|
|
106
116
|
puts "Downloaded #{count} file#{'s' if count != 1} to #{dir}" if count.positive?
|
|
107
117
|
end
|
|
108
118
|
|
|
@@ -168,6 +178,29 @@ module Teems
|
|
|
168
178
|
end
|
|
169
179
|
end
|
|
170
180
|
|
|
181
|
+
# Download logic for images pasted inline into message bodies (Teams AMS objects)
|
|
182
|
+
module InlineImageDownload
|
|
183
|
+
private
|
|
184
|
+
|
|
185
|
+
# [message, image, 1-based position within the message] for every inline image
|
|
186
|
+
def inline_images(messages) = messages.flat_map { |msg| numbered_images(msg) }
|
|
187
|
+
|
|
188
|
+
def numbered_images(msg) = msg.images.map.with_index(1) { |image, number| [msg, image, number] }
|
|
189
|
+
|
|
190
|
+
def download_image(entry, dir)
|
|
191
|
+
msg, image, number = entry
|
|
192
|
+
print "#{IMAGE_ICON} Downloading #{image.label}..."
|
|
193
|
+
result = with_token_refresh { image_downloader.fetch(image) }
|
|
194
|
+
path = unique_path(dir, "image-#{msg.short_hash}-#{number}.#{result.extension}")
|
|
195
|
+
puts " done (#{Formatters::FormatUtils.format_bytes(File.binwrite(path, result.body))}) #{path}"
|
|
196
|
+
1
|
|
197
|
+
rescue StandardError => e
|
|
198
|
+
handle_download_error(e)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def image_downloader = @image_downloader ||= runner.inline_image_downloader
|
|
202
|
+
end
|
|
203
|
+
|
|
171
204
|
# Fetch and render a single message and its thread replies
|
|
172
205
|
module ThreadFetch
|
|
173
206
|
private
|
|
@@ -175,7 +208,7 @@ module Teems
|
|
|
175
208
|
def fetch_thread(thread_id, message_id)
|
|
176
209
|
api = runner.messages_api
|
|
177
210
|
parent_data = with_token_refresh { api.message(thread_id: thread_id, message_id: message_id) }
|
|
178
|
-
replies_data =
|
|
211
|
+
replies_data = fetch_replies do
|
|
179
212
|
api.replies(thread_id: thread_id, message_id: message_id, limit: @options[:limit])
|
|
180
213
|
end
|
|
181
214
|
display_thread(parent_data, extract_messages_data(replies_data))
|
|
@@ -183,10 +216,19 @@ module Teems
|
|
|
183
216
|
error("Failed to fetch message: #{e.message}")
|
|
184
217
|
end
|
|
185
218
|
|
|
219
|
+
# Group and 1:1 chats have no reply threads; their replies endpoint returns 404
|
|
220
|
+
def fetch_replies(&)
|
|
221
|
+
with_token_refresh(&)
|
|
222
|
+
rescue ApiError => e
|
|
223
|
+
raise unless e.not_found?
|
|
224
|
+
|
|
225
|
+
{}
|
|
226
|
+
end
|
|
227
|
+
|
|
186
228
|
def display_thread(parent_data, replies_data)
|
|
187
229
|
parent = Models::Message.from_api(parent_data)
|
|
188
230
|
replies = replies_data.map { |data| Models::Message.from_api(data) }.reject(&:system_message?).reverse
|
|
189
|
-
return output_json(thread_to_hash(parent, replies)) if @options[:json]
|
|
231
|
+
return output_json(thread_to_hash(parent, replies)) || 0 if @options[:json]
|
|
190
232
|
|
|
191
233
|
render_thread(parent, replies)
|
|
192
234
|
download_attachments([parent, *replies]) if @options[:download]
|
|
@@ -212,6 +254,7 @@ module Teems
|
|
|
212
254
|
class Messages < Base
|
|
213
255
|
include MessagesDisplay
|
|
214
256
|
include AttachmentDownload
|
|
257
|
+
include InlineImageDownload
|
|
215
258
|
include ThreadFetch
|
|
216
259
|
|
|
217
260
|
def initialize(args, runner:)
|
data/lib/teems/commands/sync.rb
CHANGED
|
@@ -11,6 +11,7 @@ module Teems
|
|
|
11
11
|
OPTIONS:
|
|
12
12
|
--since DAYS Number of days of history to sync (default: 180)
|
|
13
13
|
--chat CHAT_ID Sync only this chat
|
|
14
|
+
--images Also download inline (pasted) images into each chat's images/ dir
|
|
14
15
|
--auth Authenticate via Safari before syncing
|
|
15
16
|
--dry-run Show what would be synced without writing files
|
|
16
17
|
-v, --verbose Show debug output
|
|
@@ -20,11 +21,13 @@ module Teems
|
|
|
20
21
|
teems sync # Sync 6 months of all chats
|
|
21
22
|
teems sync --since 30 # Sync last 30 days
|
|
22
23
|
teems sync --chat 19:abc@thread.v2 # Sync a single chat
|
|
24
|
+
teems sync --images # Include pasted screenshots
|
|
23
25
|
teems sync --dry-run # Preview what would be synced
|
|
24
26
|
|
|
25
27
|
OUTPUT:
|
|
26
28
|
Files are stored in ~/.local/share/teems/sync/chats/
|
|
27
29
|
Each chat gets: messages.md, messages.json, chat_metadata.json
|
|
30
|
+
(plus images/ with --images; messages.md links saved images, otherwise [image: ...])
|
|
28
31
|
HELP
|
|
29
32
|
|
|
30
33
|
# Handles syncing individual chats: fetch, merge, retry on 404
|
|
@@ -70,7 +73,9 @@ module Teems
|
|
|
70
73
|
|
|
71
74
|
def process_fetched_messages(chat, new_messages)
|
|
72
75
|
chat_id = chat.id
|
|
73
|
-
|
|
76
|
+
# --images rewrites unchanged chats too, so images in already-synced messages are backfilled
|
|
77
|
+
unchanged = new_messages.empty? && !@options[:images]
|
|
78
|
+
return skip_unchanged(chat_id) if unchanged && @sync_store.last_synced_time(@state, chat_id)
|
|
74
79
|
|
|
75
80
|
merge_and_update(chat, new_messages)
|
|
76
81
|
end
|
|
@@ -83,7 +88,9 @@ module Teems
|
|
|
83
88
|
|
|
84
89
|
def merge_and_update(chat, new_messages)
|
|
85
90
|
existing_raw = @sync_store.read_messages_json(chat.id, state: @state)
|
|
86
|
-
all_messages = sync_engine.merge_and_write(chat, existing_raw, new_messages)
|
|
91
|
+
all_messages = sync_engine.merge_and_write(chat, existing_raw, new_messages) do |chat_dir, messages|
|
|
92
|
+
save_chat_images(chat_dir, messages)
|
|
93
|
+
end
|
|
87
94
|
update_chat_state(chat, all_messages)
|
|
88
95
|
end
|
|
89
96
|
|
|
@@ -138,6 +145,23 @@ module Teems
|
|
|
138
145
|
end
|
|
139
146
|
end
|
|
140
147
|
|
|
148
|
+
# Opt-in (--images) download of inline images into each synced chat directory
|
|
149
|
+
module SyncImageHandler
|
|
150
|
+
private
|
|
151
|
+
|
|
152
|
+
def save_chat_images(chat_dir, messages)
|
|
153
|
+
return unless @options[:images]
|
|
154
|
+
|
|
155
|
+
saved = sync_images.save(chat_dir, messages)
|
|
156
|
+
debug(" Saved #{saved} image(s)")
|
|
157
|
+
@stats[:images] += saved
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def sync_images
|
|
161
|
+
@sync_images ||= Services::SyncImages.new(downloader: runner.inline_image_downloader, output: output)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
141
165
|
# Chat list fetching, dry-run display, and summary reporting
|
|
142
166
|
module SyncDisplay
|
|
143
167
|
private
|
|
@@ -211,6 +235,7 @@ module Teems
|
|
|
211
235
|
skipped = @stats[:skipped]
|
|
212
236
|
info(" Chats skipped (no new messages): #{skipped}") if skipped.positive?
|
|
213
237
|
info(" Total messages: #{@stats[:messages_total]}")
|
|
238
|
+
info(" Images downloaded: #{@stats[:images]}") if @options[:images]
|
|
214
239
|
display_error_count
|
|
215
240
|
end
|
|
216
241
|
|
|
@@ -287,6 +312,7 @@ module Teems
|
|
|
287
312
|
# Sync chat history locally as Markdown + JSON files
|
|
288
313
|
class Sync < Base
|
|
289
314
|
include SyncChatHandler
|
|
315
|
+
include SyncImageHandler
|
|
290
316
|
include SyncDisplay
|
|
291
317
|
include SyncAuth
|
|
292
318
|
|
|
@@ -318,6 +344,7 @@ module Teems
|
|
|
318
344
|
'--since' => ->(opts, args) { opts[:since_days] = args.shift.to_i },
|
|
319
345
|
'--chat' => ->(opts, args) { opts[:chat_id] = args.shift },
|
|
320
346
|
'--dry-run' => ->(opts, _args) { opts[:dry_run] = true },
|
|
347
|
+
'--images' => ->(opts, _args) { opts[:images] = true },
|
|
321
348
|
'--auth' => ->(opts, _args) { opts[:auth] = true }
|
|
322
349
|
}.freeze
|
|
323
350
|
|
|
@@ -353,7 +380,7 @@ module Teems
|
|
|
353
380
|
def init_sync_state
|
|
354
381
|
@sync_store = Services::SyncStore.new
|
|
355
382
|
@state = @sync_store.load_state
|
|
356
|
-
@stats = { synced: 0, skipped: 0, errors: 0, messages_total: 0 }
|
|
383
|
+
@stats = { synced: 0, skipped: 0, errors: 0, messages_total: 0, images: 0 }
|
|
357
384
|
setup_api_logging
|
|
358
385
|
end
|
|
359
386
|
|