telebot 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dac629c038645d92ad08c056c49abdb6af84445b
4
- data.tar.gz: a5ce13f553e827434d788b749cb4ef9ba71cc9ea
3
+ metadata.gz: e28da70cafd397b9d2d05fe37a11a974d4f0c46e
4
+ data.tar.gz: d30763a3ee77fb04b54033b1d12f5e0760aa458a
5
5
  SHA512:
6
- metadata.gz: d7ba8b3de11ada50ff7c0484cc4b305ef972ca24ea3994f578f43eaa65f00b45ec9f8ee00270ab3ca0d85de839d7f5cdc29b09cfcd3684dfb32b0752044a92f7
7
- data.tar.gz: 60863c58f0cc56969e03ae3edbce2a4e35da5b3682d87a4d6ed363f671d8da42d75f896eec4e341d95f284118bec3e692a5e891f41d018cdd0c0713084f7c2e6
6
+ metadata.gz: 7f7f22ac5c199fbd418ea03dd039bac63b535e3175a6b16dee521532e78e7284fabad584374d42d1f3c8f4e6f6b30fac71d0fed07536df5c10a35075538fcfdc
7
+ data.tar.gz: 2bc252b6e887731afc2ae91ee477d2f1a8d8537a9cc33c5349be40132e438a34c81cc7738bff6c76374e8adf4e8f438f4f688eae2750792d96c5900309580c4c
@@ -13,7 +13,10 @@ module Telebot
13
13
 
14
14
  def run(&block)
15
15
  loop do
16
- updates = @client.get_updates(offset: @processed_update_ids.last)
16
+ # Note: https://core.telegram.org/bots/api#getupdates
17
+ # To mark an update as confirmed need to use offset+1
18
+ offset = @processed_update_ids.last && @processed_update_ids.last + 1
19
+ updates = @client.get_updates(offset: offset)
17
20
 
18
21
  updates.each do |update|
19
22
  next if @processed_update_ids.include?(update.update_id)
@@ -1,3 +1,3 @@
1
1
  module Telebot
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telebot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Potapov Sergey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-26 00:00:00.000000000 Z
11
+ date: 2015-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -101,45 +101,26 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
- - ".gitignore"
105
- - ".rspec"
106
- - ".ruby-gemset"
107
- - ".ruby-version"
108
- - ".travis.yml"
109
- - CODE_OF_CONDUCT.md
110
- - Gemfile
111
- - Guardfile
112
- - LICENSE.txt
113
- - README.md
114
- - Rakefile
115
- - bin/console
116
- - bin/setup
117
- - examples/demo.rb
118
- - examples/fixtures/bender_pic.jpg
119
- - examples/fixtures/saluton_amiko.ogg
120
- - examples/fixtures/zamenhof_sticker.webp
121
- - lib/telebot.rb
122
- - lib/telebot/bot.rb
123
- - lib/telebot/client.rb
124
- - lib/telebot/errors.rb
125
- - lib/telebot/objects/audio.rb
126
- - lib/telebot/objects/contact.rb
127
- - lib/telebot/objects/document.rb
128
- - lib/telebot/objects/group_chat.rb
129
- - lib/telebot/objects/input_file.rb
130
- - lib/telebot/objects/location.rb
131
- - lib/telebot/objects/message.rb
132
- - lib/telebot/objects/photo_size.rb
133
- - lib/telebot/objects/reply_keyboard_markup.rb
134
- - lib/telebot/objects/sticker.rb
135
- - lib/telebot/objects/update.rb
136
- - lib/telebot/objects/user.rb
137
- - lib/telebot/objects/user_profile_photos.rb
138
- - lib/telebot/objects/video.rb
139
- - lib/telebot/response.rb
140
- - lib/telebot/version.rb
141
- - saluton_amiko.wav
142
- - telebot.gemspec
104
+ - "./lib/telebot.rb"
105
+ - "./lib/telebot/bot.rb"
106
+ - "./lib/telebot/client.rb"
107
+ - "./lib/telebot/errors.rb"
108
+ - "./lib/telebot/objects/audio.rb"
109
+ - "./lib/telebot/objects/contact.rb"
110
+ - "./lib/telebot/objects/document.rb"
111
+ - "./lib/telebot/objects/group_chat.rb"
112
+ - "./lib/telebot/objects/input_file.rb"
113
+ - "./lib/telebot/objects/location.rb"
114
+ - "./lib/telebot/objects/message.rb"
115
+ - "./lib/telebot/objects/photo_size.rb"
116
+ - "./lib/telebot/objects/reply_keyboard_markup.rb"
117
+ - "./lib/telebot/objects/sticker.rb"
118
+ - "./lib/telebot/objects/update.rb"
119
+ - "./lib/telebot/objects/user.rb"
120
+ - "./lib/telebot/objects/user_profile_photos.rb"
121
+ - "./lib/telebot/objects/video.rb"
122
+ - "./lib/telebot/response.rb"
123
+ - "./lib/telebot/version.rb"
143
124
  homepage: https://github.com/greyblake/telebot
