add weather command
This commit is contained in:
parent
52a080e493
commit
ae43e88e1f
3 changed files with 57 additions and 0 deletions
15
index.mjs
15
index.mjs
|
@ -4,6 +4,8 @@ import {
|
|||
SlowModeRateLimiter,
|
||||
} from "dank-twitch-irc";
|
||||
|
||||
import fetch from "node-fetch";
|
||||
|
||||
let client = new ChatClient({
|
||||
username: process.env.TWITCH_NAME,
|
||||
password: process.env.TWITCH_PASSWORD,
|
||||
|
@ -72,6 +74,19 @@ client.on("PRIVMSG", async (msg) => {
|
|||
await client.me(msg.channelName, str).catch((err) => console.log(err));
|
||||
break;
|
||||
|
||||
case "weather":
|
||||
const data = await fetch(`https://wttr.in/${splitted[2]}?format=j1`)
|
||||
.then((res) => res.json())
|
||||
.catch((err) => console.log(err));
|
||||
|
||||
await client
|
||||
.say(
|
||||
msg.channelName,
|
||||
`Weather for ${splitted[2]} Temp: ${data?.current_condition[0]?.temp_C}°C Feels like: ${data?.current_condition[0]?.FeelsLikeC}°C`
|
||||
)
|
||||
.catch((err) => console.log(err));
|
||||
break;
|
||||
|
||||
default:
|
||||
await client
|
||||
.say(msg.channelName, `${msg.displayName} Not a command`)
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"dank-twitch-irc": "^4.3.0",
|
||||
"node-fetch": "^3.3.0",
|
||||
"nodemon": "^2.0.20"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,12 @@ lockfileVersion: 5.4
|
|||
|
||||
specifiers:
|
||||
dank-twitch-irc: ^4.3.0
|
||||
node-fetch: ^3.3.0
|
||||
nodemon: ^2.0.20
|
||||
|
||||
dependencies:
|
||||
dank-twitch-irc: 4.3.0
|
||||
node-fetch: 3.3.0
|
||||
nodemon: 2.0.20
|
||||
|
||||
packages:
|
||||
|
@ -113,6 +115,11 @@ packages:
|
|||
- utf-8-validate
|
||||
dev: false
|
||||
|
||||
/data-uri-to-buffer/4.0.1:
|
||||
resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==}
|
||||
engines: {node: '>= 12'}
|
||||
dev: false
|
||||
|
||||
/debug-logger/0.4.1:
|
||||
resolution: {integrity: sha512-bLX6pxuWO6KMXBRk6vpLgHqWXiuLbKp8kLL/wNEA4rgU8wsNLaw3UNz0NfOi1bcN0JwjFwSfxhldzU5Bc6P5RQ==}
|
||||
dependencies:
|
||||
|
@ -175,6 +182,14 @@ packages:
|
|||
resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==}
|
||||
dev: false
|
||||
|
||||
/fetch-blob/3.2.0:
|
||||
resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==}
|
||||
engines: {node: ^12.20 || >= 14.13}
|
||||
dependencies:
|
||||
node-domexception: 1.0.0
|
||||
web-streams-polyfill: 3.2.1
|
||||
dev: false
|
||||
|
||||
/fill-range/7.0.1:
|
||||
resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
@ -182,6 +197,13 @@ packages:
|
|||
to-regex-range: 5.0.1
|
||||
dev: false
|
||||
|
||||
/formdata-polyfill/4.0.10:
|
||||
resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==}
|
||||
engines: {node: '>=12.20.0'}
|
||||
dependencies:
|
||||
fetch-blob: 3.2.0
|
||||
dev: false
|
||||
|
||||
/fsevents/2.3.2:
|
||||
resolution: {integrity: sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==}
|
||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
|
@ -270,6 +292,20 @@ packages:
|
|||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||
dev: false
|
||||
|
||||
/node-domexception/1.0.0:
|
||||
resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==}
|
||||
engines: {node: '>=10.5.0'}
|
||||
dev: false
|
||||
|
||||
/node-fetch/3.3.0:
|
||||
resolution: {integrity: sha512-BKwRP/O0UvoMKp7GNdwPlObhYGB5DQqwhEDQlNKuoqwVYSxkSZCSbHjnFFmUEtwSKRPU4kNK8PbDYYitwaE3QA==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
dependencies:
|
||||
data-uri-to-buffer: 4.0.1
|
||||
fetch-blob: 3.2.0
|
||||
formdata-polyfill: 4.0.10
|
||||
dev: false
|
||||
|
||||
/nodemon/2.0.20:
|
||||
resolution: {integrity: sha512-Km2mWHKKY5GzRg6i1j5OxOHQtuvVsgskLfigG25yTtbyfRGn/GNvIbRyOf1PSCKJ2aT/58TiuUsuOU5UToVViw==}
|
||||
engines: {node: '>=8.10.0'}
|
||||
|
@ -441,6 +477,11 @@ packages:
|
|||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||
dev: false
|
||||
|
||||
/web-streams-polyfill/3.2.1:
|
||||
resolution: {integrity: sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==}
|
||||
engines: {node: '>= 8'}
|
||||
dev: false
|
||||
|
||||
/wrappy/1.0.2:
|
||||
resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==}
|
||||
dev: false
|
||||
|
|
Loading…
Reference in a new issue