-
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.
- Loading branch information
0 parents
commit ff5156a
Showing
3 changed files
with
53 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Deploy | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
name: Deploy | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Deploy | ||
uses: cloudflare/wrangler-action@v3 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
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,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
async function forward_message(env, chat_id, from_chat_id, message_id) { | ||
const url = `https://api.telegram.org/bot${env.TG_BOT_TOKEN}/sendMessage` | ||
const data = { | ||
chat_id, | ||
from_chat_id, | ||
message_id, | ||
} | ||
const response = await fetch(url, { | ||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify(data), | ||
}) | ||
console.log(data) | ||
if (!response.ok) { | ||
throw new Error(`send_message: server returns ${response.status} ${response.statusText}`) | ||
} | ||
} | ||
|
||
export default { | ||
async scheduled(event, env, ctx) { | ||
await forward_message(env, env.CHAT_ID, env.FROM_CHAT_ID, env.MESSAGE_ID) | ||
|
||
console.log('cron processed') | ||
}, | ||
}; |
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,6 @@ | ||
name = "tgbot-cron" | ||
main = "bot.js" | ||
compatibility_date = "2024-08-06" | ||
|
||
[triggers] | ||
crons = ["0 11,16 * * *"] |