tgvizor 0.1.0 → 0.3.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 +40 -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: f35a3593b31a84a90a63117b8e0f93858b0eb95fa04c90887315049a90f54092
|
|
4
|
+
data.tar.gz: 6d81b6ce5e2b2909aa50c5c28700f1b70b8816800e063260dd166ec7bb67c97d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 49b1339fa9c754f337bc07ba279cf48fbc083de839b8a8e70b296db773cfc269a8132bc68e64cc850c613de661aebfa717ab9f2b1a61ed38d6157c39fa66e6e5
|
|
7
|
+
data.tar.gz: bb106efefe084045e9eaaf6cb387511c4a322fbf03cfea8839719fdb10158da8946b6d920b5e89709b0f43cb4d61263299c0f37a19669cd0f17b60d2492bbcd1
|
|
@@ -108,11 +108,47 @@ 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 (type/id/title) powers the dashboard's DM-vs-group
|
|
123
|
+
# breakdown and group naming. Prefixed `_` so user properties never
|
|
124
|
+
# collide with it.
|
|
125
|
+
chat = extract_chat(update)
|
|
126
|
+
if chat && classification[:event]
|
|
127
|
+
classification[:properties] = (classification[:properties] || {}).merge(chat_properties(chat))
|
|
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(update)
|
|
137
|
+
if update.respond_to?(:chat)
|
|
138
|
+
update.chat
|
|
139
|
+
else
|
|
140
|
+
message = update.respond_to?(:message) ? update.message : nil
|
|
141
|
+
message.chat if message && message.respond_to?(:chat)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
114
144
|
|
|
115
|
-
|
|
145
|
+
# `_chat_title` only exists on groups/channels — private chats have none.
|
|
146
|
+
def chat_properties(chat)
|
|
147
|
+
props = {}
|
|
148
|
+
props[:_chat_type] = chat.type if chat.respond_to?(:type) && chat.type
|
|
149
|
+
props[:_chat_id] = chat.id if chat.respond_to?(:id) && chat.id
|
|
150
|
+
props[:_chat_title] = chat.title if chat.respond_to?(:title) && chat.title
|
|
151
|
+
props
|
|
116
152
|
end
|
|
117
153
|
|
|
118
154
|
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.3.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
|