chgksuite 0.26.0b8__tar.gz → 0.26.0b9__tar.gz
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.
- {chgksuite-0.26.0b8/chgksuite.egg-info → chgksuite-0.26.0b9}/PKG-INFO +1 -1
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/telegram.py +68 -46
- chgksuite-0.26.0b9/chgksuite/version.py +1 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9/chgksuite.egg-info}/PKG-INFO +1 -1
- chgksuite-0.26.0b8/chgksuite/version.py +0 -1
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/LICENSE +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/MANIFEST.in +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/README.md +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/__init__.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/__main__.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/cli.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/common.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/__init__.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/chgksuite_parser.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/composer_common.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/db.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/docx.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/latex.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/lj.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/openquiz.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/pptx.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/reddit.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/stats.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/telegram_bot.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/composer/telegram_parser.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/handouter/__init__.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/handouter/gen.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/handouter/installer.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/handouter/pack.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/handouter/runner.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/handouter/tex_internals.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/handouter/utils.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/parser.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/parser_db.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/cheader.tex +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/fix-unnumbered-sections.sty +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/labels_by.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/labels_by_tar.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/labels_en.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/labels_kz_cyr.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/labels_ru.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/labels_sr.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/labels_ua.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/labels_uz.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/labels_uz_cyr.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/pptx_config.toml +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/regexes_by.json +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/regexes_en.json +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/regexes_kz_cyr.json +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/regexes_ru.json +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/regexes_sr.json +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/regexes_ua.json +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/regexes_uz_cyr.json +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/template.docx +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/template.pptx +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/resources/trello.json +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/trello.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/typotools.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite/vulture_whitelist.py +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite.egg-info/SOURCES.txt +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite.egg-info/dependency_links.txt +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite.egg-info/entry_points.txt +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite.egg-info/requires.txt +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/chgksuite.egg-info/top_level.txt +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/history.md +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/setup.cfg +0 -0
- {chgksuite-0.26.0b8 → chgksuite-0.26.0b9}/setup.py +0 -0
|
@@ -16,6 +16,11 @@ from chgksuite.composer.composer_common import BaseExporter, parseimg
|
|
|
16
16
|
from chgksuite.composer.telegram_bot import run_bot_in_thread
|
|
17
17
|
|
|
18
18
|
|
|
19
|
+
def get_text(msg_data):
|
|
20
|
+
if "message" in msg_data and "text" in msg_data["message"]:
|
|
21
|
+
return msg_data["message"]["text"]
|
|
22
|
+
|
|
23
|
+
|
|
19
24
|
class TelegramExporter(BaseExporter):
|
|
20
25
|
def __init__(self, *args, **kwargs):
|
|
21
26
|
super().__init__(*args, **kwargs)
|
|
@@ -37,6 +42,7 @@ class TelegramExporter(BaseExporter):
|
|
|
37
42
|
self.channel_id = None # Target channel ID
|
|
38
43
|
self.chat_id = None # Discussion group ID linked to the channel
|
|
39
44
|
self.auth_uuid = uuid.uuid4().hex[:8]
|
|
45
|
+
self.chat_auth_uuid = uuid.uuid4().hex[:8]
|
|
40
46
|
self.init_telegram()
|
|
41
47
|
|
|
42
48
|
def check_connectivity(self):
|
|
@@ -119,6 +125,9 @@ class TelegramExporter(BaseExporter):
|
|
|
119
125
|
|
|
120
126
|
if result:
|
|
121
127
|
msg_data = json.loads(result["raw_data"])
|
|
128
|
+
if msg_data["message"]["chat"]["type"] != "private":
|
|
129
|
+
print("You should post to the PRIVATE chat, not to the channel/group")
|
|
130
|
+
continue
|
|
122
131
|
self.control_chat_id = msg_data["message"]["chat"]["id"]
|
|
123
132
|
self.send_api_request(
|
|
124
133
|
"sendMessage",
|
|
@@ -860,6 +869,7 @@ class TelegramExporter(BaseExporter):
|
|
|
860
869
|
raise Exception("Failed to get channel ID from forwarded message")
|
|
861
870
|
else:
|
|
862
871
|
raise Exception("Channel ID is undefined")
|
|
872
|
+
|
|
863
873
|
# Handle chat resolution
|
|
864
874
|
if isinstance(chat_result, int):
|
|
865
875
|
chat_id = chat_result
|
|
@@ -868,9 +878,10 @@ class TelegramExporter(BaseExporter):
|
|
|
868
878
|
if not chat_id:
|
|
869
879
|
print("\n" + "=" * 50)
|
|
870
880
|
print(
|
|
871
|
-
"Please
|
|
881
|
+
f"Please write a message in the discussion group with text: {self.chat_auth_uuid}"
|
|
872
882
|
)
|
|
873
883
|
print("This will allow me to extract the group ID automatically.")
|
|
884
|
+
print("The bot MUST be added do the group and made admin, else it won't work!")
|
|
874
885
|
print("=" * 50 + "\n")
|
|
875
886
|
|
|
876
887
|
# Wait for a forwarded message with chat information
|
|
@@ -883,8 +894,7 @@ class TelegramExporter(BaseExporter):
|
|
|
883
894
|
while chat_id == channel_id:
|
|
884
895
|
error_msg = (
|
|
885
896
|
"Chat ID and channel ID are the same. The problem may be that "
|
|
886
|
-
"you
|
|
887
|
-
"from the channel by Telegram. Please forward a message that was sent directly in the discussion group."
|
|
897
|
+
"you posted a message in the channel, not in the discussion group."
|
|
888
898
|
)
|
|
889
899
|
self.logger.error(error_msg)
|
|
890
900
|
chat_id = self.wait_for_forwarded_message(
|
|
@@ -903,7 +913,10 @@ class TelegramExporter(BaseExporter):
|
|
|
903
913
|
raise Exception("Chat ID is undefined")
|
|
904
914
|
|
|
905
915
|
self.channel_id = f"-100{channel_id}"
|
|
906
|
-
|
|
916
|
+
if not str(chat_id).startswith("-100"):
|
|
917
|
+
self.chat_id = f"-100{chat_id}"
|
|
918
|
+
else:
|
|
919
|
+
self.chat_id = chat_id
|
|
907
920
|
|
|
908
921
|
self.logger.info(
|
|
909
922
|
f"Using channel ID {self.channel_id} and discussion group ID {self.chat_id}"
|
|
@@ -1087,7 +1100,10 @@ class TelegramExporter(BaseExporter):
|
|
|
1087
1100
|
failure_message = "❌ Failed to extract channel ID."
|
|
1088
1101
|
else:
|
|
1089
1102
|
entity_name = "discussion group"
|
|
1090
|
-
instruction_message =
|
|
1103
|
+
instruction_message = (
|
|
1104
|
+
f"🔄 Please post to the discussion group a message with text: {self.chat_auth_uuid}\n\n"
|
|
1105
|
+
"⚠️ IMPORTANT: Bot should be added to the discussion group and have ADMIN rights!"
|
|
1106
|
+
)
|
|
1091
1107
|
success_message = "✅ Successfully extracted discussion group ID: {}"
|
|
1092
1108
|
failure_message = "❌ Failed to extract discussion group ID."
|
|
1093
1109
|
|
|
@@ -1104,6 +1120,7 @@ class TelegramExporter(BaseExporter):
|
|
|
1104
1120
|
resolved = False
|
|
1105
1121
|
retry_count = 0
|
|
1106
1122
|
max_retries = 30 # 5 minutes (10 seconds per retry)
|
|
1123
|
+
extracted_id = None
|
|
1107
1124
|
|
|
1108
1125
|
# Extract channel ID for comparison if we're looking for a discussion group
|
|
1109
1126
|
channel_numeric_id = None
|
|
@@ -1132,58 +1149,63 @@ class TelegramExporter(BaseExporter):
|
|
|
1132
1149
|
messages = cursor.fetchall()
|
|
1133
1150
|
|
|
1134
1151
|
for row in messages:
|
|
1152
|
+
if self.args.debug:
|
|
1153
|
+
self.logger.info(row["raw_data"])
|
|
1135
1154
|
if self.created_at and row["created_at"] < self.created_at:
|
|
1136
1155
|
break
|
|
1137
1156
|
msg_data = json.loads(row["raw_data"])
|
|
1138
|
-
if
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
# Remove -100 prefix if present
|
|
1146
|
-
if str(chat_id).startswith("-100"):
|
|
1147
|
-
extracted_id = int(str(chat_id)[4:])
|
|
1148
|
-
else:
|
|
1149
|
-
extracted_id = chat_id
|
|
1150
|
-
|
|
1151
|
-
# If we're looking for a discussion group, verify it's not the same as the channel ID
|
|
1152
|
-
if entity_type == "chat" and channel_numeric_id:
|
|
1153
|
-
if extracted_id == channel_numeric_id:
|
|
1154
|
-
self.logger.warning(
|
|
1155
|
-
"User forwarded a message from the channel, not the discussion group"
|
|
1156
|
-
)
|
|
1157
|
-
self.send_api_request(
|
|
1158
|
-
"sendMessage",
|
|
1159
|
-
{
|
|
1160
|
-
"chat_id": self.control_chat_id,
|
|
1161
|
-
"text": "⚠️ You forwarded a message from the channel, not from the discussion group.\n\nPlease forward a message that was originally sent IN the discussion group, not an automatic repost from the channel.",
|
|
1162
|
-
},
|
|
1163
|
-
)
|
|
1164
|
-
# Skip this message and continue waiting
|
|
1165
|
-
continue
|
|
1166
|
-
|
|
1167
|
-
# For channels, check the type; for chats, accept any type except "channel" if check_type is False
|
|
1168
|
-
if (check_type and forward_info.get("type") == "channel") or (
|
|
1169
|
-
not check_type
|
|
1170
|
-
):
|
|
1171
|
-
resolved = True
|
|
1172
|
-
self.created_at = row["created_at"]
|
|
1173
|
-
self.logger.info(
|
|
1174
|
-
f"Extracted {entity_name} ID: {extracted_id} from forwarded message"
|
|
1157
|
+
if entity_type == "chat":
|
|
1158
|
+
if get_text(msg_data) != self.chat_auth_uuid:
|
|
1159
|
+
continue
|
|
1160
|
+
extracted_id = msg_data["message"]["chat"]["id"]
|
|
1161
|
+
if extracted_id == channel_numeric_id or extracted_id == self.control_chat_id:
|
|
1162
|
+
self.logger.warning(
|
|
1163
|
+
"User posted a message in the channel, not the discussion group"
|
|
1175
1164
|
)
|
|
1176
|
-
|
|
1177
|
-
# Send confirmation message
|
|
1178
1165
|
self.send_api_request(
|
|
1179
1166
|
"sendMessage",
|
|
1180
1167
|
{
|
|
1181
1168
|
"chat_id": self.control_chat_id,
|
|
1182
|
-
"text":
|
|
1169
|
+
"text": (
|
|
1170
|
+
"⚠️ You posted a message in the channel, not in the discussion group."
|
|
1171
|
+
)
|
|
1183
1172
|
},
|
|
1184
1173
|
)
|
|
1174
|
+
# Skip this message and continue waiting
|
|
1175
|
+
continue
|
|
1176
|
+
elif entity_type == "channel":
|
|
1177
|
+
if msg_data["message"]["chat"]["id"] != self.control_chat_id:
|
|
1178
|
+
continue
|
|
1179
|
+
if "message" in msg_data and "forward_from_chat" in msg_data["message"]:
|
|
1180
|
+
forward_info = msg_data["message"]["forward_from_chat"]
|
|
1181
|
+
|
|
1182
|
+
# Extract chat ID from the message
|
|
1183
|
+
chat_id = forward_info.get("id")
|
|
1184
|
+
# Remove -100 prefix if present
|
|
1185
|
+
if str(chat_id).startswith("-100"):
|
|
1186
|
+
extracted_id = int(str(chat_id)[4:])
|
|
1187
|
+
else:
|
|
1188
|
+
extracted_id = chat_id
|
|
1189
|
+
# For channels, check the type; for chats, accept any type except "channel" if check_type is False
|
|
1190
|
+
if extracted_id and ((check_type and forward_info.get("type") == "channel") or (
|
|
1191
|
+
not check_type
|
|
1192
|
+
)):
|
|
1193
|
+
resolved = True
|
|
1194
|
+
self.created_at = row["created_at"]
|
|
1195
|
+
self.logger.info(
|
|
1196
|
+
f"Extracted {entity_name} ID: {extracted_id} from forwarded message"
|
|
1197
|
+
)
|
|
1198
|
+
|
|
1199
|
+
# Send confirmation message
|
|
1200
|
+
self.send_api_request(
|
|
1201
|
+
"sendMessage",
|
|
1202
|
+
{
|
|
1203
|
+
"chat_id": self.control_chat_id,
|
|
1204
|
+
"text": success_message.format(extracted_id),
|
|
1205
|
+
},
|
|
1206
|
+
)
|
|
1185
1207
|
|
|
1186
|
-
|
|
1208
|
+
return extracted_id
|
|
1187
1209
|
|
|
1188
1210
|
retry_count += 1
|
|
1189
1211
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.26.0b9"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.26.0b8"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|