rikutelebot 0.0.4 → 0.0.5

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
  SHA1:
3
- metadata.gz: 89edd11235002a6a91c082c027cb418d3a10773f
4
- data.tar.gz: 786d6dd486ed0ffef10d573b6e2c04d64b2b292c
3
+ metadata.gz: 605889ad74d889e0bbfcf54c9a0efb292c5dc2a0
4
+ data.tar.gz: 6035b3b248f1a1bd2120fbe7807d4011e179e83d
5
5
  SHA512:
6
- metadata.gz: e5e28019c1cce1488c072cf2a7296b9cf9489eb5d8c8ad5785d61fa88e285a34f491c4168f9729c0cd119e6e0726e8efd5232e8064b5c06227de45e815badc5c
7
- data.tar.gz: bb46cc88c05052a5c780e137e9695c8b18fbb29ea14c0f4626594306962c68d12095b25e5b664524589f229c9899a4b46503705d96523ba95898d1e791d329f5
6
+ metadata.gz: 7b661490257c472c275be54cc5ec7feb87f122a2fd072bd14001e3f384dfc912d42e06805da02ec73844feecf6dc70083774d007f70c3dcb8cd06e2c6734e1bd
7
+ data.tar.gz: 02da2feeab2d3101176d4e725a219b62ad7d409b12390a2b1982e9e022e1ff6d36d6e500ea25b94ff6c49bfa80c2640aa5a2ddfac6b2c0ec4b2cdce9278a5af6
@@ -1,3 +1,3 @@
1
1
  module Rikutelebot
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/rikutelebot.rb CHANGED
@@ -4,9 +4,9 @@ require 'json'
4
4
 
5
5
  module Rikutelebot
6
6
 
7
- Config = Struct.new(:token) do
7
+ Config = Struct.new(:token, :offset) do
8
8
  def getupdatesurl
9
- "https://api.telegram.org/bot#{token}/getUpdates"
9
+ "https://api.telegram.org/bot#{token}/getUpdates?offset=#{offset}"
10
10
  end
11
11
  end
12
12
 
@@ -26,7 +26,7 @@ module Rikutelebot
26
26
 
27
27
  class Bot
28
28
  def initialize
29
- @conf = Config.new nil
29
+ @conf = Config.new nil, (File.exist?('offset') ? File.read('offset').to_i : 0)
30
30
  @state = false
31
31
  @commands = []
32
32
  yield @conf
@@ -55,6 +55,11 @@ module Rikutelebot
55
55
 
56
56
  yield Message.new(usr, chat, update['message']['text']) unless update['message']['text'].nil?
57
57
  end
58
+ @conf.offset = j['result'].last['update_id'] + 1
59
+ File.open('offset', 'w') do |f|
60
+ f.write @conf.offset
61
+ f.close
62
+ end
58
63
  end
59
64
 
60
65
  def commands
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rikutelebot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Riku