xasin-telegram 0.1.3.dev → 0.2

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: 743b7681fa291a1401aa3b999eeb412d8bda857d
4
- data.tar.gz: '099444ca11d5acc8419ed9c27886e3f1636bf49f'
3
+ metadata.gz: ca600743456b5d6b4114c81e9088714a8bada45d
4
+ data.tar.gz: ea9dcfbd3270f0f47e8665af6757680701268eb7
5
5
  SHA512:
6
- metadata.gz: 6e4fa00ac3f7d491ce64f83c3ccbba02d38a593b5e83dd132ceb0745b85585d9f867ada2041e5b3b2af50ee870f4158d8db9903cbfe5f406c50dc3773758e5c9
7
- data.tar.gz: 85081d52cf64f6ff7654e317caa31b01623752a04e1cafa57276923d590dde2932cb371f4178b435a8d6aa77a3f9bf901a2f0669db0284a2646b9637b11f6408
6
+ metadata.gz: b703ae37d7171d40fced2228c328f7040a6680081146609aaaa068e3d03199982a5224e5fe3d8535090db5008f3faa8641d03f1c6c530f7f13f788fce886f477
7
+ data.tar.gz: 1ed6375349b5c692049f19fcd9e38c9471d407f42a42574cde4d7d133a00a160bb4cc1a334aecf1a1fc002ae7c0fd672b992a6372d31acdfea45527518a9869b
@@ -21,7 +21,16 @@ module Telegram
21
21
 
22
22
  begin
23
23
  if data
24
- response = Net::HTTP.post_form(callAddress, data);
24
+ outData = Hash.new();
25
+ data.each do |key, val|
26
+ if(val.is_a? Hash or val.is_a? Array)
27
+ outData[key] = val.to_json
28
+ else
29
+ outData[key] = val;
30
+ end
31
+ end
32
+
33
+ response = Net::HTTP.post_form(callAddress, outData);
25
34
  else
26
35
  response = Net::HTTP.get callAddress
27
36
  end
@@ -28,14 +28,24 @@ module Telegram
28
28
  setup_mqtt();
29
29
  end
30
30
 
31
- def _process_inline_keyboard(keyboardLayout, GID)
31
+ def _process_inline_keyboard(keyboardLayout, gID)
32
32
  return nil unless (keyboardLayout.is_a? Array)
33
- return nil unless GID
33
+ return nil unless gID
34
34
 
35
35
  outData = Array.new();
36
-
37
- keyboardLayout.each do |key|
38
- outData << {text: key, callback_data: "#{GID}:#{key}"}
36
+ if(keyboardLayout[0].is_a? String) then
37
+ keyboardLayout.each do |key|
38
+ outData << {text: key, callback_data: "#{gID}:#{key}"}
39
+ end
40
+ outData = [outData];
41
+ else
42
+ keyboardLayout.each do |row|
43
+ newRow = Array.new();
44
+ row.each do |key|
45
+ newRow << {text: key, callback_data: "#{gID}:#{key}"}
46
+ end
47
+ outData << newRow
48
+ end
39
49
  end
40
50
 
41
51
  return {inline_keyboard: outData};
@@ -66,11 +76,12 @@ module Telegram
66
76
  text: data[:text]
67
77
  }
68
78
 
69
- if(ilk = data[:inline_keyboard])
79
+ if(ilk = data[:inline_keyboard] and data[:GID])
70
80
  outData[:reply_markup] = _process_inline_keyboard(ilk, data[:GID]);
71
81
  end
72
82
 
73
83
  reply = @httpCore.perform_post("sendMessage", outData);
84
+ return unless reply[:ok]
74
85
 
75
86
  # Check if this message has a grouping ID
76
87
  if(gID = data[:GID])
@@ -181,7 +192,7 @@ module Telegram
181
192
  uID = newUID
182
193
  end
183
194
 
184
- return unless /(\w+):(\w+)/ =~ msg[:data]
195
+ return unless /(\S+):(\S+)/ =~ msg[:data]
185
196
  @mqtt.publish_to "Telegram/#{uID}/KeyboardPress", {GID: $1, key: $2}
186
197
  end
187
198
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xasin-telegram
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.dev
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Xasin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-13 00:00:00.000000000 Z
11
+ date: 2018-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mqtt-sub_handler
@@ -51,9 +51,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
51
51
  version: '0'
52
52
  required_rubygems_version: !ruby/object:Gem::Requirement
53
53
  requirements:
54
- - - ">"
54
+ - - ">="
55
55
  - !ruby/object:Gem::Version
56
- version: 1.3.1
56
+ version: '0'
57
57
  requirements: []
58
58
  rubyforge_project:
59
59
  rubygems_version: 2.6.14.1