Skip to content
Open

Done #17

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,4 @@ crashlytics.properties
crashlytics-build.properties
fabric.properties

/.telegramToken
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.8.12-slim-buster

# YOUR COMMANDS HERE
# ....
# ....
WORKDIR /TelegramAI
COPY . .
RUN pip install -r requirements.txt

CMD ["python3", "app.py"]
19 changes: 14 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def download_user_photo(self, quality=0):
file_info = self.bot.get_file(self.current_msg.photo[quality].file_id)
data = self.bot.download_file(file_info.file_path)

with open(file_info.file_path, 'wb') as photo:
photo.write(data)

return file_info
# TODO save `data` as a photo in `file_info.file_path` path

def handle_message(self, message):
Expand All @@ -61,14 +65,19 @@ def handle_message(self, message):


class YoutubeBot(Bot):
pass

def handle_message(self, video_name):
if self.current_msg.content_type == 'photo':
self.download_user_photo()
else:
logger.info(f'Insert Video Name: {video_name}')
result = search_download_youtube_video(video_name.text)
url = result[0]['url']
self.send_text(f'Video Link: {url}')

if __name__ == '__main__':
with open('.telegramToken') as f:
_token = f.read()

my_bot = Bot(_token)
my_bot.start()


my_bot = YoutubeBot(_token)
my_bot.start()
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def search_download_youtube_video(video_name, num_results=1):
'url': video['webpage_url']
})

return results
return results