Update app.py
Browse files
app.py
CHANGED
|
@@ -173,6 +173,9 @@ async def handler_doc(event):
|
|
| 173 |
os.remove(filename)
|
| 174 |
except Exception as e:
|
| 175 |
await event.reply(f"β Error: {e}")
|
|
|
|
|
|
|
|
|
|
| 176 |
@bot.on(events.NewMessage(pattern="/cused"))
|
| 177 |
async def correction_used_handler(event):
|
| 178 |
if not is_owner(event): return
|
|
@@ -186,8 +189,11 @@ async def collect_links(event):
|
|
| 186 |
ctx = user_context.get(event.sender_id)
|
| 187 |
if ctx and ctx.get("mode") == "correct_used":
|
| 188 |
links = [l.strip() for l in event.text.split() if l.startswith("http")]
|
| 189 |
-
|
| 190 |
-
|
|
|
|
|
|
|
|
|
|
| 191 |
|
| 192 |
|
| 193 |
@bot.on(events.NewMessage(pattern="/doneused"))
|
|
@@ -224,7 +230,7 @@ async def process_correction(event):
|
|
| 224 |
if not found:
|
| 225 |
not_found += 1
|
| 226 |
|
| 227 |
-
del user_context[event.sender_id] #
|
| 228 |
|
| 229 |
await event.reply(
|
| 230 |
f"β
Done processing {len(links)} link(s).\n\n"
|
|
|
|
| 173 |
os.remove(filename)
|
| 174 |
except Exception as e:
|
| 175 |
await event.reply(f"β Error: {e}")
|
| 176 |
+
user_context = {} # make sure this is defined once globally
|
| 177 |
+
|
| 178 |
+
|
| 179 |
@bot.on(events.NewMessage(pattern="/cused"))
|
| 180 |
async def correction_used_handler(event):
|
| 181 |
if not is_owner(event): return
|
|
|
|
| 189 |
ctx = user_context.get(event.sender_id)
|
| 190 |
if ctx and ctx.get("mode") == "correct_used":
|
| 191 |
links = [l.strip() for l in event.text.split() if l.startswith("http")]
|
| 192 |
+
if links:
|
| 193 |
+
ctx["links"].extend(links)
|
| 194 |
+
await event.reply(f"π Collected {len(links)} link(s). Send more or use /doneused.")
|
| 195 |
+
else:
|
| 196 |
+
await event.reply("β οΈ No valid links detected. Please send links starting with http.")
|
| 197 |
|
| 198 |
|
| 199 |
@bot.on(events.NewMessage(pattern="/doneused"))
|
|
|
|
| 230 |
if not found:
|
| 231 |
not_found += 1
|
| 232 |
|
| 233 |
+
del user_context[event.sender_id] # Clear mode after done
|
| 234 |
|
| 235 |
await event.reply(
|
| 236 |
f"β
Done processing {len(links)} link(s).\n\n"
|