mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 04:39:57 +00:00
All APIs on resources.json
This commit is contained in:
parent
b0d9e55edf
commit
2d02e6213f
@ -1,3 +1,4 @@
|
|||||||
|
const Resources = require('../props/resources.json');
|
||||||
const { getStrings } = require('../plugins/checklang.js');
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
@ -46,10 +47,10 @@ module.exports = (bot) => {
|
|||||||
|
|
||||||
bot.command("cat", spamwatchMiddleware, async (ctx) => {
|
bot.command("cat", spamwatchMiddleware, async (ctx) => {
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
const apiUrl = "https://cataas.com/cat?json=true";
|
const apiUrl = `${Resources.catApi}?json=true`;
|
||||||
const response = await axios.get(apiUrl);
|
const response = await axios.get(apiUrl);
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
const imageUrl = `https://cataas.com/cat/${data._id}`;
|
const imageUrl = `${Resources.catApi}/${data._id}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ctx.replyWithPhoto(imageUrl, {
|
await ctx.replyWithPhoto(imageUrl, {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const Resources = require('../props/resources.json');
|
||||||
const { getStrings } = require('../plugins/checklang.js');
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
@ -5,7 +6,7 @@ const axios = require('axios');
|
|||||||
|
|
||||||
async function getDeviceList() {
|
async function getDeviceList() {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('https://raw.githubusercontent.com/androidtrackers/certified-android-devices/master/by_device.json');
|
const response = await axios.get(Resources.codenameApi);
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const message = Strings.codenameCheck.apiErr
|
const message = Strings.codenameCheck.apiErr
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const Resources = require('../props/resources.json');
|
||||||
const { getStrings } = require('../plugins/checklang.js');
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
@ -6,7 +7,7 @@ const axios = require('axios');
|
|||||||
module.exports = (bot) => {
|
module.exports = (bot) => {
|
||||||
bot.command("dog", spamwatchMiddleware, async (ctx) => {
|
bot.command("dog", spamwatchMiddleware, async (ctx) => {
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
const apiUrl = "https://dog.ceo/api/breeds/image/random";
|
const apiUrl = Resources.dogApi;
|
||||||
const response = await axios.get(apiUrl);
|
const response = await axios.get(apiUrl);
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
const resources = require('../props/resources.json');
|
const Resources = require('../props/resources.json');
|
||||||
const { getStrings } = require('../plugins/checklang.js');
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
@ -84,17 +84,17 @@ module.exports = (bot) => {
|
|||||||
|
|
||||||
bot.command('idice', spamwatchMiddleware, async (ctx) => {
|
bot.command('idice', spamwatchMiddleware, async (ctx) => {
|
||||||
ctx.replyWithSticker(
|
ctx.replyWithSticker(
|
||||||
resources.infiniteDice, {
|
Resources.infiniteDice, {
|
||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.command('furry', spamwatchMiddleware, async (ctx) => {
|
bot.command('furry', spamwatchMiddleware, async (ctx) => {
|
||||||
sendRandomReply(ctx, resources.furryGif, 'isFurry', 'isNtFurry');
|
sendRandomReply(ctx, Resources.furryGif, 'isFurry', 'isNtFurry');
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.command('gay', spamwatchMiddleware, async (ctx) => {
|
bot.command('gay', spamwatchMiddleware, async (ctx) => {
|
||||||
sendRandomReply(ctx, resources.gayFlag, 'isGay', 'isNtGay');
|
sendRandomReply(ctx, Resources.gayFlag, 'isGay', 'isNtGay');
|
||||||
});
|
});
|
||||||
|
|
||||||
bot.command(['soggy', 'soggycat'], spamwatchMiddleware, async (ctx) => {
|
bot.command(['soggy', 'soggycat'], spamwatchMiddleware, async (ctx) => {
|
||||||
@ -103,8 +103,8 @@ module.exports = (bot) => {
|
|||||||
switch (true) {
|
switch (true) {
|
||||||
case (userInput === "2" || userInput === "thumb"):
|
case (userInput === "2" || userInput === "thumb"):
|
||||||
ctx.replyWithPhoto(
|
ctx.replyWithPhoto(
|
||||||
resources.soggyCat2, {
|
Resources.soggyCat2, {
|
||||||
caption: resources.soggyCat2,
|
caption: Resources.soggyCat2,
|
||||||
parse_mode: 'Markdown',
|
parse_mode: 'Markdown',
|
||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
});
|
});
|
||||||
@ -112,15 +112,15 @@ module.exports = (bot) => {
|
|||||||
|
|
||||||
case (userInput === "3" || userInput === "sticker"):
|
case (userInput === "3" || userInput === "sticker"):
|
||||||
ctx.replyWithSticker(
|
ctx.replyWithSticker(
|
||||||
resources.soggyCatSticker, {
|
Resources.soggyCatSticker, {
|
||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case (userInput === "4" || userInput === "alt"):
|
case (userInput === "4" || userInput === "alt"):
|
||||||
ctx.replyWithPhoto(
|
ctx.replyWithPhoto(
|
||||||
resources.soggyCatAlt, {
|
Resources.soggyCatAlt, {
|
||||||
caption: resources.soggyCatAlt,
|
caption: Resources.soggyCatAlt,
|
||||||
parse_mode: 'Markdown',
|
parse_mode: 'Markdown',
|
||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
});
|
});
|
||||||
@ -128,8 +128,8 @@ module.exports = (bot) => {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
ctx.replyWithPhoto(
|
ctx.replyWithPhoto(
|
||||||
resources.soggyCat, {
|
Resources.soggyCat, {
|
||||||
caption: resources.soggyCat,
|
caption: Resources.soggyCat,
|
||||||
parse_mode: 'Markdown',
|
parse_mode: 'Markdown',
|
||||||
reply_to_message_id: ctx.message.message_id
|
reply_to_message_id: ctx.message.message_id
|
||||||
});
|
});
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const Resources = require('../props/resources.json');
|
||||||
const { getStrings } = require('../plugins/checklang.js');
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
@ -7,7 +8,7 @@ module.exports = (bot) => {
|
|||||||
bot.command("http", spamwatchMiddleware, async (ctx) => {
|
bot.command("http", spamwatchMiddleware, async (ctx) => {
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
const userInput = ctx.message.text.split(' ')[1];
|
const userInput = ctx.message.text.split(' ')[1];
|
||||||
const apiUrl = "https://status.js.org/codes.json";
|
const apiUrl = Resources.httpApi;
|
||||||
|
|
||||||
if (!userInput || isNaN(userInput)) {
|
if (!userInput || isNaN(userInput)) {
|
||||||
return ctx.reply(Strings.httpCodes.invalidCode, {
|
return ctx.reply(Strings.httpCodes.invalidCode, {
|
||||||
@ -57,7 +58,7 @@ module.exports = (bot) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiUrl = `https://http.cat/${userInput}`;
|
const apiUrl = `${Resources.httpCatApi}${userInput}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await ctx.replyWithPhoto(apiUrl, {
|
await ctx.replyWithPhoto(apiUrl, {
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
const Resources = require('../props/resources.json');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const { getStrings } = require('../plugins/checklang.js');
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
|
|
||||||
const scrobbler_url = 'http://ws.audioscrobbler.com/2.0/';
|
const scrobbler_url = Resources.lastFmApi;
|
||||||
const api_key = process.env.lastKey;
|
const api_key = process.env.lastKey;
|
||||||
|
|
||||||
const dbFile = 'src/props/lastfm.json';
|
const dbFile = 'src/props/lastfm.json';
|
||||||
@ -36,7 +37,7 @@ function saveUsers() {
|
|||||||
|
|
||||||
async function getFromMusicBrainz(mbid) {
|
async function getFromMusicBrainz(mbid) {
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`https://coverartarchive.org/release/${mbid}`);
|
const response = await axios.get(`${Resources.musicBrainzApi}${mbid}`);
|
||||||
const imgObjLarge = response.data.images[0]?.thumbnails?.['1200'];
|
const imgObjLarge = response.data.images[0]?.thumbnails?.['1200'];
|
||||||
const imgObjMid = response.data.images[0]?.thumbnails?.large;
|
const imgObjMid = response.data.images[0]?.thumbnails?.large;
|
||||||
const imageUrl = imgObjLarge || imgObjMid || '';
|
const imageUrl = imgObjLarge || imgObjMid || '';
|
||||||
@ -89,7 +90,7 @@ module.exports = (bot) => {
|
|||||||
const userId = ctx.from.id;
|
const userId = ctx.from.id;
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
const lastfmUser = users[userId];
|
const lastfmUser = users[userId];
|
||||||
const genericImg = "https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png";
|
const genericImg = Resources.lastFmGenericImg;
|
||||||
const botInfo = await ctx.telegram.getMe();
|
const botInfo = await ctx.telegram.getMe();
|
||||||
|
|
||||||
if (!lastfmUser) {
|
if (!lastfmUser) {
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const Resources = require('../props/resources.json');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
@ -7,7 +8,7 @@ const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(is
|
|||||||
|
|
||||||
async function downloadModule(moduleId) {
|
async function downloadModule(moduleId) {
|
||||||
try {
|
try {
|
||||||
const downloadUrl = `https://api.modarchive.org/downloads.php?moduleid=${moduleId}`;
|
const downloadUrl = `${Resources.modArchiveApi}${moduleId}`;
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
url: downloadUrl,
|
url: downloadUrl,
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const Resources = require('../props/resources.json');
|
||||||
const { getStrings } = require('../plugins/checklang.js');
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
@ -31,7 +32,7 @@ module.exports = (bot) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const capitalizedInput = capitalizeFirstLetter(userInput);
|
const capitalizedInput = capitalizeFirstLetter(userInput);
|
||||||
const apiUrl = `http://ponyapi.net/v1/character/${capitalizedInput}`;
|
const apiUrl = `${Resources.ponyApi}/character/${capitalizedInput}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios(apiUrl);
|
const response = await axios(apiUrl);
|
||||||
@ -105,7 +106,7 @@ module.exports = (bot) => {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
const apiUrl = `http://ponyapi.net/v1/episode/by-overall/${userInput}`;
|
const apiUrl = `${Resources.ponyApi}/episode/by-overall/${userInput}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios(apiUrl);
|
const response = await axios(apiUrl);
|
||||||
@ -174,7 +175,7 @@ module.exports = (bot) => {
|
|||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
const apiUrl = `http://ponyapi.net/v1/comics-story/${userInput}`;
|
const apiUrl = `${Resources.ponyApi}/comics-story/${userInput}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios(apiUrl);
|
const response = await axios(apiUrl);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
const Resources = require('../props/resources.json');
|
||||||
const { getStrings } = require('../plugins/checklang.js');
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch);
|
||||||
@ -8,7 +9,7 @@ module.exports = (bot) => {
|
|||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await axios.get('https://quotes-api-self.vercel.app/quote');
|
const response = await axios.get(Resources.quoteApi);
|
||||||
const data = response.data;
|
const data = response.data;
|
||||||
const escapedQuote = data.quote.replace(/([\\_*~`>.!-])/g, '\\$1');
|
const escapedQuote = data.quote.replace(/([\\_*~`>.!-])/g, '\\$1');
|
||||||
const escapedAuthor = `- ${data.author}.`.replace(/([\\_*~`>.!-])/g, '\\$1');
|
const escapedAuthor = `- ${data.author}.`.replace(/([\\_*~`>.!-])/g, '\\$1');
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// Copyright (c) 2024 BubbalooTeam. (https://github.com/BubbalooTeam)
|
// Copyright (c) 2024 BubbalooTeam. (https://github.com/BubbalooTeam)
|
||||||
// Minor code changes by lucmsilva (https://github.com/lucmsilva651)
|
// Minor code changes by lucmsilva (https://github.com/lucmsilva651)
|
||||||
|
|
||||||
|
const Resources = require('../props/resources.json');
|
||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const { getStrings } = require('../plugins/checklang.js');
|
const { getStrings } = require('../plugins/checklang.js');
|
||||||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js');
|
||||||
@ -46,7 +47,7 @@ module.exports = (bot) => {
|
|||||||
const apiKey = process.env.weatherKey;
|
const apiKey = process.env.weatherKey;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const locationResponse = await axios.get('https://api.weather.com/v3/location/search', {
|
const locationResponse = await axios.get(`${Resources.weatherApi}/location/search`, {
|
||||||
params: {
|
params: {
|
||||||
apiKey: apiKey,
|
apiKey: apiKey,
|
||||||
format: 'json',
|
format: 'json',
|
||||||
@ -69,7 +70,7 @@ module.exports = (bot) => {
|
|||||||
const countryCode = locationData.countryCode[0];
|
const countryCode = locationData.countryCode[0];
|
||||||
const { temperatureUnit, speedUnit, apiUnit } = getLocaleUnit(countryCode);
|
const { temperatureUnit, speedUnit, apiUnit } = getLocaleUnit(countryCode);
|
||||||
|
|
||||||
const weatherResponse = await axios.get('https://api.weather.com/v3/aggcommon/v3-wx-observations-current', {
|
const weatherResponse = await axios.get(`${Resources.weatherApi}/aggcommon/v3-wx-observations-current`, {
|
||||||
params: {
|
params: {
|
||||||
apiKey: apiKey,
|
apiKey: apiKey,
|
||||||
format: 'json',
|
format: 'json',
|
||||||
|
@ -5,5 +5,17 @@
|
|||||||
"soggyCatSticker": "CAACAgEAAxkBAAJ9SWb0vY0Xgg4RtNQeU5iLOx3iTVRAAAKgAwACN-NRRFf8v9p0Nz1INgQ",
|
"soggyCatSticker": "CAACAgEAAxkBAAJ9SWb0vY0Xgg4RtNQeU5iLOx3iTVRAAAKgAwACN-NRRFf8v9p0Nz1INgQ",
|
||||||
"infiniteDice": "CAACAgQAAxkBAAJxjWbSSP-8ZNEhEpAJjQsHsGf-UuEPAAJCAAPI-uwTAAEBVWWh4ucINQQ",
|
"infiniteDice": "CAACAgQAAxkBAAJxjWbSSP-8ZNEhEpAJjQsHsGf-UuEPAAJCAAPI-uwTAAEBVWWh4ucINQQ",
|
||||||
"gayFlag": "https://c.tenor.com/VTBe5BFc73sAAAAC/tenor.gif",
|
"gayFlag": "https://c.tenor.com/VTBe5BFc73sAAAAC/tenor.gif",
|
||||||
"furryGif": "https://c.tenor.com/_V_k0BVj48IAAAAd/tenor.gif"
|
"furryGif": "https://c.tenor.com/_V_k0BVj48IAAAAd/tenor.gif",
|
||||||
|
"codenameApi": "https://raw.githubusercontent.com/androidtrackers/certified-android-devices/master/by_device.json",
|
||||||
|
"catApi": "https://cataas.com/cat",
|
||||||
|
"dogApi": "https://dog.ceo/api/breeds/image/random",
|
||||||
|
"httpCatApi": "https://http.cat/",
|
||||||
|
"httpApi": "https://status.js.org/codes.json",
|
||||||
|
"lastFmApi": "http://ws.audioscrobbler.com/2.0/",
|
||||||
|
"musicBrainzApi": "https://coverartarchive.org/release/",
|
||||||
|
"lastFmGenericImg": "https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png",
|
||||||
|
"modArchiveApi": "https://api.modarchive.org/downloads.php?moduleid=",
|
||||||
|
"ponyApi": "http://ponyapi.net/v1",
|
||||||
|
"quoteApi": "https://quotes-api-self.vercel.app/quote",
|
||||||
|
"weatherApi": "https://api.weather.com/v3"
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user