telegram_bot_engine 0.1.0 → 0.2.1
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c3d331110ead0fd92e4fee373b4fa5429479116cd9e518a367aea45cdda067df
|
|
4
|
+
data.tar.gz: cb35bb73052d715549a8146cde0ab25d5d990f7b20840ae28859633ab6265609
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7b02b7c338ee4dbd4db036e32e2f77fb909aabe9a64e7ed19e9bb2a82b87ee4c8f3dd321e79772aa52d99dc637f986c02d3d7273d2279be1f6be69e22c638e30
|
|
7
|
+
data.tar.gz: d0d8c3bc21441fe79c1e7dd14cfd2ca9a452e2733f6fc0d08b478fadb9322a74968b3d0c0f974189bd20803339020409489f8ae960b70bf93b0381923cde285c
|
data/README.md
CHANGED
|
@@ -89,8 +89,34 @@ end
|
|
|
89
89
|
|
|
90
90
|
### Set webhook
|
|
91
91
|
|
|
92
|
+
These rake tasks come from the `telegram-bot` gem:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# Register your app's URL with Telegram so it sends updates to your server
|
|
96
|
+
bin/rails telegram:bot:set_webhook RAILS_ENV=production
|
|
97
|
+
|
|
98
|
+
# Remove the webhook (e.g. before switching to polling)
|
|
99
|
+
bin/rails telegram:bot:delete_webhook
|
|
100
|
+
|
|
101
|
+
# Run a local poller for development (no webhook needed)
|
|
102
|
+
bin/rails telegram:bot:poller
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
The webhook URL is derived from your Rails routes (`telegram_webhook` route helper). Make sure your production server is accessible via HTTPS before setting the webhook.
|
|
106
|
+
|
|
107
|
+
For local development with ngrok, configure `default_url_options` in `config/environments/development.rb`:
|
|
108
|
+
|
|
109
|
+
```ruby
|
|
110
|
+
if ENV['HOST'].present?
|
|
111
|
+
routes.default_url_options[:host] = ENV.fetch("HOST", "localhost:3000")
|
|
112
|
+
routes.default_url_options[:protocol] = ENV.fetch("PROTOCOL", "https")
|
|
113
|
+
end
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Then run:
|
|
117
|
+
|
|
92
118
|
```bash
|
|
93
|
-
bin/rails telegram:bot:set_webhook
|
|
119
|
+
HOST=your-subdomain.ngrok-free.app bin/rails telegram:bot:set_webhook
|
|
94
120
|
```
|
|
95
121
|
|
|
96
122
|
## Usage
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
class CreateTelegramBotEngineSubscriptions < ActiveRecord::Migration[7.0]
|
|
4
|
+
def adapter_type
|
|
5
|
+
ActiveRecord::Base.connection.adapter_name.downcase.include?('postgresql') ? :jsonb : :json
|
|
6
|
+
end
|
|
7
|
+
|
|
4
8
|
def change
|
|
5
9
|
create_table :telegram_bot_engine_subscriptions do |t|
|
|
6
10
|
t.bigint :chat_id, null: false
|
|
@@ -8,7 +12,7 @@ class CreateTelegramBotEngineSubscriptions < ActiveRecord::Migration[7.0]
|
|
|
8
12
|
t.string :username
|
|
9
13
|
t.string :first_name
|
|
10
14
|
t.boolean :active, default: true
|
|
11
|
-
t.
|
|
15
|
+
t.column :metadata, adapter_type, default: {}
|
|
12
16
|
|
|
13
17
|
t.timestamps
|
|
14
18
|
end
|
|
@@ -7,5 +7,13 @@ module TelegramBotEngine
|
|
|
7
7
|
config.generators do |g|
|
|
8
8
|
g.test_framework :rspec
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
initializer "telegram_bot_engine.middleware" do |app|
|
|
12
|
+
if app.config.api_only
|
|
13
|
+
app.middleware.use ActionDispatch::Cookies
|
|
14
|
+
app.middleware.use ActionDispatch::Session::CookieStore
|
|
15
|
+
app.middleware.use ActionDispatch::Flash
|
|
16
|
+
end
|
|
17
|
+
end
|
|
10
18
|
end
|
|
11
19
|
end
|