Skip to content

Commit

Permalink
fix: correctly send images
Browse files Browse the repository at this point in the history
  • Loading branch information
mindrunner committed Dec 9, 2023
1 parent 672a8d7 commit 6a8d859
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
11 changes: 5 additions & 6 deletions src/lib/telegram/commands/meme/kitten.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { faker } from '@faker-js/faker'
import { Telegraf } from 'telegraf'

import { logger } from '../../../../logger'
import { ContextMessageUpdate } from '../../context-message-update'

export const kitten = (bot: Telegraf<ContextMessageUpdate>): void => {
Expand All @@ -9,13 +10,11 @@ export const kitten = (bot: Telegraf<ContextMessageUpdate>): void => {
const x = faker.datatype.number({ min: 128, max: 2048 })

try {
await ctx.replyWithPhoto({
url: `https://placekitten.com/${x}/${x}`,
filename: 'kitten.jpg'
})
await ctx.replyWithPhoto(`https://placekitten.com/${x}/${x}`)
}
catch {
ctx.reply('Meow!')
catch (e: any) {

Check warning on line 15 in src/lib/telegram/commands/meme/kitten.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
logger.error(`Cannot send Photo: ${e.message}`)
await ctx.reply('Meow!')
}
})
})
Expand Down
12 changes: 6 additions & 6 deletions src/lib/telegram/commands/meme/porn.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Telegraf } from 'telegraf'

import { ShipInfo } from '../../../../db/entities'
import { logger } from '../../../../logger'
import { ContextMessageUpdate } from '../../context-message-update'

export const porn = (bot: Telegraf<ContextMessageUpdate>): void => {
Expand All @@ -14,14 +15,13 @@ export const porn = (bot: Telegraf<ContextMessageUpdate>): void => {
.getOne()

const imageName = randomShip?.imageName || ''
const imageUrl = `https://storage.googleapis.com/nft-assets/items/${imageName}.jpg`

await ctx.replyWithPhoto({
url: `https://storage.googleapis.com/nft-assets/items/${imageName}.jpg`,
filename: `${imageName}.jpg`
})
await ctx.replyWithPhoto(imageUrl)
}
catch {
ctx.reply(':-*')
catch (e: any) {

Check warning on line 22 in src/lib/telegram/commands/meme/porn.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
logger.error(`Cannot send Photo: ${e.message}`)
await ctx.reply(':-*')
}
})
})
Expand Down
11 changes: 5 additions & 6 deletions src/lib/telegram/commands/meme/wen.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
import { Telegraf } from 'telegraf'

import { logger } from '../../../../logger'
import { ContextMessageUpdate } from '../../context-message-update'

export const wen = (bot: Telegraf<ContextMessageUpdate>): void => {
bot.command(['wen'], async (ctx) => {
await ctx.persistentChatAction('upload_photo', async () => {
try {
await ctx.replyWithAnimation({
url: 'http://2damnfunny.com/wp-content/uploads/2013/06/Very-Thoon-Husky-Dog-Meme-Gif.gif',
filename: 'thoon.gif'
})
await ctx.replyWithAnimation('http://2damnfunny.com/wp-content/uploads/2013/06/Very-Thoon-Husky-Dog-Meme-Gif.gif')
}
catch {
ctx.reply('Thoon!')
catch (e: any) {

Check warning on line 12 in src/lib/telegram/commands/meme/wen.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected any. Specify a different type
logger.error(`Cannot send Photo: ${e.message}`)
await ctx.reply('Thoon!')
}
})
})
Expand Down

0 comments on commit 6a8d859

Please sign in to comment.