nvd commited on
Update bot.py
Browse files
bot.py
CHANGED
|
@@ -162,6 +162,7 @@ async def on_callback(callback: CallbackQuery):
|
|
| 162 |
if data.startswith("dl:"):
|
| 163 |
url = data[3:]
|
| 164 |
await callback.message.reply("⏳ Downloading file …")
|
|
|
|
| 165 |
await bot.send_document(
|
| 166 |
chat_id=callback.message.chat.id,
|
| 167 |
document=url,
|
|
@@ -170,7 +171,7 @@ async def on_callback(callback: CallbackQuery):
|
|
| 170 |
await callback.answer("Sent!")
|
| 171 |
|
| 172 |
# ---------- Background poller for subscriptions ----------
|
| 173 |
-
async def release_poller(
|
| 174 |
while True:
|
| 175 |
repos = get_all_distinct_repos()
|
| 176 |
for repo_url in repos:
|
|
@@ -199,8 +200,8 @@ async def start_bot(status_callback=None):
|
|
| 199 |
init_db()
|
| 200 |
if status_callback:
|
| 201 |
status_callback("🟢 Bot is online and polling GitHub for subscriptions.")
|
| 202 |
-
# Run the bot
|
| 203 |
await asyncio.gather(
|
| 204 |
-
bot.run(),
|
| 205 |
-
release_poller()
|
| 206 |
)
|
|
|
|
| 162 |
if data.startswith("dl:"):
|
| 163 |
url = data[3:]
|
| 164 |
await callback.message.reply("⏳ Downloading file …")
|
| 165 |
+
# NO InputFile needed – the library accepts a URL string directly
|
| 166 |
await bot.send_document(
|
| 167 |
chat_id=callback.message.chat.id,
|
| 168 |
document=url,
|
|
|
|
| 171 |
await callback.answer("Sent!")
|
| 172 |
|
| 173 |
# ---------- Background poller for subscriptions ----------
|
| 174 |
+
async def release_poller():
|
| 175 |
while True:
|
| 176 |
repos = get_all_distinct_repos()
|
| 177 |
for repo_url in repos:
|
|
|
|
| 200 |
init_db()
|
| 201 |
if status_callback:
|
| 202 |
status_callback("🟢 Bot is online and polling GitHub for subscriptions.")
|
| 203 |
+
# Run both the bot and the poller concurrently
|
| 204 |
await asyncio.gather(
|
| 205 |
+
bot.run(),
|
| 206 |
+
release_poller()
|
| 207 |
)
|