-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make all animal commands into one file
- Loading branch information
1 parent
f8c54da
commit 5b78e54
Showing
5 changed files
with
82 additions
and
145 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,82 @@ | ||
const Resources = require('../props/resources.json'); | ||
const { getStrings } = require('../plugins/checklang.js'); | ||
const { isOnSpamWatch } = require('../plugins/lib-spamwatch/spamwatch.js'); | ||
const spamwatchMiddleware = require('../plugins/lib-spamwatch/Middleware.js')(isOnSpamWatch); | ||
const axios = require("axios"); | ||
|
||
module.exports = (bot) => { | ||
bot.command("duck", spamwatchMiddleware, async (ctx) => { | ||
const Strings = getStrings(ctx.from.language_code); | ||
try { | ||
const response = await axios(Resources.duckApi); | ||
ctx.replyWithPhoto(response.data.url, { | ||
caption: "🦆", | ||
reply_to_message_id: ctx.message.message_id | ||
}); | ||
} catch (error) { | ||
const message = Strings.duckApiErr.replace('{error}', error.message); | ||
ctx.reply(message, { | ||
parse_mode: 'Markdown', | ||
reply_to_message_id: ctx.message.message_id | ||
}); | ||
return; | ||
} | ||
}); | ||
|
||
bot.command("fox", spamwatchMiddleware, async (ctx) => { | ||
const Strings = getStrings(ctx.from.language_code); | ||
try { | ||
const response = await axios(Resources.foxApi); | ||
ctx.replyWithPhoto(response.data.image, { | ||
caption: "🦊", | ||
reply_to_message_id: ctx.message.message_id | ||
}); | ||
} catch (error) { | ||
const message = Strings.foxApiErr.replace('{error}', error.message); | ||
ctx.reply(message, { | ||
parse_mode: 'Markdown', | ||
reply_to_message_id: ctx.message.message_id | ||
}); | ||
return; | ||
} | ||
}); | ||
|
||
bot.command("dog", spamwatchMiddleware, async (ctx) => { | ||
const Strings = getStrings(ctx.from.language_code); | ||
try { | ||
const response = await axios(Resources.dogApi); | ||
ctx.replyWithPhoto(response.data.message, { | ||
caption: "🐶", | ||
reply_to_message_id: ctx.message.message_id | ||
}); | ||
} catch (error) { | ||
const message = Strings.foxApiErr.replace('{error}', error.message); | ||
ctx.reply(message, { | ||
parse_mode: 'Markdown', | ||
reply_to_message_id: ctx.message.message_id | ||
}); | ||
return; | ||
} | ||
}); | ||
|
||
bot.command("cat", spamwatchMiddleware, async (ctx) => { | ||
const Strings = getStrings(ctx.from.language_code); | ||
const apiUrl = `${Resources.catApi}?json=true`; | ||
const response = await axios.get(apiUrl); | ||
const data = response.data; | ||
const imageUrl = `${Resources.catApi}/${data._id}`; | ||
|
||
try { | ||
await ctx.replyWithPhoto(imageUrl, { | ||
caption: `🐱`, | ||
parse_mode: 'Markdown', | ||
reply_to_message_id: ctx.message.message_id | ||
}); | ||
} catch (error) { | ||
ctx.reply(Strings.catImgErr, { | ||
parse_mode: 'Markdown', | ||
reply_to_message_id: ctx.message.message_id | ||
}); | ||
}; | ||
}); | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.