tgvizor 0.1.0 → 0.2.0
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 +4 -4
- data/lib/tgvizor/middleware/telegram_bot_ruby.rb +34 -4
- data/lib/tgvizor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dfa3a42c69518ecab7e936a9b6144538e72a98a470371a8bd00b9253bf6049f8
|
|
4
|
+
data.tar.gz: 384ffe436ad1e8c37b5a3f049dff970353b25bab32045bdd1f840b9139712ca7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a26ddda392ce73bbf17eea1b20f037873fb16df2c09f35e7acf038674f99e2bc250d93b5f65f47ed6844924c721059cc9c5bfebebd754b2066204245d4aa4825
|
|
7
|
+
data.tar.gz: fd90a0071158fedcda33e9e1814543119122c5212f662b6703433124ad43fe0c51607ad74e0271cb8bdb9b103c276a839d0a354aeea4f174b7bf8ba577485740
|
|
@@ -108,11 +108,41 @@ module TgVizor
|
|
|
108
108
|
# Classify the update into an event-name + properties payload.
|
|
109
109
|
# Returns nil for update kinds we don't track.
|
|
110
110
|
def classify(update)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
classification =
|
|
112
|
+
if message?(update)
|
|
113
|
+
classify_message(update)
|
|
114
|
+
elsif callback_query?(update)
|
|
115
|
+
classify_callback_query(update)
|
|
116
|
+
elsif inline_query?(update)
|
|
117
|
+
classify_inline_query(update)
|
|
118
|
+
else
|
|
119
|
+
{ event: nil }
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Chat context (private/group/supergroup/channel) powers the
|
|
123
|
+
# dashboard's DM-vs-group breakdown. Prefixed `_` so user properties
|
|
124
|
+
# never collide with it.
|
|
125
|
+
chat_type = extract_chat_type(update)
|
|
126
|
+
if chat_type && classification[:event]
|
|
127
|
+
classification[:properties] = (classification[:properties] || {}).merge(_chat_type: chat_type)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
classification
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Messages carry `chat` directly; callback queries carry it via the
|
|
134
|
+
# originating message (nil for inline-originated callbacks); inline
|
|
135
|
+
# queries have no chat at all.
|
|
136
|
+
def extract_chat_type(update)
|
|
137
|
+
chat =
|
|
138
|
+
if update.respond_to?(:chat)
|
|
139
|
+
update.chat
|
|
140
|
+
else
|
|
141
|
+
message = update.respond_to?(:message) ? update.message : nil
|
|
142
|
+
message.chat if message && message.respond_to?(:chat)
|
|
143
|
+
end
|
|
114
144
|
|
|
115
|
-
|
|
145
|
+
chat&.respond_to?(:type) ? chat.type : nil
|
|
116
146
|
end
|
|
117
147
|
|
|
118
148
|
def classify_message(message)
|
data/lib/tgvizor/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tgvizor
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- TGVizor
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-08-24 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: rspec
|