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: 6328e735752f40d861612353af4506231c527650bb1af06eb41e555266a57d6e
4
- data.tar.gz: bbf440a730524d681420d2c65f9835a7c13e5250042c5d5f32d7ca1797a9803c
3
+ metadata.gz: c3d331110ead0fd92e4fee373b4fa5429479116cd9e518a367aea45cdda067df
4
+ data.tar.gz: cb35bb73052d715549a8146cde0ab25d5d990f7b20840ae28859633ab6265609
5
5
  SHA512:
6
- metadata.gz: e3addc87463489304620537db0c299cce2825e5a82239eafbc1a0fffad91bd806f8453893fb79ed79cb133501e8b07be035de481380cb0d94fcfa18f28d8a405
7
- data.tar.gz: 8aa8eb624f5d29d562186d9888c3027886f65f11417e6f34a480bd5dca607a446ff4ea224ecb56c18238b179946ad9dcba2f863d262c690104db0c02e50ba2cd
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.jsonb :metadata, default: {}
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
@@ -5,6 +5,7 @@ module TelegramBotEngine
5
5
  extend ActiveSupport::Concern
6
6
 
7
7
  included do
8
+ skip_forgery_protection if respond_to?(:skip_forgery_protection)
8
9
  before_action :authorize_user!
9
10
  end
10
11
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TelegramBotEngine
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telegram_bot_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TelegramBotEngine Contributors