Skip to content

Commit

Permalink
use respond
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick80835 committed Oct 10, 2020
1 parent 400c747 commit 899355e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion ubot/modules/booru.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ async def booru(event):
return

try:
await event.client.send_message(event.chat_id, f"[sauce]({post.sauce})", file=post.file_url, force_document=as_file)
await event.respond(f"[sauce]({post.sauce})", file=post.file_url, force_document=as_file)
await event.delete()
except:
await event.edit(f"`Failed to fetch media for query: `**{event.args}**")
8 changes: 4 additions & 4 deletions ubot/modules/catdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def shibe(event):
await event.edit(f"`There was an error finding the shibes! :( -> {shibe_inu}`")
return

await event.client.send_file(await event.client.get_input_entity(event.chat_id), shibe_inu[0])
await event.respond(file=shibe_inu[0])
await event.delete()


Expand All @@ -74,7 +74,7 @@ async def bird(event):
await event.edit(f"`There was an error finding the birdies! :( -> {tori}`")
return

await event.client.send_file(await event.client.get_input_entity(event.chat_id), tori[0])
await event.respond(file=tori[0])
await event.delete()


Expand All @@ -86,7 +86,7 @@ async def cat(event):
await event.reply(f"There was an error finding the cats! :( -> **{neko}**")
return

await event.client.send_file(event.chat, neko[0]["url"], force_document=bool(event.other_args[1]))
await event.respond(file=neko[0]["url"], force_document=bool(event.other_args[1]))
await event.delete()


Expand All @@ -98,5 +98,5 @@ async def dog(event):
await event.edit(f"There was an error finding the dogs! :( -> **{inu}**")
return

await event.client.send_file(event.chat, inu[0]["url"], force_document=bool(event.other_args[1]))
await event.respond(file=inu[0]["url"], force_document=bool(event.other_args[1]))
await event.delete()
2 changes: 1 addition & 1 deletion ubot/modules/fourchan.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def fourchan(event):
return

try:
await event.client.send_file(event.chat_id, file=post_file_url, force_document=as_file, caption=post_info[2].replace("<br>", "\n") if post_info[2] else None, parse_mode="html")
await event.respond(file=post_file_url, force_document=as_file, caption=post_info[2].replace("<br>", "\n") if post_info[2] else None, parse_mode="html")
await event.delete()
return
except:
Expand Down
6 changes: 3 additions & 3 deletions ubot/modules/nekos.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async def supernekoatsume(event):
return

try:
await event.client.send_file(event.chat_id, file=image_url, force_document=as_file, reply_to=reply_to)
await event.respond(file=image_url, force_document=as_file, reply_to=reply_to)
await event.delete()
except:
await event.edit(f"`Failed to fetch media for query: `**{nekotype}**")
Expand Down Expand Up @@ -61,7 +61,7 @@ async def eightball(event):
sticker_io.name = "sticker.webp"

try:
await event.client.send_file(event.chat_id, file=sticker_io)
await event.respond(file=sticker_io)
await event.delete()
except:
await event.edit(f"`Failed to send 8ball! :(`")
await event.edit("`Failed to send 8ball! :(`")
2 changes: 1 addition & 1 deletion ubot/modules/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ async def imagefetcher(event, sub):
return

try:
await event.client.send_file(event.chat_id, image_url, caption=title)
await event.respond(file=image_url, caption=title)
await event.delete()
except:
await event.edit(f"`Failed to download content from `**r/{sub}**`!`\n`Title: `**{title}**\n`URL: `{image_url}")
Expand Down
8 changes: 4 additions & 4 deletions ubot/modules/scrapers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def pokemon_image(event):
sticker_io.seek(0)
sticker_io.name = "sticker.webp"

await event.client.send_file(event.chat, sticker_io)
await event.respond(file=sticker_io)
await event.delete()


Expand Down Expand Up @@ -140,7 +140,7 @@ async def text_to_speech(event):
await event.edit('`Error loading the languages dictionary.`')
return

await event.client.send_file(event.chat_id, tts_bytesio, voice_note=True, reply_to=reply)
await event.respond(file=tts_bytesio, voice_note=True, reply_to=reply)
await event.delete()


Expand Down Expand Up @@ -257,7 +257,7 @@ async def youtube_cmd(event):
video = pafy.new(event.args)
video_stream = video.getbest()
try:
await event.client.send_file(event.chat_id, file=video_stream.url)
await event.respond(file=video_stream.url)
except:
await event.reply(f"`Download failed: `[URL]({video_stream.url})")

Expand All @@ -267,6 +267,6 @@ async def youtube_audio_cmd(event):
video = pafy.new(event.args)
video_stream = video.getbestaudio()
try:
await event.client.send_file(event.chat_id, file=video_stream.url)
await event.respond(file=video_stream.url)
except:
await event.reply(f"`Download failed: `[URL]({video_stream.url})")
4 changes: 2 additions & 2 deletions ubot/modules/sticklet.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async def stickcolor(event):
image_stream.name = "sticker.webp"
image.save(image_stream, "WebP")
image_stream.seek(0)
await event.client.send_file(event.chat_id, image_stream)
await event.respond(file=image_stream)


@ldr.add("slet")
Expand Down Expand Up @@ -70,7 +70,7 @@ async def sticklet(event):
image.save(image_stream, "WebP")
image_stream.seek(0)

await event.client.send_file(event.chat_id, image_stream)
await event.respond(file=image_stream)


def find_optimal_wrap(text):
Expand Down
2 changes: 1 addition & 1 deletion ubot/modules/urbandict.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def urban_dict(event):
file_io = io.BytesIO()
file_io.write(bytes(definition.encode('utf-8')))
file_io.name = f"definition of {response_word['word']}.txt"
await event.client.send_file(event.chat_id, file_io, caption="`Output was too large, sent it as a file.`")
await event.respond(file=file_io, caption="`Output was too large, sent it as a file.`")
await event.delete()
return

Expand Down

0 comments on commit 899355e

Please sign in to comment.