# Copyright (c) 2023, Jingrow Technologies Pvt. Ltd. and Contributors
# For license information, please see license.txt
import jingrow


def execute():
	jingrow.reload_pg("jcloude", "doctype", "telegram_group_topic")
	jingrow.reload_pg("jcloude", "doctype", "telegram_group")
	jingrow.reload_pg("jcloude", "doctype", "jcloude_settings")
	settings = jingrow.get_pg("Press Settings")
	if settings.telegram_alert_chat_id:
		group = jingrow.get_pg(
			{
				"doctype": "Telegram Group",
				"name": "Alerts",
				"chat_id": settings.telegram_alert_chat_id,
			}
		).insert()
		settings.telegram_alerts_chat_group = group.name

	settings.save()
