Отправка уведомлений в Телеграмм из программы по завершению функции
Есть скрипт отвечающий за обратный отсчет времени после запуска определенного действия. Как мне сделать, чтобы по окончанию таймера отправлялось уведомление в телеграмм бота, и еще чтобы в нем присутствовало название Action?
extends Panel
export(String, "Dig", "Tree", "Pokestop", "Bosses", "Daily", "Excavation", "Items", "Mushrooms", "Other") var Action
export var areaName := "Route 1"
export var cooldown_sec := 259200
var itemindex = 0
var indexcount = 0
var exist = false
func calculate_time_left(current_unix_time:int):
var time_left = (int(Datastore.get_data().Profiles[Datastore.get_data().LastSelectedProfile].user_data[itemindex][2]) + cooldown_sec) - current_unix_time
var result := ""
if time_left <= 0:
result = "Ready"
$VBC/HBC/Done.visible = true
$VBC/HBC/Reset.visible = false
else:
$VBC/HBC/Done.visible = false
$VBC/HBC/Reset.visible = true
var day = time_left / 86400
var hour = (time_left - (86400 * day)) / 3600
var minute = (time_left - (day * 86400) - (hour * 3600)) / 60
result = str(day) + ":" + str(hour) + ":" + str(minute)
return result
func _ready():
$VBC/Area.text = areaName
for profile in Datastore.get_data().Profiles:
indexcount = 0
for data in profile.user_data:
if data.has(Action) && data.has(areaName):
exist = true
itemindex = indexcount
if str(data[2]) != "Ready":
$VBC/HBC/Cooldown.text = calculate_time_left(OS.get_unix_time())
$VBC/HBC/Done.visible = false
$VBC/HBC/Reset.visible = true
else:
$VBC/HBC/Cooldown.text = "Ready"
indexcount += 1
if !exist:
profile.user_data.append([Action, areaName, "Ready"])
itemindex = Datastore.get_data().Profiles[Datastore.get_data().LastSelectedProfile].user_data.size() - 1
$VBC/HBC/Cooldown.text = "Ready"
func _process(_delta):
$VBC/HBC/Cooldown.text = calculate_time_left(OS.get_unix_time())
func _on_Done_pressed():
Datastore.get_data().Profiles[Datastore.get_data().LastSelectedProfile].user_data[itemindex] = [Action, areaName, OS.get_unix_time()]
Datastore.set_data(Datastore.get_data())
Datastore.save_data()
$VBC/HBC/Cooldown.text = calculate_time_left(OS.get_unix_time())
$VBC/HBC/Done.visible = false
$VBC/HBC/Reset.visible = true
func _on_Reset_pressed():
$VBC/HBC/Cooldown.text = "Ready"
$VBC/HBC/Done.visible = true
$VBC/HBC/Reset.visible = false
Datastore.get_data().Profiles[Datastore.get_data().LastSelectedProfile].user_data[itemindex] = [Action, areaName, "Ready"]
Datastore.set_data(Datastore.get_data())
Datastore.save_data()