ChaterJee 0.2.8__py3-none-any.whl → 0.2.9__py3-none-any.whl
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.
- ChaterJee/ChaterJee.py +17 -29
- {chaterjee-0.2.8.dist-info → chaterjee-0.2.9.dist-info}/METADATA +1 -1
- chaterjee-0.2.9.dist-info/RECORD +6 -0
- chaterjee-0.2.8.dist-info/RECORD +0 -6
- {chaterjee-0.2.8.dist-info → chaterjee-0.2.9.dist-info}/WHEEL +0 -0
- {chaterjee-0.2.8.dist-info → chaterjee-0.2.9.dist-info}/top_level.txt +0 -0
ChaterJee/ChaterJee.py
CHANGED
@@ -12,6 +12,7 @@ from telegram.ext import Updater, ApplicationBuilder, ContextTypes, CommandHandl
|
|
12
12
|
from telegram.constants import ParseMode
|
13
13
|
import os.path
|
14
14
|
import threading
|
15
|
+
import subprocess
|
15
16
|
from subprocess import PIPE, Popen
|
16
17
|
from pathlib import Path
|
17
18
|
|
@@ -169,38 +170,25 @@ class ChatLogs:
|
|
169
170
|
return last_line.strip()
|
170
171
|
|
171
172
|
def get_last_line(filepath):
|
172
|
-
|
173
|
-
|
174
|
-
f.seek(0, 2)
|
175
|
-
end = f.tell()
|
176
|
-
pos = end - 1
|
177
|
-
last_non_empty_pos = None
|
178
|
-
|
179
|
-
# Step backwards to find last non-empty line
|
180
|
-
while pos >= 0:
|
181
|
-
f.seek(pos)
|
182
|
-
char = f.read(1)
|
183
|
-
|
184
|
-
# If we find a newline, check if we've collected non-whitespace since last newline
|
185
|
-
if char == b'\n':
|
186
|
-
if last_non_empty_pos is not None:
|
187
|
-
break
|
188
|
-
# Skip empty lines at the end
|
189
|
-
end = pos
|
190
|
-
elif not char.isspace():
|
191
|
-
# Track position of last non-whitespace character
|
192
|
-
last_non_empty_pos = pos
|
193
|
-
|
194
|
-
pos -= 1
|
173
|
+
if not os.path.exists(filepath):
|
174
|
+
return None
|
195
175
|
|
196
|
-
|
197
|
-
|
176
|
+
try:
|
177
|
+
command_chain = f"tail -n 1000 '{filepath}' | grep -Ev '^\s*$' | tail -n 1"
|
178
|
+
process = subprocess.run(command_chain, shell=True, capture_output=True, text=True, check=True)
|
179
|
+
|
180
|
+
output = process.stdout.strip()
|
181
|
+
if output:
|
182
|
+
return output
|
183
|
+
else:
|
198
184
|
return None
|
199
185
|
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
return
|
186
|
+
except subprocess.CalledProcessError as e:
|
187
|
+
return None
|
188
|
+
except FileNotFoundError:
|
189
|
+
return None
|
190
|
+
except Exception as e:
|
191
|
+
return None
|
204
192
|
|
205
193
|
async def cancel(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
|
206
194
|
self.smsID.append(update.message.message_id)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
ChaterJee/ChaterJee.py,sha256=ZowS5jnPzSt6o8ACigYei65uVDEfKzb6nL75Wsox7tU,13668
|
2
|
+
ChaterJee/__init__.py,sha256=tZmkZY2XbzJ8rHDh8nOmb1W73kPecPv3xcEiCPwkZf4,98
|
3
|
+
chaterjee-0.2.9.dist-info/METADATA,sha256=F95_Nvpn_jb71dvzdMDNlmn0UQkuilfHiA9VMq_Laos,5872
|
4
|
+
chaterjee-0.2.9.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
5
|
+
chaterjee-0.2.9.dist-info/top_level.txt,sha256=Z1UAYoaNybpDiKjqa1yFpti_q0FNECVItb3-9yAh3gM,10
|
6
|
+
chaterjee-0.2.9.dist-info/RECORD,,
|
chaterjee-0.2.8.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
ChaterJee/ChaterJee.py,sha256=sFcIZhnVihbRxaiIlvh7JBgjIkQ7xOe2wcirTmjmH7g,14204
|
2
|
-
ChaterJee/__init__.py,sha256=tZmkZY2XbzJ8rHDh8nOmb1W73kPecPv3xcEiCPwkZf4,98
|
3
|
-
chaterjee-0.2.8.dist-info/METADATA,sha256=CKER-5tBAhMOj9pUDOBA4vKqQnb1OPYwER_1qzf5LyM,5872
|
4
|
-
chaterjee-0.2.8.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
5
|
-
chaterjee-0.2.8.dist-info/top_level.txt,sha256=Z1UAYoaNybpDiKjqa1yFpti_q0FNECVItb3-9yAh3gM,10
|
6
|
-
chaterjee-0.2.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|