forked from joont92/srtmacro
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 확장 프로그램의 '옵션'에서 텔레그램 봇의 토큰(token)과 본인의 chat id 설정 가능, 설정 저장 시 'Bot connected.' 라는 메시지가 봇에게 전달됨 - 예약 완료 시 트럼펫 소리와 함께 텔레그램 봇으로 예약 완료 알리 전달
- Loading branch information
Showing
4 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>SRT Macro Options</title> | ||
<style> | ||
body: { padding: 10px; } | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<table cellpadding="5"> | ||
<tr> | ||
<td align="right">Bot Token:</td> | ||
<td><input type="text" id="bot_token" size="30"/></td> | ||
</tr> | ||
<tr> | ||
<td align="right">Your Telegram Chat ID:</td> | ||
<td><input type="text" id="chat_id" size="30"/></td> | ||
</tr> | ||
</table> | ||
|
||
<br /> | ||
|
||
<div id="status"></div> | ||
<button id="save">Save</button> | ||
|
||
<script src="options.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
var defaultBotToken = 'Set your telegram bot token'; | ||
var defaultChatId = 'Set your telegram chat id'; | ||
|
||
function save_options() { | ||
localStorage['botToken'] = document.getElementById('bot_token').value; | ||
localStorage['chatId'] = document.getElementById('chat_id').value; | ||
|
||
var url = 'https://api.telegram.org/bot' + document.getElementById('bot_token').value + '/sendmessage?chat_id=' + document.getElementById('chat_id').value + '&text=' + encodeURI('Bot connected.'); | ||
|
||
var xmlhttp = new XMLHttpRequest(); | ||
xmlhttp.onreadystatechange=function() { | ||
if (xmlhttp.readyState==4 && xmlhttp.status==200) { | ||
var response = xmlhttp.responseText; //if you need to do something with the returned value | ||
} | ||
} | ||
xmlhttp.open('GET', url, true); | ||
xmlhttp.send(); | ||
|
||
var status = document.getElementById('status'); | ||
status.textContent = 'Options saved.'; | ||
setTimeout(function() { | ||
status.textContent = ''; | ||
}, 750); | ||
} | ||
|
||
function restore_options() { | ||
var botToken = localStorage['botToken']; | ||
var chatId = localStorage['chatId']; | ||
|
||
if (botToken == undefined) | ||
botToken = defaultBotToken; | ||
|
||
if (chatId == undefined) | ||
chatId = defaultChatId; | ||
|
||
document.getElementById('bot_token').value = botToken; | ||
document.getElementById('chat_id').value = chatId; | ||
} | ||
document.addEventListener('DOMContentLoaded', restore_options); | ||
document.getElementById('save').addEventListener('click', | ||
save_options); |