From 9428e04ee4b6a81ad31f193b3bb59db2c0f1d3d6 Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sat, 18 May 2024 16:59:19 +0300 Subject: [PATCH 01/19] salt n pepper tese done --- polybot/img_proc.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/polybot/img_proc.py b/polybot/img_proc.py index 137ca70..72f78b4 100644 --- a/polybot/img_proc.py +++ b/polybot/img_proc.py @@ -1,3 +1,4 @@ +import random from pathlib import Path from matplotlib.image import imread, imsave @@ -55,11 +56,22 @@ def rotate(self): raise NotImplementedError() def salt_n_pepper(self): + for i in range(len(self.data)): + for j in range(len(self.data[i])): + rnd = random.random() + if rnd < 0.2: + self.data[i][j] = 255 + elif rnd > 0.8: + self.data[i][j] = 0 + + + # TODO remove the `raise` below, and write your implementation - raise NotImplementedError() + # raise NotImplementedError() def concat(self, other_img, direction='horizontal'): # TODO remove the `raise` below, and write your implementation + raise NotImplementedError() def segment(self): From b4a2f0e0729f00ffb6c595980a4e8e1b025a29ef Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sat, 18 May 2024 17:53:56 +0300 Subject: [PATCH 02/19] segment test done --- polybot/img_proc.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/polybot/img_proc.py b/polybot/img_proc.py index 72f78b4..69c206f 100644 --- a/polybot/img_proc.py +++ b/polybot/img_proc.py @@ -63,17 +63,21 @@ def salt_n_pepper(self): self.data[i][j] = 255 elif rnd > 0.8: self.data[i][j] = 0 + my_img = Img('/home/ameer123/PycharmProjects/PolybotServicePythonFursa/polybot/test/beatles.jpeg') + my_img.salt_n_pepper() + my_img.save_img() # noisy image was saved in 'path/to/image_filtered.jpg' - - # TODO remove the `raise` below, and write your implementation - # raise NotImplementedError() - def concat(self, other_img, direction='horizontal'): # TODO remove the `raise` below, and write your implementation raise NotImplementedError() def segment(self): - # TODO remove the `raise` below, and write your implementation - raise NotImplementedError() + for i in range(len(self.data)): + for j in range(len(self.data[i])): + if self.data[i][j]> 100: + self.data[i][j] = 255 + else: + self.data[i][j] = 0 + From 8cecf93da245ae8580757e9f00c5effc8d54878b Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sat, 18 May 2024 18:13:04 +0300 Subject: [PATCH 03/19] rotate done --- polybot/img_proc.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/polybot/img_proc.py b/polybot/img_proc.py index 69c206f..c000d06 100644 --- a/polybot/img_proc.py +++ b/polybot/img_proc.py @@ -52,8 +52,11 @@ def contour(self): self.data[i] = res def rotate(self): - # TODO remove the `raise` below, and write your implementation - raise NotImplementedError() + for i in range(len(self.data)): + for j in range(i): + tmp = self.data[i][j] + self.data[i][j] = self.data[j][i] + self.data[j][i] = tmp def salt_n_pepper(self): for i in range(len(self.data)): @@ -63,10 +66,6 @@ def salt_n_pepper(self): self.data[i][j] = 255 elif rnd > 0.8: self.data[i][j] = 0 - my_img = Img('/home/ameer123/PycharmProjects/PolybotServicePythonFursa/polybot/test/beatles.jpeg') - my_img.salt_n_pepper() - my_img.save_img() # noisy image was saved in 'path/to/image_filtered.jpg' - def concat(self, other_img, direction='horizontal'): # TODO remove the `raise` below, and write your implementation From c513ab70dbadaa873683cb9d855ce15128c3a579 Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sat, 18 May 2024 18:39:00 +0300 Subject: [PATCH 04/19] concat done --- polybot/img_proc.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/polybot/img_proc.py b/polybot/img_proc.py index c000d06..19039d5 100644 --- a/polybot/img_proc.py +++ b/polybot/img_proc.py @@ -68,9 +68,17 @@ def salt_n_pepper(self): self.data[i][j] = 0 def concat(self, other_img, direction='horizontal'): - # TODO remove the `raise` below, and write your implementation + if len(self.data) != len(other_img.data) or len(self.data[0]) != len(other_img.data[0]): + raise RuntimeError("ERROR: images dimensions are not compatible") + if direction == 'horizontal': + for i in range(len(other_img.data)): + self.data[i] += other_img.data[i] + elif direction == 'vertical': + for i in range(len(other_img.data)): + self.data.append(other_img.data[i]) + else: + raise RuntimeError("ERROR: invalid direction") - raise NotImplementedError() def segment(self): for i in range(len(self.data)): From 5bc4f1577a515ad69ec2f1e7bc3da9c921f51126 Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sat, 18 May 2024 23:09:45 +0300 Subject: [PATCH 05/19] rotate --- polybot/img_proc.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/polybot/img_proc.py b/polybot/img_proc.py index 19039d5..9815c00 100644 --- a/polybot/img_proc.py +++ b/polybot/img_proc.py @@ -52,11 +52,14 @@ def contour(self): self.data[i] = res def rotate(self): - for i in range(len(self.data)): - for j in range(i): - tmp = self.data[i][j] - self.data[i][j] = self.data[j][i] - self.data[j][i] = tmp + if len(self.data) == len(self.data[0]): + for i in range(len(self.data)): + for j in range(i): + tmp = self.data[i][j] + self.data[i][j] = self.data[j][i] + self.data[j][i] = tmp + else: + self.data = [list(row) for row in zip(*self.data[::-1])] def salt_n_pepper(self): for i in range(len(self.data)): @@ -83,7 +86,7 @@ def concat(self, other_img, direction='horizontal'): def segment(self): for i in range(len(self.data)): for j in range(len(self.data[i])): - if self.data[i][j]> 100: + if self.data[i][j] > 100: self.data[i][j] = 255 else: self.data[i][j] = 0 From 4159526f7aaa0295158f2407fb30e9868c8cc1ce Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sat, 18 May 2024 23:10:31 +0300 Subject: [PATCH 06/19] app --- polybot/app.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polybot/app.py b/polybot/app.py index 469190e..e88600d 100644 --- a/polybot/app.py +++ b/polybot/app.py @@ -22,6 +22,6 @@ def webhook(): if __name__ == "__main__": - bot = Bot(TELEGRAM_TOKEN, TELEGRAM_APP_URL) + bot = ImageProcessingBot(TELEGRAM_TOKEN, TELEGRAM_APP_URL) app.run(host='0.0.0.0', port=8443) From aaf8465b07b51b3d1f1fd202244b533e6f3f4209 Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sun, 19 May 2024 01:57:30 +0300 Subject: [PATCH 07/19] not done --- polybot/bot.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+), 1 deletion(-) diff --git a/polybot/bot.py b/polybot/bot.py index 7fea847..723b764 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -75,4 +75,70 @@ def handle_message(self, msg): class ImageProcessingBot(Bot): - pass + def handle_message(self, msg): + logger.info(f'Incoming message: {msg}') + name = msg['chat']['first_name'] + options = ("Please send a photo, with a caption of the filter you want to apply on it.\n" + "- Salt and pepper: Adds random noise the image.\n" + "- Blur: Applies a blurring effect to the image.\n" + "- Contour: Detects edges of objects in the image.\n" + "- Rotate: Rotates the image in clockwise.\n" + "- Segment: Divides the image into regions based on similarities.\n" + "- Concat: Combines two images either horizontally or vertically.\n" + "- Rotate num: Rotates the image in clockwise num times. \n" + " - Done: to quit" + ) + if "text" in msg and msg["text"].lower() == '/start': + self.send_text(msg['chat']['id'], f"Hello {name}, Welcome to Ameer images bot.\n") + self.send_text(msg['chat']['id'], options) + elif 'text' in msg and msg['text'].lower() == 'done': + self.send_text(msg['chat']['id'], "Good bye, we well be happy to see you again") + else: + try: + is_image = self.is_current_msg_photo(msg) + if is_image: + img = Img(self.download_user_photo(msg)) + filter_option = msg['caption'].strip().split(' ') + if len(filter_option) == 1: + self.send_text(msg['chat']['id'], f'{filter_option[0]}...') + if filter_option == "blur": + img.blur() + elif filter_option == "rotate": + img.rotate() + elif filter_option == "contour": + img.contour() + elif filter_option == 'segment': + img.segment() + elif filter_option == 'concat': + img2_path = self.download_user_photo(msg) + img2 = Img(img2_path) + img.concat(img2) + else: + self.send_text(msg['chat']['id'], "invalid filter") + return + + elif len(filter_option) > 1: + if filter_option[0] == "salt": + self.send_text(msg['chat']['id'], f'{filter_option[0]} {filter_option[1]} ...') + img.salt_n_pepper() + elif filter_option[0] == "rotate": + self.send_text(msg['chat']['id'], f'{filter_option[0]} image{filter_option[1]} times..') + num = int(filter_option[1].strip()) + for i in range(num): + img.rotate() + else: + self.send_text(msg['chat']['id'], "invalid filter") + return + + else: + self.send_text(msg['chat']['id'], "invalid filter") + + return + new_img_path = img.save_img() + self.send_photo(msg['chat']['id'], new_img_path) + else: + self.send_text(msg['chat']['id'], options) + except Exception as e: + logger.error(f'Error: {e}') + self.send_text(msg['chat']['id'], 'something went wrong...\n' + 'please try again\n') From 6ff621bac43da97b1d8326498f79df9419ca2067 Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sun, 19 May 2024 02:02:25 +0300 Subject: [PATCH 08/19] check bot --- polybot/bot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/polybot/bot.py b/polybot/bot.py index 723b764..8769872 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -101,15 +101,15 @@ def handle_message(self, msg): filter_option = msg['caption'].strip().split(' ') if len(filter_option) == 1: self.send_text(msg['chat']['id'], f'{filter_option[0]}...') - if filter_option == "blur": + if filter_option[0] == "blur": img.blur() - elif filter_option == "rotate": + elif filter_option[0] == "rotate": img.rotate() - elif filter_option == "contour": + elif filter_option[0] == "contour": img.contour() - elif filter_option == 'segment': + elif filter_option[0] == 'segment': img.segment() - elif filter_option == 'concat': + elif filter_option[0] == 'concat': img2_path = self.download_user_photo(msg) img2 = Img(img2_path) img.concat(img2) From 0f1af357c8b6c6418f081ae370f9aad9e5815b78 Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sun, 19 May 2024 02:06:16 +0300 Subject: [PATCH 09/19] uppercase and lowercase --- polybot/bot.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/polybot/bot.py b/polybot/bot.py index 8769872..b244c38 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -101,15 +101,15 @@ def handle_message(self, msg): filter_option = msg['caption'].strip().split(' ') if len(filter_option) == 1: self.send_text(msg['chat']['id'], f'{filter_option[0]}...') - if filter_option[0] == "blur": + if filter_option[0].lower() == "blur": img.blur() - elif filter_option[0] == "rotate": + elif filter_option[0].lower() == "rotate": img.rotate() - elif filter_option[0] == "contour": + elif filter_option[0].lower() == "contour": img.contour() - elif filter_option[0] == 'segment': + elif filter_option[0].lower() == 'segment': img.segment() - elif filter_option[0] == 'concat': + elif filter_option[0].lower() == 'concat': img2_path = self.download_user_photo(msg) img2 = Img(img2_path) img.concat(img2) @@ -118,10 +118,10 @@ def handle_message(self, msg): return elif len(filter_option) > 1: - if filter_option[0] == "salt": + if filter_option[0].lower() == "salt": self.send_text(msg['chat']['id'], f'{filter_option[0]} {filter_option[1]} ...') img.salt_n_pepper() - elif filter_option[0] == "rotate": + elif filter_option[0].lower() == "rotate": self.send_text(msg['chat']['id'], f'{filter_option[0]} image{filter_option[1]} times..') num = int(filter_option[1].strip()) for i in range(num): From 47e77bbc27b72001c27de3c4f0d3d074fa3c3569 Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sun, 19 May 2024 02:14:39 +0300 Subject: [PATCH 10/19] format --- polybot/bot.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/polybot/bot.py b/polybot/bot.py index b244c38..700e3c5 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -88,11 +88,12 @@ def handle_message(self, msg): "- Rotate num: Rotates the image in clockwise num times. \n" " - Done: to quit" ) + chat_id = msg['chat']['id'] if "text" in msg and msg["text"].lower() == '/start': - self.send_text(msg['chat']['id'], f"Hello {name}, Welcome to Ameer images bot.\n") - self.send_text(msg['chat']['id'], options) + self.send_text(chat_id, f"Hello {name}, Welcome to Ameer images bot.\n") + self.send_text(chat_id, options) elif 'text' in msg and msg['text'].lower() == 'done': - self.send_text(msg['chat']['id'], "Good bye, we well be happy to see you again") + self.send_text(chat_id, "Good bye, we well be happy to see you again") else: try: is_image = self.is_current_msg_photo(msg) @@ -100,7 +101,7 @@ def handle_message(self, msg): img = Img(self.download_user_photo(msg)) filter_option = msg['caption'].strip().split(' ') if len(filter_option) == 1: - self.send_text(msg['chat']['id'], f'{filter_option[0]}...') + self.send_text(chat_id, f'{filter_option[0]}...') if filter_option[0].lower() == "blur": img.blur() elif filter_option[0].lower() == "rotate": @@ -114,31 +115,29 @@ def handle_message(self, msg): img2 = Img(img2_path) img.concat(img2) else: - self.send_text(msg['chat']['id'], "invalid filter") + self.send_text(chat_id, "invalid filter") return elif len(filter_option) > 1: if filter_option[0].lower() == "salt": - self.send_text(msg['chat']['id'], f'{filter_option[0]} {filter_option[1]} ...') + self.send_text(chat_id, f'{filter_option[0]} {filter_option[1]} ...') img.salt_n_pepper() elif filter_option[0].lower() == "rotate": - self.send_text(msg['chat']['id'], f'{filter_option[0]} image{filter_option[1]} times..') + self.send_text(chat_id, f'{filter_option[0]} image{filter_option[1]} times..') num = int(filter_option[1].strip()) for i in range(num): img.rotate() else: - self.send_text(msg['chat']['id'], "invalid filter") + self.send_text(chat_id, "invalid filter") return else: - self.send_text(msg['chat']['id'], "invalid filter") - + self.send_text(chat_id, "invalid filter") return new_img_path = img.save_img() - self.send_photo(msg['chat']['id'], new_img_path) + self.send_photo(chat_id, new_img_path) else: - self.send_text(msg['chat']['id'], options) + self.send_text(chat_id, options) except Exception as e: logger.error(f'Error: {e}') - self.send_text(msg['chat']['id'], 'something went wrong...\n' - 'please try again\n') + self.send_text(msg['chat']['id'], 'something went wrong, try again...\n') From 8ba944652a5422598f95f422b6cd0e03f971e4e7 Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sun, 19 May 2024 02:24:30 +0300 Subject: [PATCH 11/19] donnnnnneeeeee --- polybot/bot.py | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/polybot/bot.py b/polybot/bot.py index 700e3c5..6ac84c0 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -88,14 +88,15 @@ def handle_message(self, msg): "- Rotate num: Rotates the image in clockwise num times. \n" " - Done: to quit" ) - chat_id = msg['chat']['id'] - if "text" in msg and msg["text"].lower() == '/start': - self.send_text(chat_id, f"Hello {name}, Welcome to Ameer images bot.\n") - self.send_text(chat_id, options) - elif 'text' in msg and msg['text'].lower() == 'done': - self.send_text(chat_id, "Good bye, we well be happy to see you again") - else: - try: + try: + + chat_id = msg['chat']['id'] + if "text" in msg and msg["text"].lower() == '/start': + self.send_text(chat_id, f"Hello {name}, Welcome to Ameer images bot.\n") + self.send_text(chat_id, options) + elif 'text' in msg and msg['text'].lower() == 'done': + self.send_text(chat_id, "Good bye, we well be happy to see you again") + else: is_image = self.is_current_msg_photo(msg) if is_image: img = Img(self.download_user_photo(msg)) @@ -115,7 +116,7 @@ def handle_message(self, msg): img2 = Img(img2_path) img.concat(img2) else: - self.send_text(chat_id, "invalid filter") + self.send_text(chat_id, "Invalid filter") return elif len(filter_option) > 1: @@ -124,20 +125,25 @@ def handle_message(self, msg): img.salt_n_pepper() elif filter_option[0].lower() == "rotate": self.send_text(chat_id, f'{filter_option[0]} image{filter_option[1]} times..') - num = int(filter_option[1].strip()) - for i in range(num): - img.rotate() + try: + num = int(filter_option[1].strip()) + for i in range(num): + img.rotate() + except: + self.send_text(chat_id, "Invalid filter") + return else: - self.send_text(chat_id, "invalid filter") + self.send_text(chat_id, "Invalid filter") return else: self.send_text(chat_id, "invalid filter") return - new_img_path = img.save_img() - self.send_photo(chat_id, new_img_path) + new_path = img.save_img() + self.send_photo(chat_id, new_path) else: self.send_text(chat_id, options) - except Exception as e: - logger.error(f'Error: {e}') - self.send_text(msg['chat']['id'], 'something went wrong, try again...\n') + + except Exception as e: + logger.error(f'Error: {e}') + self.send_text(msg['chat']['id'], 'Something went Wrong, Try Again...\n') From a821c6ccd3e948e748519b68c66bf31bdbe3eba0 Mon Sep 17 00:00:00 2001 From: AmeerBadir Date: Sun, 19 May 2024 02:28:26 +0300 Subject: [PATCH 12/19] syntax --- polybot/bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polybot/bot.py b/polybot/bot.py index 6ac84c0..d604420 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -124,7 +124,7 @@ def handle_message(self, msg): self.send_text(chat_id, f'{filter_option[0]} {filter_option[1]} ...') img.salt_n_pepper() elif filter_option[0].lower() == "rotate": - self.send_text(chat_id, f'{filter_option[0]} image{filter_option[1]} times..') + self.send_text(chat_id, f'{filter_option[0]} image {filter_option[1]} times..') try: num = int(filter_option[1].strip()) for i in range(num): From 369be7f988563bce35e97559eddf8e0d9f46213e Mon Sep 17 00:00:00 2001 From: AmeerBadir <100073193+AmeerBadir@users.noreply.github.com> Date: Tue, 21 May 2024 14:04:21 +0300 Subject: [PATCH 13/19] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index fa90cfd..e8ceda5 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Let's get started... Reference: https://ai.stanford.edu/~syyeung/cvweb/tutorial1.html ### What is a digital image? +##sadsa If we take a closer look on a digital image, we will notice it comprised of individual pixels, From 5314bf6b50f010c4edea472416ce4401950fd861 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Tue, 11 Jun 2024 22:05:54 +0000 Subject: [PATCH 14/19] etaf --- .github/workflows/dev-deploy.yaml | 27 +++++++++++++++++++++++++++ .github/workflows/prod-deploy.yaml | 26 ++++++++++++++++++++++++++ deploy.sh | 6 ++++++ polybot/app.py | 2 +- polybot/bot.py | 4 ++-- 5 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/dev-deploy.yaml create mode 100644 .github/workflows/prod-deploy.yaml create mode 100644 deploy.sh diff --git a/.github/workflows/dev-deploy.yaml b/.github/workflows/dev-deploy.yaml new file mode 100644 index 0000000..eed6eab --- /dev/null +++ b/.github/workflows/dev-deploy.yaml @@ -0,0 +1,27 @@ +# .github/workflows/dev-deploy.yaml +name: Dev Polybot Service Deployment + +on: + push: + branches: + - dev + +env: + EC2_PUBLIC_IP: 34.237.139.140 + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + +jobs: + Deploy: + name: Deploy in EC2 + runs-on: ubuntu-latest + steps: + - name: Checkout the app code + uses: actions/checkout@v2 + - name: SSH to EC2 instance + run: | + echo "$SSH_PRIVATE_KEY" > mykey.pem + chmod 400 mykey.pem + ssh -o StrictHostKeyChecking=accept-new -i mykey.pem ubuntu@$EC2_PUBLIC_IP "cd PolybotServicePythonFursa && bash deploy.sh" + + + diff --git a/.github/workflows/prod-deploy.yaml b/.github/workflows/prod-deploy.yaml new file mode 100644 index 0000000..55b0c13 --- /dev/null +++ b/.github/workflows/prod-deploy.yaml @@ -0,0 +1,26 @@ +# .github/workflows/prod-deploy.yaml +name: Prod Polybot Service Deployment + +on: + push: + branches: + - main + +env: + EC2_PUBLIC_IP: 3.239.187.111 + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} + +jobs: + Deploy: + name: Deploy in EC2 + runs-on: ubuntu-latest + steps: + - name: Checkout the app code + uses: actions/checkout@v2 + - name: SSH to EC2 instance + run: | + echo "$SSH_PRIVATE_KEY" > mykey.pem + chmod 400 mykey.pem + ssh -o StrictHostKeyChecking=accept-new -i mykey.pem ubuntu@$EC2_PUBLIC_IP "cd PolybotServicePythonFursa && bash deploy.sh" + + diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..7a35e40 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +git checkout dev +git pull dev +sudo systemctl daemon-reload +sudo systemctl restart tel.service diff --git a/polybot/app.py b/polybot/app.py index e88600d..ed2ef74 100644 --- a/polybot/app.py +++ b/polybot/app.py @@ -24,4 +24,4 @@ def webhook(): if __name__ == "__main__": bot = ImageProcessingBot(TELEGRAM_TOKEN, TELEGRAM_APP_URL) - app.run(host='0.0.0.0', port=8443) + app.run(host='0.0.0.0', port=8443, ssl_context=('/home/ubuntu/PolybotServicePythonFursa/polybot/YOURPUBLIC.pem', '/home/ubuntu/PolybotServicePythonFursa/polybot/YOURPRIVATE.key')) diff --git a/polybot/bot.py b/polybot/bot.py index d604420..be0360d 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -3,7 +3,7 @@ import os import time from telebot.types import InputFile -from polybot.img_proc import Img +from img_proc import Img class Bot: @@ -18,7 +18,7 @@ def __init__(self, token, telegram_chat_url): time.sleep(0.5) # set the webhook URL - self.telegram_bot_client.set_webhook(url=f'{telegram_chat_url}/{token}/', timeout=60) + self.telegram_bot_client.set_webhook(url=f'{telegram_chat_url}/{token}/',certificate=open('/home/ubuntu/PolybotServicePythonFursa/polybot/YOURPUBLIC.pem', 'r'), timeout=60) logger.info(f'Telegram Bot information\n\n{self.telegram_bot_client.get_me()}') From c61c3e5f710314be6115409efa6ed69b5fb06180 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 12 Jun 2024 15:54:17 +0000 Subject: [PATCH 15/19] sfdsafa --- polybot/bot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/polybot/bot.py b/polybot/bot.py index be0360d..a50e683 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -6,6 +6,7 @@ from img_proc import Img + class Bot: def __init__(self, token, telegram_chat_url): From 375267fb2e7416d14c44e11d66458b9410e71e9b Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 12 Jun 2024 15:57:17 +0000 Subject: [PATCH 16/19] adfasd --- polybot/bot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/polybot/bot.py b/polybot/bot.py index a50e683..ead1887 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -7,6 +7,8 @@ + + class Bot: def __init__(self, token, telegram_chat_url): From b3d67efd13d1b9546fc58419009b197dcacade26 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 12 Jun 2024 16:03:55 +0000 Subject: [PATCH 17/19] update ip --- .github/workflows/dev-deploy.yaml | 2 +- .github/workflows/prod-deploy.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dev-deploy.yaml b/.github/workflows/dev-deploy.yaml index eed6eab..dce3e2e 100644 --- a/.github/workflows/dev-deploy.yaml +++ b/.github/workflows/dev-deploy.yaml @@ -7,7 +7,7 @@ on: - dev env: - EC2_PUBLIC_IP: 34.237.139.140 + EC2_PUBLIC_IP: 3.235.247.204 SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} jobs: diff --git a/.github/workflows/prod-deploy.yaml b/.github/workflows/prod-deploy.yaml index 55b0c13..34fde94 100644 --- a/.github/workflows/prod-deploy.yaml +++ b/.github/workflows/prod-deploy.yaml @@ -7,7 +7,7 @@ on: - main env: - EC2_PUBLIC_IP: 3.239.187.111 + EC2_PUBLIC_IP: 3.232.132.216 SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} jobs: From 5149024557dea3b23b4f5f45fd8917514c124820 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 12 Jun 2024 16:18:14 +0000 Subject: [PATCH 18/19] update url --- polybot/app.py | 2 +- polybot/bot.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/polybot/app.py b/polybot/app.py index ed2ef74..0616470 100644 --- a/polybot/app.py +++ b/polybot/app.py @@ -24,4 +24,4 @@ def webhook(): if __name__ == "__main__": bot = ImageProcessingBot(TELEGRAM_TOKEN, TELEGRAM_APP_URL) - app.run(host='0.0.0.0', port=8443, ssl_context=('/home/ubuntu/PolybotServicePythonFursa/polybot/YOURPUBLIC.pem', '/home/ubuntu/PolybotServicePythonFursa/polybot/YOURPRIVATE.key')) + app.run(host='0.0.0.0', port=8443, ssl_context=('YOURPUBLIC.pem', 'YOURPRIVATE.key')) diff --git a/polybot/bot.py b/polybot/bot.py index ead1887..b0d7090 100644 --- a/polybot/bot.py +++ b/polybot/bot.py @@ -21,7 +21,7 @@ def __init__(self, token, telegram_chat_url): time.sleep(0.5) # set the webhook URL - self.telegram_bot_client.set_webhook(url=f'{telegram_chat_url}/{token}/',certificate=open('/home/ubuntu/PolybotServicePythonFursa/polybot/YOURPUBLIC.pem', 'r'), timeout=60) + self.telegram_bot_client.set_webhook(url=f'{telegram_chat_url}/{token}/',certificate=open('YOURPUBLIC.pem', 'r'), timeout=60) logger.info(f'Telegram Bot information\n\n{self.telegram_bot_client.get_me()}') From 53467f1d1bdad00b20f0c05003237ac951bbf557 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Wed, 12 Jun 2024 16:39:44 +0000 Subject: [PATCH 19/19] sddas --- polybot/app.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/polybot/app.py b/polybot/app.py index 0616470..be1d8ba 100644 --- a/polybot/app.py +++ b/polybot/app.py @@ -14,6 +14,8 @@ def index(): return 'Ok' + + @app.route(f'/{TELEGRAM_TOKEN}/', methods=['POST']) def webhook(): req = request.get_json()