-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(telegram): adds workflow and script for telegram
- Loading branch information
1 parent
1dfee50
commit 71b7f68
Showing
5 changed files
with
183 additions
and
7 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,28 @@ | ||
name: Notify Telegram on JSON Update | ||
|
||
on: | ||
push: | ||
paths: | ||
- './build/voltage-swap-default.tokenlist.json' | ||
|
||
jobs: | ||
notify: | ||
environment: TELEGRAM | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Run notify script | ||
run: npm run notify:telegram | ||
env: | ||
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | ||
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,63 @@ | ||
const axios = require('axios') | ||
|
||
// const token = process.env.TELEGRAM_BOT_TOKEN | ||
// const chatId = process.env.TELEGRAM_CHAT_ID | ||
const TELEGRAM_BOT_TOKEN = '' | ||
const TELEGRAM_CHAT_ID = '' | ||
|
||
if (!TELEGRAM_BOT_TOKEN || !TELEGRAM_CHAT_ID) { | ||
throw new Error('TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_ID is not set') | ||
} | ||
|
||
async function sendMessage(chatId) { | ||
const url = `https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage` | ||
|
||
// const currentTokenList = await getCurrentTokenList() | ||
// const newToken = await getNewToken(newTokenList, currentTokenList) | ||
|
||
// if (!newToken) { | ||
// console.log('No new token has been added') | ||
// return | ||
// } | ||
|
||
// mock | ||
const newToken = { | ||
name: 'Dai Stablecoin V2', | ||
address: '0x2502F488D481Df4F5054330C71b95d93D41625C2', | ||
symbol: 'DAI V2', | ||
decimals: 18, | ||
chainId: 122, | ||
logoURI: | ||
'https://raw.githubusercontent.com/voltfinance/swap-default-token-list/master/logos/0x440B63C0e7b21a57A3784D8AB8E819B9dA383FDf/logo.png', | ||
} | ||
|
||
const text = ` | ||
There has been a new listing! | ||
- Token address: ${newToken.address} | ||
- Name: ${newToken.name} | ||
- Symbol: ${newToken.symbol} | ||
- Decimals: ${newToken.decimals} | ||
` | ||
|
||
try { | ||
console.log(text) | ||
const response = await axios.post(url, { | ||
chat_id: chatId, | ||
text: text, | ||
}) | ||
console.log('Message sent:', response.data) | ||
} catch (error) { | ||
if (axios.isAxiosError(error)) { | ||
console.error('Axios error message:', error.message) | ||
if (error.response) { | ||
console.error('Response data:', error.response.data) | ||
console.error('Response status:', error.response.status) | ||
console.error('Response headers:', error.response.headers) | ||
} | ||
} else { | ||
console.error('Unexpected error:', error) | ||
} | ||
} | ||
} | ||
|
||
sendMessage(TELEGRAM_CHAT_ID) |
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 |
---|---|---|
|
@@ -746,6 +746,15 @@ asynckit@^0.4.0: | |
resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz" | ||
integrity sha1-x57Zf380y48robyXkLzDZkdLS3k= sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== | ||
|
||
axios@^1.7.3: | ||
version "1.7.3" | ||
resolved "https://registry.npmjs.org/axios/-/axios-1.7.3.tgz" | ||
integrity sha512-Ar7ND9pU99eJ9GpoGQKhKf58GpUOgnzuaB7ueNQ5BMi0p+LZ5oaEnfF999fAArcTIBwXTCHAmGcHOZJaWPq9Nw== | ||
dependencies: | ||
follow-redirects "^1.15.6" | ||
form-data "^4.0.0" | ||
proxy-from-env "^1.1.0" | ||
|
||
balanced-match@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz" | ||
|
@@ -1410,7 +1419,7 @@ flat@^5.0.2: | |
resolved "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz" | ||
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ== | ||
|
||
follow-redirects@^1.12.1: | ||
follow-redirects@^1.12.1, follow-redirects@^1.15.6: | ||
version "1.15.6" | ||
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz" | ||
integrity sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA== | ||
|
@@ -1424,6 +1433,15 @@ form-data@^3.0.0: | |
combined-stream "^1.0.8" | ||
mime-types "^2.1.12" | ||
|
||
form-data@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz" | ||
integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== | ||
dependencies: | ||
asynckit "^0.4.0" | ||
combined-stream "^1.0.8" | ||
mime-types "^2.1.12" | ||
|
||
fp-ts@^1.0.0, [email protected]: | ||
version "1.19.3" | ||
resolved "https://registry.npmjs.org/fp-ts/-/fp-ts-1.19.3.tgz" | ||
|
@@ -2156,6 +2174,11 @@ process@~0.5.1: | |
resolved "https://registry.npmjs.org/process/-/process-0.5.2.tgz" | ||
integrity sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8= sha512-oNpcutj+nYX2FjdEW7PGltWhXulAnFlM0My/k48L90hARCOJtvBbQXc/6itV2jDvU5xAAtonP+r6wmQgCcbAUA== | ||
|
||
proxy-from-env@^1.1.0: | ||
version "1.1.0" | ||
resolved "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz" | ||
integrity sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg== | ||
|
||
punycode@^2.1.0: | ||
version "2.1.1" | ||
resolved "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz" | ||
|