ChaterJee 0.2.7__py3-none-any.whl → 0.2.8__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 CHANGED
@@ -148,7 +148,7 @@ class ChatLogs:
148
148
 
149
149
  return ConversationHandler.END
150
150
 
151
- def get_last_line(self, filepath):
151
+ def get_last_line0(self, filepath):
152
152
  with open(filepath, 'rb') as f:
153
153
  # Go to the end of file
154
154
  f.seek(0, 2)
@@ -168,6 +168,40 @@ class ChatLogs:
168
168
  last_line = f.read().decode('utf-8')
169
169
  return last_line.strip()
170
170
 
171
+ def get_last_line(filepath):
172
+ with open(filepath, 'rb') as f:
173
+ # Go to the end of file
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
195
+
196
+ # If file is empty or only contains whitespace
197
+ if last_non_empty_pos is None:
198
+ return None
199
+
200
+ # Read the last non-empty line
201
+ f.seek(last_non_empty_pos + 1 if last_non_empty_pos != end else 0)
202
+ last_line = f.read(end - f.tell()).decode('utf-8')
203
+ return last_line.strip()
204
+
171
205
  async def cancel(self, update: Update, context: ContextTypes.DEFAULT_TYPE):
172
206
  self.smsID.append(update.message.message_id)
173
207
  await context.bot.sendChatAction(chat_id=self.CHATID, action="typing")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ChaterJee
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Communicate your project updates via Telegram Bot!
5
5
  Author: Pallab Dutta
6
6
  Author-email: pallab9997@gmail.com
@@ -0,0 +1,6 @@
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,,
@@ -1,6 +0,0 @@
1
- ChaterJee/ChaterJee.py,sha256=oTSXbCSpfXB8f9m7ErXSFMlgGayGifI8FUHRa2DeFDg,12995
2
- ChaterJee/__init__.py,sha256=tZmkZY2XbzJ8rHDh8nOmb1W73kPecPv3xcEiCPwkZf4,98
3
- chaterjee-0.2.7.dist-info/METADATA,sha256=AlMpY3NNrzmlfUx5_1DfvBCAWxb4vA_l9e1bIECrtOw,5872
4
- chaterjee-0.2.7.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
5
- chaterjee-0.2.7.dist-info/top_level.txt,sha256=Z1UAYoaNybpDiKjqa1yFpti_q0FNECVItb3-9yAh3gM,10
6
- chaterjee-0.2.7.dist-info/RECORD,,