summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/example/ruby
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-11-30 17:48:47 +0300
committerGeorge Hazan <ghazan@miranda.im>2022-11-30 17:48:47 +0300
commit0ece30dc7c0e34b4c5911969b8fa99c33c6d023c (patch)
tree671325d3fec09b999411e4e3ab84ef8259261818 /protocols/Telegram/tdlib/td/example/ruby
parent46c53ffc6809c67e4607e99951a2846c382b63b2 (diff)
Telegram: update for TDLIB
Diffstat (limited to 'protocols/Telegram/tdlib/td/example/ruby')
-rw-r--r--protocols/Telegram/tdlib/td/example/ruby/Gemfile3
-rw-r--r--protocols/Telegram/tdlib/td/example/ruby/Gemfile.lock17
-rw-r--r--protocols/Telegram/tdlib/td/example/ruby/example.rb61
3 files changed, 0 insertions, 81 deletions
diff --git a/protocols/Telegram/tdlib/td/example/ruby/Gemfile b/protocols/Telegram/tdlib/td/example/ruby/Gemfile
deleted file mode 100644
index 3a38ffc0a3..0000000000
--- a/protocols/Telegram/tdlib/td/example/ruby/Gemfile
+++ /dev/null
@@ -1,3 +0,0 @@
-source 'https://rubygems.org'
-
-gem 'tdlib-ruby'
diff --git a/protocols/Telegram/tdlib/td/example/ruby/Gemfile.lock b/protocols/Telegram/tdlib/td/example/ruby/Gemfile.lock
deleted file mode 100644
index 22954eddfb..0000000000
--- a/protocols/Telegram/tdlib/td/example/ruby/Gemfile.lock
+++ /dev/null
@@ -1,17 +0,0 @@
-GEM
- remote: https://rubygems.org/
- specs:
- concurrent-ruby (1.0.5)
- dry-configurable (0.7.0)
- concurrent-ruby (~> 1.0)
- tdlib-ruby (0.2.0)
- dry-configurable (~> 0.7)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- tdlib-ruby
-
-BUNDLED WITH
- 1.16.1
diff --git a/protocols/Telegram/tdlib/td/example/ruby/example.rb b/protocols/Telegram/tdlib/td/example/ruby/example.rb
deleted file mode 100644
index 4b29dfd53a..0000000000
--- a/protocols/Telegram/tdlib/td/example/ruby/example.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-require 'tdlib-ruby'
-
-TD.configure do |config|
- config.lib_path = 'path/to/dir_containing_lobtdjson'
-
- # You should obtain your own api_id and api_hash from https://my.telegram.org/apps
- config.client.api_id = 12345
- config.client.api_hash = '1234567890abcdefghigklmnopqrstuv'
-end
-
-TD::Api.set_log_verbosity_level(1)
-
-client = TD::Client.new
-
-begin
- state = nil
-
- client.on('updateAuthorizationState') do |update|
- next unless update.dig('authorization_state', '@type') == 'authorizationStateWaitPhoneNumber'
- state = :wait_phone
- end
-
- client.on('updateAuthorizationState') do |update|
- next unless update.dig('authorization_state', '@type') == 'authorizationStateWaitCode'
- state = :wait_code
- end
-
- client.on('updateAuthorizationState') do |update|
- next unless update.dig('authorization_state', '@type') == 'authorizationStateReady'
- state = :ready
- end
-
- loop do
- case state
- when :wait_phone
- p 'Please, enter your phone number:'
- phone = STDIN.gets.strip
- params = {
- '@type' => 'setAuthenticationPhoneNumber',
- 'phone_number' => phone
- }
- client.broadcast_and_receive(params)
- when :wait_code
- p 'Please, enter code from SMS:'
- code = STDIN.gets.strip
- params = {
- '@type' => 'checkAuthenticationCode',
- 'code' => code
- }
- client.broadcast_and_receive(params)
- when :ready
- @me = client.broadcast_and_receive('@type' => 'getMe')
- break
- end
- end
-
-ensure
- client.close
-end
-
-p @me