talknote_rb 0.1.0 → 0.2.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 +4 -4
- data/.github/dependabot.yml +11 -0
- data/.github/workflows/main.yml +37 -0
- data/Gemfile +6 -3
- data/Gemfile.lock +71 -34
- data/README.md +351 -13
- data/examples/complete_csv_export_example.rb +268 -0
- data/examples/dm_csv_export_example.rb +133 -0
- data/examples/dm_example.rb +55 -0
- data/examples/group_csv_export_example.rb +146 -0
- data/examples/group_example.rb +107 -0
- data/lib/talknote/cli.rb +142 -37
- data/lib/talknote/client.rb +56 -13
- data/lib/talknote/version.rb +1 -1
- data/lib/talknote.rb +2 -0
- data/talknote_rb.gemspec +9 -4
- metadata +86 -10
- data/.travis.yml +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6d214dec33ec2622bfe1d52931690bf988e6f7d825dda2f37bd9cb219ebf28d
|
4
|
+
data.tar.gz: 4df093e513a0d9b56e49103a3e729d0fc6da3610993eea2ca82c6aa6da3865ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58038dfcafd4a41f0652a712511d1349bd3e3ecd854df2c0ba9474c5149ef96954d8fa031c18c37e08ec47a148b9b436400e1839b5408b53df0fe921daeba6f1
|
7
|
+
data.tar.gz: 273b08d4029be1147174e224b2f0043e4a40b0a05277046b368341738f6a1172e23c29e0e7e463b9db652a5eb20c142194de094cdef5093f3c1d542cb204c37f
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# To get started with Dependabot version updates, you'll need to specify which
|
2
|
+
# package ecosystems to update and where the package manifests are located.
|
3
|
+
# Please see the documentation for all configuration options:
|
4
|
+
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
5
|
+
|
6
|
+
version: 2
|
7
|
+
updates:
|
8
|
+
- package-ecosystem: bundler # See documentation for possible values
|
9
|
+
directory: "/" # Location of package manifests
|
10
|
+
schedule:
|
11
|
+
interval: "daily"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on: [push,pull_request]
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
test:
|
14
|
+
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
timeout-minutes: 30
|
17
|
+
strategy:
|
18
|
+
fail-fast: false
|
19
|
+
matrix:
|
20
|
+
ruby-version: ['3.3', '3.4', 'head', 'debug']
|
21
|
+
|
22
|
+
steps:
|
23
|
+
- uses: actions/checkout@v3
|
24
|
+
- name: Set up Ruby
|
25
|
+
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
26
|
+
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
27
|
+
uses: ruby/setup-ruby@v1
|
28
|
+
with:
|
29
|
+
ruby-version: ${{ matrix.ruby-version }}
|
30
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
31
|
+
- name: Run tests
|
32
|
+
run: |
|
33
|
+
bundle exec rake
|
34
|
+
- name: CodeCov
|
35
|
+
uses: codecov/codecov-action@v3
|
36
|
+
with:
|
37
|
+
files: ./coverage/coverage.xml
|
data/Gemfile
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in talknote_rb.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem
|
7
|
-
gem
|
6
|
+
gem 'rake', '~> 13.0'
|
7
|
+
gem 'rspec', '~> 3.12'
|
8
|
+
gem 'simplecov', '~> 0.21.0', require: false
|
9
|
+
gem 'simplecov-cobertura', require: false
|
10
|
+
gem 'csv', '~> 3.0'
|
data/Gemfile.lock
CHANGED
@@ -1,53 +1,90 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
talknote_rb (0.
|
5
|
-
|
6
|
-
|
4
|
+
talknote_rb (0.2.0)
|
5
|
+
base64
|
6
|
+
bigdecimal
|
7
|
+
csv (~> 3.0)
|
8
|
+
faraday (~> 2.0)
|
9
|
+
json
|
10
|
+
oauth2 (~> 2.0)
|
7
11
|
thor
|
12
|
+
webrick
|
8
13
|
|
9
14
|
GEM
|
10
15
|
remote: https://rubygems.org/
|
11
16
|
specs:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
base64 (0.3.0)
|
18
|
+
bigdecimal (3.2.2)
|
19
|
+
csv (3.3.5)
|
20
|
+
diff-lcs (1.6.2)
|
21
|
+
docile (1.4.1)
|
22
|
+
faraday (2.13.1)
|
23
|
+
faraday-net_http (>= 2.0, < 3.5)
|
24
|
+
json
|
25
|
+
logger
|
26
|
+
faraday-net_http (3.4.1)
|
27
|
+
net-http (>= 0.5.0)
|
28
|
+
hashie (5.0.0)
|
29
|
+
json (2.12.2)
|
30
|
+
jwt (3.0.0)
|
31
|
+
base64
|
32
|
+
logger (1.7.0)
|
33
|
+
multi_xml (0.7.2)
|
34
|
+
bigdecimal (~> 3.1)
|
35
|
+
net-http (0.6.0)
|
36
|
+
uri
|
37
|
+
oauth2 (2.0.12)
|
38
|
+
faraday (>= 0.17.3, < 4.0)
|
39
|
+
jwt (>= 1.0, < 4.0)
|
40
|
+
logger (~> 1.2)
|
24
41
|
multi_xml (~> 0.5)
|
25
|
-
rack (>= 1.2, <
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
rspec-
|
34
|
-
|
42
|
+
rack (>= 1.2, < 4)
|
43
|
+
snaky_hash (~> 2.0, >= 2.0.3)
|
44
|
+
version_gem (>= 1.1.8, < 3)
|
45
|
+
rack (3.1.16)
|
46
|
+
rake (13.3.0)
|
47
|
+
rexml (3.4.1)
|
48
|
+
rspec (3.13.1)
|
49
|
+
rspec-core (~> 3.13.0)
|
50
|
+
rspec-expectations (~> 3.13.0)
|
51
|
+
rspec-mocks (~> 3.13.0)
|
52
|
+
rspec-core (3.13.4)
|
53
|
+
rspec-support (~> 3.13.0)
|
54
|
+
rspec-expectations (3.13.5)
|
35
55
|
diff-lcs (>= 1.2.0, < 2.0)
|
36
|
-
rspec-support (~> 3.
|
37
|
-
rspec-mocks (3.
|
56
|
+
rspec-support (~> 3.13.0)
|
57
|
+
rspec-mocks (3.13.5)
|
38
58
|
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
-
rspec-support (~> 3.
|
40
|
-
rspec-support (3.
|
41
|
-
|
42
|
-
|
59
|
+
rspec-support (~> 3.13.0)
|
60
|
+
rspec-support (3.13.4)
|
61
|
+
simplecov (0.21.2)
|
62
|
+
docile (~> 1.1)
|
63
|
+
simplecov-html (~> 0.11)
|
64
|
+
simplecov_json_formatter (~> 0.1)
|
65
|
+
simplecov-cobertura (2.1.0)
|
66
|
+
rexml
|
67
|
+
simplecov (~> 0.19)
|
68
|
+
simplecov-html (0.13.1)
|
69
|
+
simplecov_json_formatter (0.1.4)
|
70
|
+
snaky_hash (2.0.3)
|
71
|
+
hashie (>= 0.1.0, < 6)
|
72
|
+
version_gem (>= 1.1.8, < 3)
|
73
|
+
thor (1.3.2)
|
74
|
+
uri (1.0.3)
|
75
|
+
version_gem (1.1.8)
|
76
|
+
webrick (1.9.1)
|
43
77
|
|
44
78
|
PLATFORMS
|
45
79
|
ruby
|
46
80
|
|
47
81
|
DEPENDENCIES
|
48
|
-
|
49
|
-
|
82
|
+
csv (~> 3.0)
|
83
|
+
rake (~> 13.0)
|
84
|
+
rspec (~> 3.12)
|
85
|
+
simplecov (~> 0.21.0)
|
86
|
+
simplecov-cobertura
|
50
87
|
talknote_rb!
|
51
88
|
|
52
89
|
BUNDLED WITH
|
53
|
-
2.
|
90
|
+
2.3.21
|
data/README.md
CHANGED
@@ -1,8 +1,22 @@
|
|
1
|
+
[](https://badge.fury.io/rb/talknote_rb)
|
2
|
+
[](https://github.com/geeknees/talknote_rb/actions/workflows/main.yml)
|
3
|
+
[](https://codecov.io/gh/geeknees/talknote_rb)
|
4
|
+
[](https://codeclimate.com/github/geeknees/talknote_rb/maintainability)
|
5
|
+

|
6
|
+

|
7
|
+
|
1
8
|
# TalknoteRb
|
2
9
|
|
3
|
-
|
10
|
+
A Ruby client library for the Talknote API. This gem provides a simple interface to interact with Talknote's REST API, allowing you to access direct messages, groups, and other Talknote features programmatically.
|
11
|
+
|
12
|
+
## Features
|
4
13
|
|
5
|
-
|
14
|
+
- 🔐 OAuth 2.0 authentication flow
|
15
|
+
- 💬 Direct message management
|
16
|
+
- 👥 Group conversation access
|
17
|
+
- 📊 Unread message tracking
|
18
|
+
- 🖥️ Command-line interface
|
19
|
+
- 💎 Simple Ruby API client
|
6
20
|
|
7
21
|
## Installation
|
8
22
|
|
@@ -20,35 +34,359 @@ Or install it yourself as:
|
|
20
34
|
|
21
35
|
$ gem install talknote_rb
|
22
36
|
|
37
|
+
**Note:** The CSV export examples require the `csv` gem, which is included as a dependency. If you're using Ruby 3.0+, make sure to include it in your Gemfile:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
gem 'csv', '~> 3.0'
|
41
|
+
```
|
42
|
+
|
43
|
+
$ bundle install
|
44
|
+
|
45
|
+
Or install it yourself as:
|
46
|
+
|
47
|
+
$ gem install talknote_rb
|
48
|
+
|
49
|
+
## Quick Start
|
50
|
+
|
51
|
+
1. Get your client credentials from the [Talknote Developer Console](https://developer.talknote.com/doc/#intro)
|
52
|
+
2. Run the authentication setup:
|
53
|
+
```sh
|
54
|
+
bundle exec talknote init -i your_client_id -s your_client_secret
|
55
|
+
```
|
56
|
+
3. Start using the API:
|
57
|
+
```sh
|
58
|
+
bundle exec talknote dm
|
59
|
+
```
|
60
|
+
|
23
61
|
## Usage
|
24
62
|
|
25
|
-
###
|
63
|
+
### Authentication
|
26
64
|
|
27
|
-
|
28
|
-
https://developer.talknote.com/doc/#intro
|
65
|
+
Before using the API, you need to set up authentication. First, obtain your client credentials from the [Talknote Developer Console](https://developer.talknote.com/doc/#intro).
|
29
66
|
|
30
|
-
To
|
67
|
+
To initialize and authenticate, run:
|
31
68
|
|
32
69
|
```sh
|
33
|
-
bundle exec talknote init -i
|
70
|
+
bundle exec talknote init -i your_client_id -s your_client_secret
|
34
71
|
```
|
35
72
|
|
36
|
-
|
73
|
+
This command will:
|
74
|
+
1. Open your browser to the Talknote OAuth authorization page
|
75
|
+
2. Start a local server to handle the OAuth callback
|
76
|
+
3. Save your access token to `~/.config/talknote/token.json`
|
37
77
|
|
78
|
+
You can also specify custom host and port for the OAuth callback:
|
79
|
+
|
80
|
+
```sh
|
81
|
+
bundle exec talknote init -i your_client_id -s your_client_secret -h localhost -p 8080
|
82
|
+
```
|
83
|
+
|
84
|
+
### CLI Commands
|
85
|
+
|
86
|
+
#### Authentication
|
87
|
+
```sh
|
88
|
+
# Initialize authentication (run this first)
|
89
|
+
talknote init -i CLIENT_ID -s CLIENT_SECRET
|
90
|
+
|
91
|
+
# Optional: specify custom callback host/port
|
92
|
+
talknote init -i CLIENT_ID -s CLIENT_SECRET -h localhost -p 9000
|
93
|
+
```
|
94
|
+
|
95
|
+
#### Direct Messages
|
38
96
|
```sh
|
39
|
-
|
97
|
+
# List all DM conversations
|
98
|
+
talknote dm
|
99
|
+
|
100
|
+
# Show messages from a specific DM conversation
|
101
|
+
talknote dm-list DM_ID
|
102
|
+
|
103
|
+
# Show unread count for a DM conversation
|
104
|
+
talknote dm-unread DM_ID
|
105
|
+
|
106
|
+
# Send a message to a DM conversation
|
107
|
+
talknote dm-post DM_ID "Your message here"
|
108
|
+
```
|
109
|
+
|
110
|
+
#### Groups
|
111
|
+
```sh
|
112
|
+
# List all groups
|
113
|
+
talknote group
|
114
|
+
|
115
|
+
# Show messages from a specific group
|
116
|
+
talknote group-list GROUP_ID
|
117
|
+
|
118
|
+
# Show unread count for a group
|
119
|
+
talknote group-unread GROUP_ID
|
120
|
+
|
121
|
+
# Send a message to a group
|
122
|
+
talknote group-post GROUP_ID "Your message here"
|
123
|
+
```
|
124
|
+
|
125
|
+
## Library Usage
|
126
|
+
|
127
|
+
### Setup
|
128
|
+
|
129
|
+
```ruby
|
130
|
+
require 'talknote_rb'
|
131
|
+
|
132
|
+
# Client will automatically load token from ~/.config/talknote/token.json
|
133
|
+
client = Talknote::Client.new
|
134
|
+
```
|
135
|
+
|
136
|
+
### Direct Messages
|
137
|
+
|
138
|
+
```ruby
|
139
|
+
# Get all DM conversations
|
140
|
+
conversations = client.dm
|
141
|
+
|
142
|
+
# Get messages from a specific conversation
|
143
|
+
messages = client.dm_list('conversation_id')
|
144
|
+
|
145
|
+
# Send a message
|
146
|
+
result = client.dm_post('conversation_id', 'Hello!')
|
147
|
+
```
|
148
|
+
|
149
|
+
### Groups
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
# Get all groups
|
153
|
+
groups = client.group
|
154
|
+
|
155
|
+
# Get messages from a specific group
|
156
|
+
messages = client.group_list('group_id')
|
157
|
+
|
158
|
+
# Get unread count
|
159
|
+
unread_count = client.group_unread('group_id')
|
160
|
+
|
161
|
+
# Send a message to a group
|
162
|
+
result = client.group_post('group_id', 'Hello group!')
|
163
|
+
```
|
164
|
+
|
165
|
+
### CSV Export Examples
|
166
|
+
|
167
|
+
**⚠️ Note**: CSV export operations are high-load processes. For large datasets, they may take considerable time and could be interrupted by API rate limits or server load restrictions.
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
require 'talknote_rb'
|
171
|
+
require 'csv'
|
172
|
+
|
173
|
+
client = Talknote::Client.new
|
174
|
+
|
175
|
+
# Export DM conversations to CSV
|
176
|
+
CSV.open('dm_export.csv', 'w', encoding: 'UTF-8') do |csv|
|
177
|
+
csv << ['conversation_id', 'conversation_name', 'message_id', 'sender_name', 'message', 'created_at']
|
178
|
+
|
179
|
+
dm_response = client.dm
|
180
|
+
conversations = dm_response.dig('data', 'threads') || []
|
181
|
+
|
182
|
+
conversations.each do |conversation|
|
183
|
+
messages_response = client.dm_list(conversation['id'])
|
184
|
+
messages = messages_response.dig('data', 'messages') || []
|
185
|
+
|
186
|
+
messages.each do |message|
|
187
|
+
csv << [
|
188
|
+
conversation['id'],
|
189
|
+
conversation['name'],
|
190
|
+
message['id'],
|
191
|
+
message['sender_name'],
|
192
|
+
message['message'],
|
193
|
+
message['created_at']
|
194
|
+
]
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
# Export group conversations to CSV
|
200
|
+
CSV.open('group_export.csv', 'w', encoding: 'UTF-8') do |csv|
|
201
|
+
csv << ['group_id', 'group_name', 'message_id', 'sender_name', 'message', 'created_at']
|
202
|
+
|
203
|
+
groups_response = client.group
|
204
|
+
groups = groups_response.dig('data', 'groups') || []
|
205
|
+
|
206
|
+
groups.each do |group|
|
207
|
+
messages_response = client.group_list(group['id'])
|
208
|
+
messages = messages_response.dig('data', 'messages') || []
|
209
|
+
|
210
|
+
messages.each do |message|
|
211
|
+
csv << [
|
212
|
+
group['id'],
|
213
|
+
group['name'],
|
214
|
+
message['id'],
|
215
|
+
message['sender_name'],
|
216
|
+
message['message'],
|
217
|
+
message['created_at']
|
218
|
+
]
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
```
|
223
|
+
|
224
|
+
### Error Handling
|
225
|
+
|
226
|
+
```ruby
|
227
|
+
begin
|
228
|
+
result = client.dm
|
229
|
+
rescue Talknote::Error => e
|
230
|
+
puts "API Error: #{e.message}"
|
231
|
+
end
|
232
|
+
```
|
233
|
+
|
234
|
+
## Configuration
|
235
|
+
|
236
|
+
The authentication token is stored in `~/.config/talknote/token.json` after running the `init` command. The file contains the OAuth 2.0 access token and refresh token.
|
237
|
+
|
238
|
+
## API Endpoints
|
239
|
+
|
240
|
+
This gem supports the following Talknote API endpoints:
|
241
|
+
|
242
|
+
### Direct Messages
|
243
|
+
- `GET /api/v1/dm` - List DM conversations
|
244
|
+
- `GET /api/v1/dm/list/:id` - Get messages from a conversation
|
245
|
+
- `GET /api/v1/dm/unread/:id` - Get unread count
|
246
|
+
- `POST /api/v1/dm/post/:id` - Send a message
|
247
|
+
|
248
|
+
### Groups
|
249
|
+
- `GET /api/v1/group` - List groups
|
250
|
+
- `GET /api/v1/group/list/:id` - Get messages from a group
|
251
|
+
- `GET /api/v1/group/unread/:id` - Get unread count
|
252
|
+
- `POST /api/v1/group/post/:id` - Send a message to group
|
253
|
+
|
254
|
+
## Permissions
|
255
|
+
|
256
|
+
Make sure your Talknote application has the necessary scopes:
|
257
|
+
|
258
|
+
### DM Permissions
|
259
|
+
- `talknote.direct_message`
|
260
|
+
- `talknote.direct_message.read`
|
261
|
+
- `talknote.direct_message.write`
|
262
|
+
- `talknote.direct_message.unread`
|
263
|
+
- `talknote.direct_message.message.read`
|
264
|
+
- `talknote.direct_message.message.write`
|
265
|
+
|
266
|
+
### Group Permissions
|
267
|
+
- `talknote.group`
|
268
|
+
- `talknote.group.read`
|
269
|
+
- `talknote.group.write`
|
270
|
+
- `talknote.group.unread`
|
271
|
+
- `talknote.group.message.read`
|
272
|
+
- `talknote.group.message.write`
|
273
|
+
|
274
|
+
### Additional Permissions
|
275
|
+
- `talknote.user.read`
|
276
|
+
- `talknote.user.write`
|
277
|
+
- `talknote.timeline.read`
|
278
|
+
- `talknote.timeline.write`
|
279
|
+
- `talknote.timeline.message.read`
|
280
|
+
- `talknote.timeline.message.write`
|
281
|
+
- `talknote.timeline.unread`
|
282
|
+
- `talknote.allfeed.read`
|
283
|
+
- `talknote.allfeed.unread`
|
284
|
+
|
285
|
+
## Examples
|
286
|
+
|
287
|
+
The `examples/` directory contains practical usage examples:
|
288
|
+
|
289
|
+
- `examples/dm_example.rb` - Basic DM operations
|
290
|
+
- `examples/group_example.rb` - Basic group operations
|
291
|
+
- `examples/dm_csv_export_example.rb` - Export all DM conversations to CSV
|
292
|
+
- `examples/group_csv_export_example.rb` - Export all group conversations to CSV
|
293
|
+
- `examples/complete_csv_export_example.rb` - Export everything to organized CSV files
|
294
|
+
|
295
|
+
### Example: Export all conversations to CSV
|
296
|
+
|
297
|
+
```bash
|
298
|
+
# Export all DM conversations to CSV
|
299
|
+
ruby examples/dm_csv_export_example.rb
|
300
|
+
|
301
|
+
# Export all group conversations to CSV
|
302
|
+
ruby examples/group_csv_export_example.rb
|
303
|
+
|
304
|
+
# Export everything to organized directory
|
305
|
+
ruby examples/complete_csv_export_example.rb
|
306
|
+
```
|
307
|
+
|
308
|
+
**⚠️ Important Notes for CSV Export:**
|
309
|
+
- **High-load processing warning**: Export operations are resource-intensive processes that may be terminated by server-side load limits or API rate limits
|
310
|
+
- Large numbers of conversations may take significant time to export (potentially hours for thousands of conversations)
|
311
|
+
- The export process includes rate limiting delays (1 second between each conversation) to avoid API throttling
|
312
|
+
- **If the process stops unexpectedly**, wait some time before re-running to avoid further rate limiting
|
313
|
+
- Each API call is logged with progress indicators to track export status
|
314
|
+
- Export can be interrupted with Ctrl+C and resumed later
|
315
|
+
- For large exports, consider running the specific DM or Group exporters separately instead of the complete export
|
316
|
+
- Monitor your system resources during large exports as they may consume significant memory
|
317
|
+
|
318
|
+
The CSV export examples will create files with the following structure:
|
319
|
+
|
320
|
+
**DM CSV format:**
|
321
|
+
- `conversation_id`, `conversation_name`, `message_id`, `user_id`, `user_name`, `message`, `created_at`, `message_type`
|
322
|
+
|
323
|
+
**Group CSV format:**
|
324
|
+
- `group_id`, `group_name`, `message_id`, `user_id`, `user_name`, `message`, `created_at`, `message_type`, `unread_count`
|
325
|
+
|
326
|
+
### Example: Send a daily report to a group
|
327
|
+
|
328
|
+
```ruby
|
329
|
+
require 'talknote_rb'
|
330
|
+
|
331
|
+
client = Talknote::Client.new
|
332
|
+
|
333
|
+
# Get all groups and find the right one
|
334
|
+
groups = client.group
|
335
|
+
group = groups.dig('data', 'groups')&.find { |g| g['name'].include?('Daily Reports') }
|
336
|
+
|
337
|
+
if group
|
338
|
+
# Send daily report
|
339
|
+
report = "📊 Daily Report (#{Date.today})\n\n" \
|
340
|
+
"- Tasks completed: 15\n" \
|
341
|
+
"- Issues resolved: 3\n" \
|
342
|
+
"- New features deployed: 2"
|
343
|
+
|
344
|
+
client.group_post(group['id'], report)
|
345
|
+
puts "Daily report sent to #{group['name']}!"
|
346
|
+
else
|
347
|
+
puts "Daily Reports group not found"
|
348
|
+
end
|
349
|
+
```
|
350
|
+
|
351
|
+
### Example: Monitor unread messages
|
352
|
+
|
353
|
+
```ruby
|
354
|
+
require 'talknote_rb'
|
355
|
+
|
356
|
+
client = Talknote::Client.new
|
357
|
+
|
358
|
+
# Check unread DMs
|
359
|
+
dm_conversations = client.dm
|
360
|
+
dm_conversations.dig('data', 'threads')&.each do |dm|
|
361
|
+
unread = client.dm_unread(dm['id'])
|
362
|
+
unread_count = unread.dig('data', 'unread_count')
|
363
|
+
|
364
|
+
if unread_count && unread_count > 0
|
365
|
+
puts "📩 #{dm['title']}: #{unread_count} unread messages"
|
366
|
+
end
|
367
|
+
end
|
368
|
+
|
369
|
+
# Check unread group messages
|
370
|
+
groups = client.group
|
371
|
+
groups.dig('data', 'groups')&.each do |group|
|
372
|
+
unread = client.group_unread(group['id'])
|
373
|
+
unread_count = unread.dig('data', 'unread_count')
|
374
|
+
|
375
|
+
if unread_count && unread_count > 0
|
376
|
+
puts "👥 #{group['name']}: #{unread_count} unread messages"
|
377
|
+
end
|
378
|
+
end
|
40
379
|
```
|
41
380
|
|
42
381
|
## Development
|
43
382
|
|
44
383
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
45
384
|
|
46
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and
|
385
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
47
386
|
|
48
387
|
## Contributing
|
49
388
|
|
50
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/geeknees/talknote_rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/
|
51
|
-
|
389
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/geeknees/talknote_rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/geeknees/talknote_rb/blob/main/CODE_OF_CONDUCT.md).
|
52
390
|
|
53
391
|
## License
|
54
392
|
|
@@ -56,4 +394,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
56
394
|
|
57
395
|
## Code of Conduct
|
58
396
|
|
59
|
-
Everyone interacting in the TalknoteRb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
397
|
+
Everyone interacting in the TalknoteRb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/geeknees/talknote_rb/blob/main/CODE_OF_CONDUCT.md).
|