144
125
  licenses:
145
126
  - MIT
data/.gitignore DELETED
@@ -1,15 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
-
11
- # To use benefits of vim-rails plugin
12
- /config/environment.rb
13
-
14
- # Do not public token of the demo bot
15
- examples/DEMO_TOKEN
data/.rspec DELETED
@@ -1,2 +0,0 @@
1
- --format documentation
2
- --color
@@ -1 +0,0 @@
1
- telebot
@@ -1 +0,0 @@
1
- 2.1.5
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.1.5
4
- before_install: gem install bundler -v 1.10.4
@@ -1,13 +0,0 @@
1
- # Contributor Code of Conduct
2
-
3
- As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
-
5
- We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
-
7
- Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
-
9
- Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
-
11
- Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
-
13
- This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile DELETED
@@ -1,12 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in telebot.gemspec
4
- gemspec
5
-
6
-
7
- group :development, :test do
8
- gem 'pry'
9
- gem 'guard'
10
- gem 'guard-rspec'
11
- gem 'libnotify'
12
- end
data/Guardfile DELETED
@@ -1,43 +0,0 @@
1
- # A sample Guardfile
2
- # More info at https://github.com/guard/guard#readme
3
-
4
- ## Uncomment and set this to only include directories you want to watch
5
- # directories %w(app lib config test spec features) \
6
- # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
-
8
- ## Note: if you are using the `directories` clause above and you are not
9
- ## watching the project directory ('.'), then you will want to move
10
- ## the Guardfile to a watched dir and symlink it back, e.g.
11
- #
12
- # $ mkdir config
13
- # $ mv Guardfile config/
14
- # $ ln -s config/Guardfile .
15
- #
16
- # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
-
18
- # Note: The cmd option is now required due to the increasing number of ways
19
- # rspec may be run, below are examples of the most common uses.
20
- # * bundler: 'bundle exec rspec'
21
- # * bundler binstubs: 'bin/rspec'
22
- # * spring: 'bin/rspec' (This will use spring if running and you have
23
- # installed the spring binstubs per the docs)
24
- # * zeus: 'zeus rspec' (requires the server to be started separately)
25
- # * 'just' rspec: 'rspec'
26
-
27
- guard :rspec, cmd: "bundle exec rspec" do
28
- require "guard/rspec/dsl"
29
- dsl = Guard::RSpec::Dsl.new(self)
30
-
31
- # RSpec files
32
- rspec = dsl.rspec
33
- watch(rspec.spec_helper) { rspec.spec_dir }
34
- watch(rspec.spec_support) { rspec.spec_dir }
35
- watch(rspec.spec_files)
36
-
37
- # Ruby files
38
- ruby = dsl.ruby
39
- dsl.watch_spec_files_for(ruby.lib_files)
40
-
41
- end
42
-
43
- notification :libnotify, timeout: 1, transient: true, append: true, urgency: :critical
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Potapov Sergey
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
13
- all 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
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,73 +0,0 @@
1
- # Telebot
2
-
3
- Ruby client for [Telegram's Bot API](https://core.telegram.org/bots).
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'telebot'
11
- ```
12
-
13
- Run
14
-
15
- ```
16
- $ gem install telebot
17
- ```
18
-
19
- ## Usage
20
-
21
- Minimal example, that repeats a message, would look like this:
22
-
23
- ```ruby
24
- bot = Telebot::Bot.new(TOKEN)
25
-
26
- bot.run do |client, message|
27
- reply = "You've said: #{message.text}"
28
- client.send_message(chat_id: message.chat.id, text: reply)
29
- end
30
- ```
31
-
32
- Please check out full featured example as well: [demo.rb](https://github.com/greyblake/telebot/blob/master/examples/demo.rb).
33
-
34
-
35
- ### Using pure client
36
-
37
- ```ruby
38
- client = Telebot::Client.new(TOKEN)
39
-
40
- # Perform getMe call
41
- client.get_me
42
- # =>
43
- # #<Telebot::User:0x0000000111f688
44
- # @first_name="Telebot Demo",
45
- # @id=97445105,
46
- # @last_name=nil,
47
- # @username="demoTelebot">
48
-
49
- # Send message to chat with id=12345
50
- client.send_message(chat_id: 12345, text: "Hello there!")
51
- ```
52
- The client supports all [Telegram's Bot API methods](https://core.telegram.org/bots/api#available-methods).
53
-
54
- For more information check out [client.rb](https://github.com/greyblake/telebot/blob/master/lib/telebot/client.rb)
55
- and [demo.rb](https://github.com/greyblake/telebot/blob/master/examples/demo.rb).
56
-
57
-
58
- ## Running demo
59
-
60
- Clone the repo and run demo example to see how you can use [Telegram's Bot API](https://core.telegram.org/bots).
61
-
62
- ```ruby
63
- git clone /github.com/greyblake/telebot
64
- cd telebot
65
- bundle install
66
-
67
- TOKEN=<YOUR_TOKEN> ruby ./examples/demo.rb
68
- ```
69
-
70
- ## License
71
-
72
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
73
-
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "telebot"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
4
-
5
- require 'telebot'
6
- require 'pp'
7
-
8
- TOKEN_FILE = File.expand_path("../DEMO_TOKEN", __FILE__)
9
-
10
- def fixture(file_name)
11
- File.expand_path("../fixtures/#{file_name}", __FILE__)
12
- end
13
-
14
- token =
15
- if File.exist?(TOKEN_FILE)
16
- File.read(TOKEN_FILE).strip
17
- elsif ENV['TOKEN']
18
- ENV['TOKEN']
19
- else
20
- abort "Please set token as TOKEN env variable"
21
- end
22
-
23
- bot = Telebot::Bot.new(token)
24
-
25
- bot.run do |client, message|
26
- case message.text
27
- when /get_me/
28
- user = client.get_me
29
- msg = "ID: #{user.id}\n"
30
- msg << "First name: #{user.first_name}\n"
31
- msg << "Last name: #{user.last_name}\n"
32
- msg << "Username: #{user.username}"
33
- client.send_message(chat_id: message.chat.id, text: msg)
34
-
35
- when /send_message/
36
- client.send_message(chat_id: message.chat.id, text: "Hello, man! What's going on?")
37
-
38
- when /forward_message/
39
- client.forward_message(chat_id: message.chat.id, from_chat_id: message.chat.id, message_id: message.message_id)
40
-
41
- when /send_photo/
42
- file = Telebot::InputFile.new(fixture("bender_pic.jpg"), 'image/jpeg')
43
- client.send_photo(chat_id: message.chat.id, photo: file)
44
-
45
- when /send_audio/
46
- client.send_message(chat_id: message.chat.id, text: "Let me say 'Hi' in Esperanto.")
47
- file = Telebot::InputFile.new(fixture("saluton_amiko.ogg"))
48
- client.send_audio(chat_id: message.chat.id, audio: file)
49
-
50
- when /send_document/
51
- file = Telebot::InputFile.new(__FILE__)
52
- client.send_document(chat_id: message.chat.id, document: file)
53
-
54
- when /send_sticker/
55
- file = Telebot::InputFile.new(fixture("zamenhof_sticker.webp"))
56
- client.send_sticker(chat_id: message.chat.id, sticker: file)
57
-
58
- when /send_video/
59
- file_id = "BAADAgADOQADqwcsBcskdD5ZfXZyAg"
60
- client.send_video(chat_id: message.chat.id, video: file_id)
61
-
62
- when /send_location/
63
- client.send_location(chat_id: message.chat.id, latitude: 53.131684, longitude: 23.169556)
64
-
65
- when /send_chat_action/
66
- client.send_message(chat_id: message.chat.id, text: "Check my status, I am typing")
67
- client.send_chat_action(chat_id: message.chat.id, action: :typing)
68
- sleep 3
69
- client.send_message(chat_id: message.chat.id, text: "Done")
70
-
71
- when /get_user_profile_photos/
72
- photos = client.get_user_profile_photos(user_id: message.from.id)
73
- if photos.total_count > 0
74
- client.send_message(chat_id: message.chat.id, text: "Look at yourself!")
75
- photo = photos.photos.first
76
- photo_size = photo.first
77
- client.send_photo(chat_id: message.chat.id, photo: photo_size.file_id)
78
- else
79
- client.send_message(chat_id: message.chat.id, text: "Your profile has no photos")
80
- end
81
-
82
- else
83
- markup = Telebot::ReplyKeyboardMarkup.new(
84
- keyboard: [
85
- [ "get_me", "send_message", "forward_message" ],
86
- [ "send_photo", "send_audio", "send_document" ],
87
- [ "send_sticker", "send_video", "send_location"],
88
- [ "send_chat_action", "get_user_profile_photos"]
89
- ]
90
- )
91
-
92
- client.send_message(chat_id: message.chat.id, text: 'Unknown command', reply_markup: markup)
93
- end
94
- end
Binary file
@@ -1,27 +0,0 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'telebot/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "telebot"
8
- spec.version = Telebot::VERSION
9
- spec.authors = ["Potapov Sergey"]
10
- spec.email = ["blake131313@gmail.com"]
11
-
12
- spec.summary = "Ruby client for Telegram bot API"
13
- spec.description = spec.summary
14
- spec.homepage = "https://github.com/greyblake/telebot"
15
- spec.license = "MIT"
16
-
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.require_paths = ["lib"]
19
-
20
- spec.add_dependency "faraday"
21
- spec.add_dependency "faraday_middleware"
22
- spec.add_dependency "virtus"
23
-
24
- spec.add_development_dependency "bundler", "~> 1.1"
25
- spec.add_development_dependency "rake", "~> 10.0"
26
- spec.add_development_dependency "rspec"
27
- end