xasin-telegram 0.2.1 → 0.2.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: 0f3ca644e1e5d77120315bfd33be84caca0c66ef
4
- data.tar.gz: b88593045f6338ad204bfefcdade20fff9ec0cf9
3
+ metadata.gz: 9b586489f2bb15aa638d85a6409bbfd937ee10d8
4
+ data.tar.gz: 3b184fa20bf6fa785ce51796b00af78ca75bc83f
5
5
  SHA512:
6
- metadata.gz: 82b65f87cb2d4b341a086bb748a48ee7a73ade189eee2e2ac21933f21352b149e0fef778ebb54ef1d932f0afdb2bdacd196ed3dc253fb625048b96c39eee26f8
7
- data.tar.gz: 8b297c561c50a537a740a701bbb263adbffc2c596951ef7ae52d3680c8fff46e078dec39a794d51d53cef7a30d551ce932a1e4087b466fa13b4e34765c35a89c
6
+ metadata.gz: c8241173e2b8911d30dcbef771aa1c03848bc6d289160401a518d6b8248fa93281852ab34ccf192afc1a0e770a0dfa232900e528d5cf04fe7c5aa90e43b163b9
7
+ data.tar.gz: ee57382ce4b7649d32e7c01752ddf3d965241815b7e13413486014e5326644caa361b7567decd5f0467baef7d7ec5764fa2627db0c4ac01ad416b5795c4d87f9
@@ -62,12 +62,21 @@ module Telegram
62
62
  return if (uID = uID.to_i) == 0;
63
63
 
64
64
  begin
65
- data = JSON.parse(data, symbolize_names: true);
65
+ data = JSON.parse(data, symbolize_names: true) if data.is_a? String
66
66
  rescue
67
67
  # Allow for pure-text to be sent (easier on the ESPs)
68
68
  data = {text: data}
69
69
  end
70
70
 
71
+ if(gID = data[:gid])
72
+ if(data[:replace])
73
+ _handle_delete(gID, uID)
74
+ elsif(data[:overwrite] and @groupIDList[uID][gID])
75
+ _handle_edit(data, uID);
76
+ return;
77
+ end
78
+ end
79
+
71
80
  outData = {
72
81
  chat_id: uID,
73
82
  parse_mode: (data[:parse_mode] or "Markdown"),
@@ -83,11 +92,6 @@ module Telegram
83
92
 
84
93
  # Check if this message has a grouping ID
85
94
  if(gID = data[:gid])
86
- # If the message has the :single flag, delete the last one
87
- if(data[:single])
88
- _handle_delete(gID, uID);
89
- end
90
-
91
95
  # Save this grouping ID
92
96
  @groupIDList[uID][gID] = reply[:result][:message_id];
93
97
  end
@@ -99,9 +103,8 @@ module Telegram
99
103
  return if (uID = uID.to_i) == 0;
100
104
 
101
105
  begin
102
- data = JSON.parse(data, symbolize_names: true);
106
+ data = JSON.parse(data, symbolize_names: true) if data.is_a? String
103
107
 
104
- return unless data[:text];
105
108
  # Fetch the target Message ID
106
109
  return unless mID = @groupIDList[uID][data[:gid]]
107
110
 
@@ -177,9 +180,7 @@ module Telegram
177
180
 
178
181
  if(data[:text] =~ /^\//)
179
182
  @mqtt.publish_to "Telegram/#{uID}/Command", data.to_json;
180
- end
181
-
182
- if(data[:reply_gid])
183
+ elsif(data[:reply_gid])
183
184
  @mqtt.publish_to "Telegram/#{uID}/Reply", data.to_json;
184
185
  else
185
186
  @mqtt.publish_to "Telegram/#{uID}/Received", data.to_json;
@@ -198,8 +199,13 @@ module Telegram
198
199
  begin
199
200
  data = JSON.parse(msg[:data], symbolize_names: true);
200
201
 
201
- if(data[:k] =~ /^\//)
202
- @mqtt.publish_to "Telegram/#{uID}/Command", {text: data[:k]}.to_json
202
+ data = {
203
+ gid: data[:g],
204
+ key: data[:k],
205
+ }
206
+
207
+ if(data[:key] =~ /^\//)
208
+ @mqtt.publish_to "Telegram/#{uID}/Command", {text: data[:key]}.to_json
203
209
  end
204
210
  @mqtt.publish_to "Telegram/#{uID}/KeyboardPress", data.to_json
205
211
  rescue
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.2.1
4
+ version: 0.2.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-15 00:00:00.000000000 Z
11
+ date: 2018-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mqtt-sub_handler