telegem 0.2.5 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc3dc81c673fa1128b108e02c3401f4bac483d7173759b4c901c3db625fa8dd8
4
- data.tar.gz: 4cb6de9fa5d9b8c5babbbd83ff86b5b7f6c0161628e74dbb7416ee5eeaa10e70
3
+ metadata.gz: 6264779d02976cf1d0e711273fdc15764dcb1d3edf93ef45420de14e633c25d0
4
+ data.tar.gz: ab19b23511dc6e11c6c62d02d5b342071a8e44f4d1ed380293bf1870f8b7da6d
5
5
  SHA512:
6
- metadata.gz: 32211bca88485aa5d19b41c8bc400b1af8b790de8ec4cf9761537a2f59de299e4ee6c5dca2de3e5561f58fe0280238c1452cff10429aa876d2fad2426556819d
7
- data.tar.gz: fef73c4f8d976614ec815cee3c230409bf471564f38a46acb5fc7093c80d2154186a621f68068098cc1072cdb144184c92a683be83e42107f7ea409ea3175b5e
6
+ metadata.gz: 4cdc42ae03dc43d53b6920d0200443a0eb0ac4e665acd0f5511779f280f772a7d349951dddd5c4e3ecf236a31bdba506fe335e45e8ee83c0457a4d45f45567b9
7
+ data.tar.gz: 68a606074e574aca0aef136b45e1ab2d8b2c36f47dbf33a0b01a161935a02b14144fcf5f5d434d9497efbd7ab6326f22ecca977ca42397c35d939bafbfbf78e0
data/.replit ADDED
@@ -0,0 +1,13 @@
1
+ run = "bundle exec ruby main.rb"
2
+ hidden = [".bundle"]
3
+ entrypoint = "main.rb"
4
+ modules = ["ruby-3.2"]
5
+
6
+ [nix]
7
+ channel = "stable-24_05"
8
+
9
+ [gitHubImport]
10
+ requiredFiles = [".replit", "replit.nix"]
11
+
12
+ [agent]
13
+ expertMode = true
data/Contributing.md ADDED
@@ -0,0 +1,553 @@
1
+ 🤝 Contributing to Telegem
2
+
3
+ Welcome! We're excited you want to contribute to Telegem. This guide will help you get started, whether you're fixing a bug, adding a feature, or improving documentation.
4
+
5
+ ---
6
+
7
+ 🎯 First Time Contributor?
8
+
9
+ Start here! We welcome contributions of all sizes:
10
+
11
+ · 🐛 Bug fixes - Found an issue? Help us fix it!
12
+ · ✨ New features - Have an idea? Let's build it!
13
+ · 📚 Documentation - Can something be clearer? Improve it!
14
+ · 🧪 Tests - Help us make Telegem more reliable
15
+ · 🌍 Examples - Share how you're using Telegem
16
+
17
+ No contribution is too small! Even fixing a typo is appreciated.
18
+
19
+ ---
20
+
21
+ 📋 Table of Contents
22
+
23
+ 1. Code of Conduct
24
+ 2. Getting Started
25
+ 3. Development Setup
26
+ 4. Project Structure
27
+ 5. Making Changes
28
+ 6. Pull Request Process
29
+ 7. Coding Standards
30
+ 8. Testing
31
+ 9. Documentation
32
+ 10. Community
33
+
34
+ ---
35
+
36
+ 📜 Code of Conduct
37
+
38
+ We are committed to providing a friendly, safe, and welcoming environment for all. By participating, you agree to:
39
+
40
+ · Be respectful and inclusive
41
+ · Give and receive constructive feedback gracefully
42
+ · Focus on what's best for the community
43
+ · Show empathy towards other community members
44
+
45
+ Harassment of any kind will not be tolerated. If you experience or witness unacceptable behavior, please contact the maintainers.
46
+
47
+ ---
48
+
49
+ 🚀 Getting Started
50
+
51
+ Find Something to Work On
52
+
53
+ Good First Issues:
54
+ Look for issues tagged with:
55
+
56
+ · good first issue - Perfect for newcomers
57
+ · help wanted - Need community help
58
+ · documentation - Docs need improvement
59
+
60
+ Want to suggest a feature?
61
+
62
+ 1. Check if it already exists in issues
63
+ 2. If not, open an issue to discuss first
64
+ 3. Get feedback before writing code
65
+
66
+ Communication
67
+
68
+ · Discuss first - For significant changes, open an issue to discuss
69
+ · Ask questions - Don't hesitate to ask for clarification
70
+ · Be patient - Maintainers are volunteers with limited time
71
+
72
+ ---
73
+
74
+ 🛠️ Development Setup
75
+
76
+ 1. Fork & Clone
77
+
78
+ ```bash
79
+ # Fork on GitLab
80
+ # Then clone your fork
81
+ git clone https://gitlab.com/YOUR_USERNAME/telegem.git
82
+ cd telegem
83
+ ```
84
+
85
+ 2. Install Dependencies
86
+
87
+ ```bash
88
+ # Install Ruby (3.0+ required)
89
+ ruby --version
90
+
91
+ # Install Bundler if needed
92
+ gem install bundler
93
+
94
+ # Install gem dependencies
95
+ bundle install
96
+ ```
97
+
98
+ 3. Set Up Your Environment
99
+
100
+ ```bash
101
+ # Create a test bot token
102
+ # Get one from @BotFather on Telegram
103
+ export TEST_BOT_TOKEN="your_test_token_here"
104
+
105
+ # Optional: Set up test Redis for session tests
106
+ export REDIS_URL="redis://localhost:6379"
107
+ ```
108
+
109
+ 4. Verify Setup
110
+
111
+ ```bash
112
+ # Run tests to ensure everything works
113
+ bundle exec rake spec
114
+
115
+ # Build the gem locally
116
+ gem build telegem.gemspec
117
+
118
+ # Test installation
119
+ gem install ./telegem-*.gem
120
+ ```
121
+
122
+ ---
123
+
124
+ 🏗️ Project Structure
125
+
126
+ ```
127
+ telegem/
128
+ ├── lib/
129
+ │ ├── telegem.rb # Main entry point
130
+ │ ├── api/ # Telegram API client
131
+ │ │ ├── client.rb
132
+ │ │ └── types.rb
133
+ │ ├── core/ # Core bot framework
134
+ │ │ ├── bot.rb
135
+ │ │ ├── context.rb
136
+ │ │ ├── composer.rb
137
+ │ │ └── scene.rb
138
+ │ ├── session/ # Session management
139
+ │ │ ├── middleware.rb
140
+ │ │ └── memory_store.rb
141
+ │ └── markup/ # Keyboard builders
142
+ │ └── keyboard.rb
143
+ ├── webhook/ # Webhook server
144
+ │ └── server.rb
145
+ ├── spec/ # Tests
146
+ │ ├── unit/
147
+ │ ├── integration/
148
+ │ └── spec_helper.rb
149
+ ├── examples/ # Example bots
150
+ │ ├── pizza_bot.rb
151
+ │ └── echo_bot.rb
152
+ ├── docs/ # Documentation
153
+ │ ├── How_to_use.md
154
+ │ ├── usage.md
155
+ │ ├── cookbook.md
156
+ │ └── API.md
157
+ ├── Gemfile
158
+ ├── telegem.gemspec
159
+ └── Rakefile
160
+ ```
161
+
162
+ ---
163
+
164
+ 🔧 Making Changes
165
+
166
+ 1. Create a Branch
167
+
168
+ ```bash
169
+ # Always work on a branch, never on main
170
+ git checkout -b feature/your-feature-name
171
+ # or
172
+ git checkout -b fix/issue-description
173
+ # or
174
+ git checkout -b docs/improve-readme
175
+ ```
176
+
177
+ 2. Make Your Changes
178
+
179
+ Follow our coding standards. Write tests for new functionality.
180
+
181
+ 3. Test Your Changes
182
+
183
+ ```bash
184
+ # Run all tests
185
+ bundle exec rake spec
186
+
187
+ # Run specific test file
188
+ bundle exec rspec spec/core/bot_spec.rb
189
+
190
+ # Run with coverage
191
+ bundle exec rspec --format progress --coverage
192
+ ```
193
+
194
+ 4. Update Documentation
195
+
196
+ · Update relevant documentation
197
+ · Add examples if adding new features
198
+ · Update API reference if changing public API
199
+
200
+ 5. Commit Your Changes
201
+
202
+ ```bash
203
+ # Use descriptive commit messages
204
+ git commit -m "Add feature: description of change
205
+
206
+ - Detail 1 about the change
207
+ - Detail 2 about the change
208
+ - Fixes #123 (if applicable)"
209
+ ```
210
+
211
+ Commit Message Guidelines:
212
+
213
+ · First line: Summary (50 chars or less)
214
+ · Blank line
215
+ · Detailed description (wrap at 72 chars)
216
+ · Reference issues: Fixes #123, Closes #456
217
+
218
+ ---
219
+
220
+ 🔄 Pull Request Process
221
+
222
+ 1. Push Your Branch
223
+
224
+ ```bash
225
+ git push origin your-branch-name
226
+ ```
227
+
228
+ 2. Create a Merge Request
229
+
230
+ On GitLab:
231
+
232
+ 1. Click "Merge Requests" → "New Merge Request"
233
+ 2. Select your branch
234
+ 3. Fill in the template
235
+ 4. Request review from maintainers
236
+
237
+ 3. Merge Request Template
238
+
239
+ ```markdown
240
+ ## Description
241
+ <!-- What does this PR do? Why is it needed? -->
242
+
243
+ ## Type of Change
244
+ - [ ] Bug fix (non-breaking change)
245
+ - [ ] New feature (non-breaking change)
246
+ - [ ] Breaking change (fix/feature causing existing functionality to break)
247
+ - [ ] Documentation update
248
+ - [ ] Example/test addition
249
+
250
+ ## Testing
251
+ - [ ] Added tests for new functionality
252
+ - [ ] Updated existing tests
253
+ - [ ] All tests pass locally
254
+ - [ ] Manual testing completed
255
+
256
+ ## Documentation
257
+ - [ ] Updated API documentation
258
+ - [ ] Updated usage examples
259
+ - [ ] Updated README if needed
260
+
261
+ ## Checklist
262
+ - [ ] Code follows project standards
263
+ - [ ] Self-reviewed my own code
264
+ - [ ] Added comments for complex logic
265
+ - [ ] No new warnings generated
266
+ ```
267
+
268
+ 4. Review Process
269
+
270
+ · Maintainers will review within a few days
271
+ · Address any feedback requested
272
+ · Tests must pass
273
+ · Keep discussions constructive
274
+
275
+ 5. After Approval
276
+
277
+ · Maintainer will merge your PR
278
+ · Your contribution will be in the next release!
279
+ · You'll be added to contributors list
280
+
281
+ ---
282
+
283
+ 📏 Coding Standards
284
+
285
+ Ruby Style
286
+
287
+ Follow Ruby Style Guide with these specifics:
288
+
289
+ ```ruby
290
+ # Good
291
+ def send_message(text, parse_mode: nil)
292
+ # ...
293
+ end
294
+
295
+ # Bad
296
+ def sendMessage(text, parse_mode = nil)
297
+ # ...
298
+ end
299
+ ```
300
+
301
+ Naming
302
+
303
+ · Modules/Classes: CamelCase
304
+ · Methods/Variables: snake_case
305
+ · Constants: SCREAMING_SNAKE_CASE
306
+
307
+ Async Patterns
308
+
309
+ ```ruby
310
+ # Use Async.do for I/O operations
311
+ def fetch_data
312
+ Async do
313
+ await api.call('method', params)
314
+ end
315
+ end
316
+
317
+ # Handle errors properly
318
+ Async do
319
+ begin
320
+ await risky_operation
321
+ rescue => e
322
+ logger.error("Failed: #{e.message}")
323
+ raise
324
+ end
325
+ end
326
+ ```
327
+
328
+ Documentation
329
+
330
+ ```ruby
331
+ # Document public methods
332
+ # @param [String] text The message to send
333
+ # @option options [String] :parse_mode "HTML", "Markdown", or "MarkdownV2"
334
+ # @return [Async::Task] Async task that sends the message
335
+ def reply(text, **options)
336
+ Async do
337
+ # ...
338
+ end
339
+ end
340
+ ```
341
+
342
+ ---
343
+
344
+ 🧪 Testing
345
+
346
+ Writing Tests
347
+
348
+ ```ruby
349
+ # spec/core/bot_spec.rb
350
+ RSpec.describe Telegem::Core::Bot do
351
+ describe "#command" do
352
+ it "registers a command handler" do
353
+ bot = described_class.new("test_token")
354
+ bot.command('test') { |ctx| ctx.reply("Working") }
355
+
356
+ expect(bot.handlers[:message].size).to eq(1)
357
+ end
358
+ end
359
+ end
360
+ ```
361
+
362
+ Test Structure
363
+
364
+ · Unit tests - Test individual components
365
+ · Integration tests - Test component interactions
366
+ · Async tests - Test async behavior properly
367
+
368
+ Running Tests
369
+
370
+ ```bash
371
+ # All tests
372
+ bundle exec rake spec
373
+
374
+ # Specific test type
375
+ bundle exec rspec spec/unit
376
+ bundle exec rspec spec/integration
377
+
378
+ # With verbose output
379
+ bundle exec rspec --format documentation
380
+
381
+ # Watch mode (development)
382
+ bundle exec guard
383
+ ```
384
+
385
+ ---
386
+
387
+ 📚 Documentation
388
+
389
+ Documentation Types
390
+
391
+ 1. API Reference (docs/API.md) - Complete method documentation
392
+ 2. Usage Guides (docs/usage.md) - Advanced patterns
393
+ 3. Tutorials (docs/How_to_use.md) - Beginner guides
394
+ 4. Cookbook (docs/cookbook.md) - Copy-paste recipes
395
+ 5. Examples (examples/) - Working bot examples
396
+
397
+ Writing Documentation
398
+
399
+ · Use clear, simple language
400
+ · Include code examples
401
+ · Show both simple and advanced usage
402
+ · Update when changing functionality
403
+
404
+ Building Examples
405
+
406
+ ```bash
407
+ # Test your examples work
408
+ cd examples
409
+ ruby pizza_bot.rb --test-mode
410
+ ```
411
+
412
+ ---
413
+
414
+ 🌍 Community
415
+
416
+ Getting Help
417
+
418
+ · Issues - Bug reports and feature requests
419
+ · Merge Requests - Code contributions
420
+ · Discussions - Questions and ideas
421
+ · Chat - Telegram group for quick questions
422
+
423
+ Recognition
424
+
425
+ All contributors are recognized in:
426
+
427
+ · README.md contributors section
428
+ · Release notes
429
+ · Project documentation
430
+
431
+ Becoming a Maintainer
432
+
433
+ Consistent contributors may be invited to become maintainers. We look for:
434
+
435
+ · Quality contributions over time
436
+ · Helpful community participation
437
+ · Understanding of project goals
438
+ · Willingness to review others' work
439
+
440
+ ---
441
+
442
+ 🐛 Reporting Bugs
443
+
444
+ Before Reporting
445
+
446
+ 1. Check if issue already exists
447
+ 2. Update to latest version
448
+ 3. Try to reproduce with minimal code
449
+
450
+ Bug Report Template
451
+
452
+ ```markdown
453
+ ## Description
454
+ <!-- Clear description of the bug -->
455
+
456
+ ## Steps to Reproduce
457
+ 1.
458
+ 2.
459
+ 3.
460
+
461
+ ## Expected Behavior
462
+ <!-- What should happen -->
463
+
464
+ ## Actual Behavior
465
+ <!-- What actually happens -->
466
+
467
+ ## Environment
468
+ - Telegem version:
469
+ - Ruby version:
470
+ - OS:
471
+ - Telegram Bot API token: (use test token)
472
+
473
+ ## Code Example
474
+ ```ruby
475
+ # Minimal code to reproduce
476
+ ```
477
+
478
+ Logs/Errors
479
+
480
+ <!-- Any error messages or logs -->```
481
+
482
+ ---
483
+
484
+ ## 💡 Suggesting Features
485
+
486
+ ### Feature Request Template
487
+ ```markdown
488
+ ## Problem
489
+ <!-- What problem does this solve? -->
490
+
491
+ ## Solution
492
+ <!-- Describe your proposed solution -->
493
+
494
+ ## Alternatives
495
+ <!-- Any alternative solutions considered -->
496
+
497
+ ## Use Cases
498
+ <!-- Who needs this and how will they use it? -->
499
+
500
+ ## Implementation Ideas
501
+ <!-- Technical implementation thoughts -->
502
+ ```
503
+
504
+ ---
505
+
506
+ 🏷️ Release Process
507
+
508
+ Versioning
509
+
510
+ We follow Semantic Versioning:
511
+
512
+ · MAJOR - Breaking changes
513
+ · MINOR - New features (backwards compatible)
514
+ · PATCH - Bug fixes (backwards compatible)
515
+
516
+ Release Checklist
517
+
518
+ · All tests pass
519
+ · Documentation updated
520
+ · Examples tested
521
+ · Changelog updated
522
+ · Version bumped in lib/telegem.rb
523
+ · Git tag created
524
+ · Gem pushed to RubyGems
525
+ · Release notes published
526
+
527
+ ---
528
+
529
+ 🙏 Acknowledgments
530
+
531
+ Thank you for contributing! Your work helps make Telegem better for everyone.
532
+
533
+ Quick Start Recap
534
+
535
+ 1. Fork & clone
536
+ 2. Create branch
537
+ 3. Make changes
538
+ 4. Write tests
539
+ 5. Update docs
540
+ 6. Submit MR
541
+
542
+ Remember: Every contribution matters. Whether you're fixing a typo or adding a major feature, you're helping build something awesome!
543
+
544
+ ---
545
+
546
+ ❓ Still Have Questions?
547
+
548
+ · Read the documentation
549
+ · Check existing issues
550
+ · Ask in discussions
551
+ · Join our Telegram group
552
+
553
+ Happy coding! 🎉
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'rake', '~> 13.0'
7
+ gem 'rspec', '~> 3.0'
8
+ gem 'pry', '~> 0.14.0'
9
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,11 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+
5
+ PLATFORMS
6
+ x86_64-linux
7
+
8
+ DEPENDENCIES
9
+
10
+ BUNDLED WITH
11
+ 2.4.10
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 šłîçk phäñtøm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.