# Copyright (c) 2023, JINGROW
# For license information, please see license.txt
import jingrow


def execute():
	jingrow.reload_pg("jcloud", "pagetype", "telegram_group_topic")
	jingrow.reload_pg("jcloud", "pagetype", "telegram_group")
	jingrow.reload_pg("jcloud", "pagetype", "jcloud_settings")
	settings = jingrow.get_pg("Jcloud Settings")
	if settings.telegram_alert_chat_id:
		group = jingrow.get_pg(
			{
				"pagetype": "Telegram Group",
				"name": "Alerts",
				"chat_id": settings.telegram_alert_chat_id,
			}
		).insert()
		settings.telegram_alerts_chat_group = group.name

	settings.save()
