aboutsummaryrefslogtreecommitdiff
path: root/bot
diff options
context:
space:
mode:
authorclarkzjw <[email protected]>2023-03-28 13:25:07 -0700
committerclarkzjw <[email protected]>2023-03-28 13:25:07 -0700
commit7987a261d444b151e53177beffbb8abd16db141b (patch)
tree2c4182b9e9d2a4a5018c556c6451415940872313 /bot
parent78d996f287ecc2c4ab8c4580f8d2ba0a1eed963e (diff)
downloadphoto-7987a261d444b151e53177beffbb8abd16db141b.tar.gz
add rebuild command
Diffstat (limited to 'bot')
-rw-r--r--bot/bot.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/bot/bot.py b/bot/bot.py
index 307f18f..63a15a8 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -181,21 +181,27 @@ async def process(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
181 output.seek(0) 181 output.seek(0)
182 upload_to_s3(photo.fileId, output.read()) 182 upload_to_s3(photo.fileId, output.read())
183 183
184 write_json() 184 await rebuild(update)
185 response = httpx.post(cloudflare_pages_deploy_hook_url) 185
186 if response.status_code == 200:
187 await update.message.reply_markdown_v2(text="trigger deploy succeed")
188 else:
189 await update.message.reply_markdown_v2("trigger deploy failed, status: {}".format(response.status_code))
190 except Exception: 186 except Exception:
191 await update.message.reply_markdown_v2(text="Error:\n```{}```".format(traceback.format_exc())) 187 await update.message.reply_markdown_v2(text="Error:\n```{}```".format(traceback.format_exc()))
192 188
193 189
190async def rebuild(update: Update) -> None:
191 write_json()
192 response = httpx.post(cloudflare_pages_deploy_hook_url)
193 if response.status_code == 200:
194 await update.message.reply_markdown_v2(text="trigger deploy succeed")
195 else:
196 await update.message.reply_markdown_v2("trigger deploy failed, status: {}".format(response.status_code))
197
198
194def main() -> None: 199def main() -> None:
195 tg_token = os.getenv("TG_TOKEN") 200 tg_token = os.getenv("TG_TOKEN")
196 application = Application.builder().token(tg_token).build() 201 application = Application.builder().token(tg_token).build()
197 202
198 application.add_handler(CommandHandler("start", start)) 203 application.add_handler(CommandHandler("start", start))
204 application.add_handler(CommandHandler("rebuild", rebuild))
199 application.add_handler(MessageHandler(filters.ATTACHMENT & ~filters.COMMAND, process)) 205 application.add_handler(MessageHandler(filters.ATTACHMENT & ~filters.COMMAND, process))
200 206
201 application.run_polling() 207 application.run_polling()
Powered by cgit v1.2.3 (git 2.41.0)