From 6bb7125cb8e08800e6993553db11f796ce224dd4 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Wed, 4 Oct 2023 20:11:16 +0000 Subject: [PATCH 01/11] Fix code style issues with Black --- projects/AudioAPI/transcription.py | 52 ++++++++----- projects/MovieApi_and_ML/movieapi/api/apps.py | 4 +- .../MovieApi_and_ML/movieapi/api/predict.py | 14 ++-- projects/MovieApi_and_ML/movieapi/api/urls.py | 8 +- .../MovieApi_and_ML/movieapi/api/views.py | 36 ++++----- projects/MovieApi_and_ML/movieapi/manage.py | 4 +- .../MovieApi_and_ML/movieapi/movieapi/asgi.py | 2 +- .../movieapi/movieapi/settings.py | 74 +++++++++---------- .../MovieApi_and_ML/movieapi/movieapi/urls.py | 5 +- .../MovieApi_and_ML/movieapi/movieapi/wsgi.py | 2 +- projects/Tile Matching/tile_matching.py | 31 ++++++-- projects/movie-rater/main.py | 18 ++--- 12 files changed, 140 insertions(+), 110 deletions(-) diff --git a/projects/AudioAPI/transcription.py b/projects/AudioAPI/transcription.py index fe5b9a0e6..6c254b7c3 100644 --- a/projects/AudioAPI/transcription.py +++ b/projects/AudioAPI/transcription.py @@ -6,36 +6,40 @@ app = Flask(__name__) -@app.route('/transcribe', methods=['POST']) + +@app.route("/transcribe", methods=["POST"]) def transcribe(): # check if the post request has the file part - if 'audio' not in request.files: - return jsonify({'error': 'No audio file found.'}), 400 + if "audio" not in request.files: + return jsonify({"error": "No audio file found."}), 400 - file = request.files['audio'] + file = request.files["audio"] - if file.filename == '': - return jsonify({'error': 'No audio file selected.'}), 400 + if file.filename == "": + return jsonify({"error": "No audio file selected."}), 400 if not allowed_file(file.filename): - return jsonify({'error': 'Only WAV, MP3, and OGG audio files are allowed.'}), 400 + return ( + jsonify({"error": "Only WAV, MP3, and OGG audio files are allowed."}), + 400, + ) filename = secure_filename(file.filename) file.save(filename) - model = whisper.load_model("small") # Change this to your desired model + model = whisper.load_model("small") # Change this to your desired model print("Whisper model loaded.") transcribe = model.transcribe(audio=filename) - segments = transcribe['segments'] + segments = transcribe["segments"] - srt_file = open('subtitles.vtt', 'w', encoding='utf-8') - srt_file.write('WEBVTT\n\n') + srt_file = open("subtitles.vtt", "w", encoding="utf-8") + srt_file.write("WEBVTT\n\n") for segment in segments: - startTime = str(0)+str(timedelta(seconds=int(segment['start'])))+'.000' - endTime = str(0)+str(timedelta(seconds=int(segment['end'])))+'.000' - text = segment['text'] - segmentId = segment['id']+1 + startTime = str(0) + str(timedelta(seconds=int(segment["start"]))) + ".000" + endTime = str(0) + str(timedelta(seconds=int(segment["end"]))) + ".000" + text = segment["text"] + segmentId = segment["id"] + 1 segment = f"{segmentId}\n{startTime} --> {endTime}\n{text[1:] if text[0] == ' ' else text}\n\n" srt_file.write(segment) @@ -43,11 +47,21 @@ def transcribe(): srt_file.close() os.remove(filename) - return send_file('subtitles.vtt', as_attachment=True, download_name='subtitles.vtt', mimetype='text/vtt') + return send_file( + "subtitles.vtt", + as_attachment=True, + download_name="subtitles.vtt", + mimetype="text/vtt", + ) + def allowed_file(filename): - return '.' in filename and \ - filename.rsplit('.', 1)[1].lower() in ['wav', 'mp3', 'ogg'] + return "." in filename and filename.rsplit(".", 1)[1].lower() in [ + "wav", + "mp3", + "ogg", + ] + -if __name__ == '__main__': +if __name__ == "__main__": app.run() diff --git a/projects/MovieApi_and_ML/movieapi/api/apps.py b/projects/MovieApi_and_ML/movieapi/api/apps.py index 8e0045c0d..ae9f89424 100644 --- a/projects/MovieApi_and_ML/movieapi/api/apps.py +++ b/projects/MovieApi_and_ML/movieapi/api/apps.py @@ -2,5 +2,5 @@ class ApiConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'api' + default_auto_field = "django.db.models.BigAutoField" + name = "api" diff --git a/projects/MovieApi_and_ML/movieapi/api/predict.py b/projects/MovieApi_and_ML/movieapi/api/predict.py index 8f0a4bcb5..7a721f0c4 100644 --- a/projects/MovieApi_and_ML/movieapi/api/predict.py +++ b/projects/MovieApi_and_ML/movieapi/api/predict.py @@ -4,17 +4,18 @@ from sklearn.feature_extraction.text import CountVectorizer from sklearn.metrics.pairwise import cosine_similarity -df1 = pd.read_csv(r'tmdb-movie-metadata\tmdb_5000_movies.csv') +df1 = pd.read_csv(r"tmdb-movie-metadata\tmdb_5000_movies.csv") -count = CountVectorizer(stop_words='english') -df1['overview'] = df1['overview'].fillna('') -count_matrix = count.fit_transform(df1['overview']) +count = CountVectorizer(stop_words="english") +df1["overview"] = df1["overview"].fillna("") +count_matrix = count.fit_transform(df1["overview"]) cosine_similarity_count = cosine_similarity(count_matrix, count_matrix) -indices = pd.Series(df1.index, index =df1['title']).drop_duplicates() +indices = pd.Series(df1.index, index=df1["title"]).drop_duplicates() + # Using TFIDF def get_recommendations(title, cosine_sim=cosine_similarity_count): @@ -32,9 +33,8 @@ def get_recommendations(title, cosine_sim=cosine_similarity_count): sim_scores = sim_scores[1:2] # Adjust this number as needed # Get the titles of the recommended movies - recommended_movies = recommended_movies = df1['title'].iloc[sim_scores[0][0]] + recommended_movies = recommended_movies = df1["title"].iloc[sim_scores[0][0]] return recommended_movies except KeyError: return "Sorry, we don't have enough data about this movie title." - diff --git a/projects/MovieApi_and_ML/movieapi/api/urls.py b/projects/MovieApi_and_ML/movieapi/api/urls.py index 155ebe943..dd49b77ff 100644 --- a/projects/MovieApi_and_ML/movieapi/api/urls.py +++ b/projects/MovieApi_and_ML/movieapi/api/urls.py @@ -1,6 +1,8 @@ from django.contrib import admin from django.urls import path, include from . import views -urlpatterns = [path('', view=views.movie, name='movie'), - path('predict/', view=views.predict, name='predict'), - ] + +urlpatterns = [ + path("", view=views.movie, name="movie"), + path("predict/", view=views.predict, name="predict"), +] diff --git a/projects/MovieApi_and_ML/movieapi/api/views.py b/projects/MovieApi_and_ML/movieapi/api/views.py index 1834cb7d6..8e8fcad15 100644 --- a/projects/MovieApi_and_ML/movieapi/api/views.py +++ b/projects/MovieApi_and_ML/movieapi/api/views.py @@ -3,48 +3,50 @@ import os from .predict import get_recommendations from dotenv import load_dotenv + load_dotenv() -RapidAPIKey = os.getenv('X-RapidAPI-Key') +RapidAPIKey = os.getenv("X-RapidAPI-Key") + + # Create your views here. def movie(request): url = "https://online-movie-database.p.rapidapi.com/title/find" - querystring = {"q":"Iron man"} + querystring = {"q": "Iron man"} Obs = [] image_urls = [] actor_names = [] - headers = { "X-RapidAPI-Key": RapidAPIKey, - "X-RapidAPI-Host": "online-movie-database.p.rapidapi.com" + "X-RapidAPI-Host": "online-movie-database.p.rapidapi.com", } response = requests.get(url, headers=headers, params=querystring) - + if response.status_code == 200: data = response.json() results = data.get("results", [])[0:5] for i in range(5): - Ob = results[i]['title'] - image_url = results[i]['image']['url'] - actor_name = results[i]['principals'][0]['name'] + Ob = results[i]["title"] + image_url = results[i]["image"]["url"] + actor_name = results[i]["principals"][0]["name"] Obs.append(Ob) image_urls.append(image_url) actor_names.append(actor_name) context = { "title": Obs, - "poster":image_urls, - "actor_name":actor_names, + "poster": image_urls, + "actor_name": actor_names, } - return render(request, 'index.html', context) + return render(request, "index.html", context) + + def predict(request): predict = None - if request.method == 'POST': - title = request.POST.get('title') + if request.method == "POST": + title = request.POST.get("title") predict = get_recommendations(title) - context = { - 'predict1':predict - } - return render(request, 'predict.html', context) \ No newline at end of file + context = {"predict1": predict} + return render(request, "predict.html", context) diff --git a/projects/MovieApi_and_ML/movieapi/manage.py b/projects/MovieApi_and_ML/movieapi/manage.py index 5a4c67c2a..fbea46d32 100644 --- a/projects/MovieApi_and_ML/movieapi/manage.py +++ b/projects/MovieApi_and_ML/movieapi/manage.py @@ -6,7 +6,7 @@ def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'movieapi.settings') + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "movieapi.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: @@ -18,5 +18,5 @@ def main(): execute_from_command_line(sys.argv) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/projects/MovieApi_and_ML/movieapi/movieapi/asgi.py b/projects/MovieApi_and_ML/movieapi/movieapi/asgi.py index a52e10970..83453ed4b 100644 --- a/projects/MovieApi_and_ML/movieapi/movieapi/asgi.py +++ b/projects/MovieApi_and_ML/movieapi/movieapi/asgi.py @@ -11,6 +11,6 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'movieapi.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "movieapi.settings") application = get_asgi_application() diff --git a/projects/MovieApi_and_ML/movieapi/movieapi/settings.py b/projects/MovieApi_and_ML/movieapi/movieapi/settings.py index bf348bf19..83f805d35 100644 --- a/projects/MovieApi_and_ML/movieapi/movieapi/settings.py +++ b/projects/MovieApi_and_ML/movieapi/movieapi/settings.py @@ -20,7 +20,7 @@ # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = 'django-insecure-+b$m6xr@2au^d-qsmcr3yys--2p+)*a%3+!8-z+s&s2_sn9oi8' +SECRET_KEY = "django-insecure-+b$m6xr@2au^d-qsmcr3yys--2p+)*a%3+!8-z+s&s2_sn9oi8" # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True @@ -31,53 +31,53 @@ # Application definition INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'api', + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "api", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", ] -ROOT_URLCONF = 'movieapi.urls' +ROOT_URLCONF = "movieapi.urls" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [BASE_DIR/'templates'], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": [BASE_DIR / "templates"], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", ], }, }, ] -WSGI_APPLICATION = 'movieapi.wsgi.application' +WSGI_APPLICATION = "movieapi.wsgi.application" # Database # https://docs.djangoproject.com/en/4.2/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': BASE_DIR / 'db.sqlite3', + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": BASE_DIR / "db.sqlite3", } } @@ -87,16 +87,16 @@ AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] @@ -104,9 +104,9 @@ # Internationalization # https://docs.djangoproject.com/en/4.2/topics/i18n/ -LANGUAGE_CODE = 'en-us' +LANGUAGE_CODE = "en-us" -TIME_ZONE = 'UTC' +TIME_ZONE = "UTC" USE_I18N = True @@ -116,9 +116,9 @@ # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/4.2/howto/static-files/ -STATIC_URL = 'static/' +STATIC_URL = "static/" # Default primary key field type # https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field -DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" diff --git a/projects/MovieApi_and_ML/movieapi/movieapi/urls.py b/projects/MovieApi_and_ML/movieapi/movieapi/urls.py index 469b6e4cb..6c7ad0fe8 100644 --- a/projects/MovieApi_and_ML/movieapi/movieapi/urls.py +++ b/projects/MovieApi_and_ML/movieapi/movieapi/urls.py @@ -17,7 +17,4 @@ from django.contrib import admin from django.urls import path, include -urlpatterns = [ - path('admin/', admin.site.urls), - path('', include('api.urls')) -] +urlpatterns = [path("admin/", admin.site.urls), path("", include("api.urls"))] diff --git a/projects/MovieApi_and_ML/movieapi/movieapi/wsgi.py b/projects/MovieApi_and_ML/movieapi/movieapi/wsgi.py index 7f910062f..4434bc593 100644 --- a/projects/MovieApi_and_ML/movieapi/movieapi/wsgi.py +++ b/projects/MovieApi_and_ML/movieapi/movieapi/wsgi.py @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'movieapi.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "movieapi.settings") application = get_wsgi_application() diff --git a/projects/Tile Matching/tile_matching.py b/projects/Tile Matching/tile_matching.py index 7e2d09885..ed2cc6122 100644 --- a/projects/Tile Matching/tile_matching.py +++ b/projects/Tile Matching/tile_matching.py @@ -1,6 +1,7 @@ import tkinter as tk import random -from tkinter import messagebox #Import the messagebox module +from tkinter import messagebox # Import the messagebox module + class TileMatchingGame: def __init__(self, root, rows, columns): @@ -17,7 +18,16 @@ def __init__(self, root, rows, columns): self.create_timer(60) def create_board(self): - all_colors = ["salmon","lightblue", "azure", "darkblue", "orange", "purple", "pink", "brown"] + all_colors = [ + "salmon", + "lightblue", + "azure", + "darkblue", + "orange", + "purple", + "pink", + "brown", + ] colors = random.sample(all_colors, self.rows * self.columns // 2) colors *= 2 # Duplicate colors to have pairs random.shuffle(colors) @@ -68,7 +78,9 @@ def tile_clicked(self, event): tile = event.widget row, col = self.get_tile_position(tile) if (row, col) not in self.selected_tiles and len(self.selected_tiles) < 2: - tile.config(text="X", bg=self.tile_colors[row * self.columns + col]) # Reveal the color when clicked + tile.config( + text="X", bg=self.tile_colors[row * self.columns + col] + ) # Reveal the color when clicked self.selected_tiles.append((row, col)) if len(self.selected_tiles) == 2: @@ -81,7 +93,10 @@ def check_matching_tiles(self): if len(self.selected_tiles) == 2: tile1 = self.selected_tiles[0] tile2 = self.selected_tiles[1] - if self.tile_colors[tile1[0] * self.columns + tile1[1]] == self.tile_colors[tile2[0] * self.columns + tile2[1]]: + if ( + self.tile_colors[tile1[0] * self.columns + tile1[1]] + == self.tile_colors[tile2[0] * self.columns + tile2[1]] + ): self.score += 1 self.score_label.config(text=f"Score: {self.score}") if self.score == self.rows * self.columns // 2: @@ -103,19 +118,21 @@ def get_tile_position(self, tile): col = row_tiles.index(tile) return row, col + def main(): root = tk.Tk() root.title("Tile Matching Game") - + rows, columns = 4, 4 - + game = TileMatchingGame(root, rows, columns) # Exit Button exit_button = tk.Button(root, text="Exit", command=root.destroy) exit_button.grid(row=rows + 3, columnspan=columns) - + root.mainloop() + if __name__ == "__main__": main() diff --git a/projects/movie-rater/main.py b/projects/movie-rater/main.py index 8bfd1a649..429d57e02 100644 --- a/projects/movie-rater/main.py +++ b/projects/movie-rater/main.py @@ -1,4 +1,3 @@ - from fastapi import FastAPI, HTTPException from dotenv import load_dotenv import os @@ -7,21 +6,19 @@ load_dotenv() -app= FastAPI ( - +app = FastAPI( title="MOVIE RATER API", description="The MovieRater API is your gateway to a world of cinematic exploration and user-generated movie ratings. This versatile API empowers developers to create dynamic movie-related applications, allowing users to rate, review, and discover films from a vast collection.", - docs_url="/" + docs_url="/", ) -apiKey=os.getenv("API_KEY") -apiToken=os.getenv("API_TOKEN") - +apiKey = os.getenv("API_KEY") +apiToken = os.getenv("API_TOKEN") @app.get("/movies") async def get_popular_movies(): - url=f"https://api.themoviedb.org/3/discover/movie?api_key={apiKey}&sort_by=popularity.desc" - + url = f"https://api.themoviedb.org/3/discover/movie?api_key={apiKey}&sort_by=popularity.desc" + response = requests.get(url) if response.status_code != 200: raise HTTPException(status_code=response.status_code, detail=response.content) @@ -30,6 +27,7 @@ async def get_popular_movies(): return movie_data + @app.get("/movies/{movie_id}") async def get_movie(movie_id: int): """Get information about a movie.""" @@ -44,6 +42,7 @@ async def get_movie(movie_id: int): return movie_data + @app.post("/movies/{movie_id}/rate") async def rate_movie(movie_id: int, rating: int): """Rate a movie.""" @@ -56,4 +55,3 @@ async def rate_movie(movie_id: int, rating: int): # Return a success response. return {"message": "Movie rated successfully."} - From cde4b77a275cd926f63b527ee08a603388356743 Mon Sep 17 00:00:00 2001 From: Bhanushri Chinta <110604493+bhanushri123@users.noreply.github.com> Date: Mon, 6 Nov 2023 05:43:44 +0530 Subject: [PATCH 02/11] Update AES256.py ERRORHANDLING Adding key value errrors --- projects/AES256/AES256.py | 91 +++++++++++++++++++-------------------- 1 file changed, 44 insertions(+), 47 deletions(-) diff --git a/projects/AES256/AES256.py b/projects/AES256/AES256.py index 6c0836d59..90efe2912 100644 --- a/projects/AES256/AES256.py +++ b/projects/AES256/AES256.py @@ -1,5 +1,3 @@ -# AES 256 Encryption/Decryption Using pycryptodome Library - # Imports import hashlib from base64 import b64encode, b64decode @@ -8,7 +6,7 @@ from Cryptodome.Random import get_random_bytes import platform -# For different OS +# Clear the console screen if platform.system() == "Windows": os.system("cls") else: @@ -17,18 +15,12 @@ # Start of Encryption Function def encrypt(plain_text, password): - # generate a random salt - salt = get_random_bytes(AES.block_size) - - # use the Scrypt KDF to get a private key from the password - private_key = hashlib.scrypt( - password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32 - ) + if not password: + raise ValueError("Password cannot be empty.") - # create cipher config + salt = get_random_bytes(AES.block_size) + private_key = hashlib.scrypt(password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32) cipher_config = AES.new(private_key, AES.MODE_GCM) - - # return a dictionary with the encrypted text cipher_text, tag = cipher_config.encrypt_and_digest(bytes(plain_text, "utf-8")) return { "cipher_text": b64encode(cipher_text).decode("utf-8"), @@ -40,48 +32,53 @@ def encrypt(plain_text, password): # Start of Decryption Function def decrypt(enc_dict, password): - # decode the dictionary entries from base64 - salt = b64decode(enc_dict["salt"]) - cipher_text = b64decode(enc_dict["cipher_text"]) - nonce = b64decode(enc_dict["nonce"]) - tag = b64decode(enc_dict["tag"]) - - # generate the private key from the password and salt - private_key = hashlib.scrypt( - password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32 - ) - - # create the cipher config - cipher = AES.new(private_key, AES.MODE_GCM, nonce=nonce) - - # decrypt the cipher text - decrypted = cipher.decrypt_and_verify(cipher_text, tag) - - return decrypted + if not password: + raise ValueError("Password cannot be empty.") + + try: + salt = b64decode(enc_dict["salt"]) + cipher_text = b64decode(enc_dict["cipher_text"]) + nonce = b64decode(enc_dict["nonce"]) + tag = b64decode(enc_dict["tag"]) + private_key = hashlib.scrypt(password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32) + cipher = AES.new(private_key, AES.MODE_GCM, nonce=nonce) + decrypted = cipher.decrypt_and_verify(cipher_text, tag) + return decrypted.decode("utf-8") + except (ValueError, KeyError) as e: + raise ValueError("Invalid encrypted message format.") from e def main(): print("\t\tAES 256 Encryption and Decryption Algorithm") print("\t\t-------------------------------------------\n\n") - x = input("Enter 1 to encrypt and 2 to decrypt :") - if x == 1: + x = input("Enter 1 to encrypt and 2 to decrypt: ") + if x == '1': password = input("Enter the Password: ") secret_mssg = input("\nEnter the Secret Message: ") - # First let us encrypt secret message + # First, let us encrypt the secret message encrypted = encrypt(secret_mssg, password) print("\n\nEncrypted:") print("---------------\n") - print("\n".join("{}: {}".format(k, v) for k, v in encrypted.items())) - - # Now let us decrypt the message using our original password - if x == 2: - encrypted = input("Enter the encrypted message") - password = input("Enter the password") - decrypted = decrypt(encrypted, password) - print("\n\nDecrypted:") - print("-----------------\n") - print(bytes.decode(decrypted)) - - -main() + for k, v in encrypted.items(): + print(f"{k}: {v}") + + elif x == '2': + try: + encrypted = {} + encrypted["cipher_text"] = input("Enter the cipher text: ") + encrypted["salt"] = input("Enter the salt: ") + encrypted["nonce"] = input("Enter the nonce: ") + encrypted["tag"] = input("Enter the tag: ") + password = input("Enter the password: ") + + decrypted = decrypt(encrypted, password) + print("\n\nDecrypted:") + print("-----------------\n") + print(decrypted) + except ValueError as e: + print(f"Error: {e}") + + +if __name__ == "__main__": + main() From 7fa47e31abb28881a8f64c0578dd77a4aa32f9dd Mon Sep 17 00:00:00 2001 From: Lint Action Date: Wed, 8 Nov 2023 07:23:58 +0000 Subject: [PATCH 03/11] Fix code style issues with Black --- projects/AES256/AES256.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/AES256/AES256.py b/projects/AES256/AES256.py index 90efe2912..ffa635bcc 100644 --- a/projects/AES256/AES256.py +++ b/projects/AES256/AES256.py @@ -19,7 +19,9 @@ def encrypt(plain_text, password): raise ValueError("Password cannot be empty.") salt = get_random_bytes(AES.block_size) - private_key = hashlib.scrypt(password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32) + private_key = hashlib.scrypt( + password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32 + ) cipher_config = AES.new(private_key, AES.MODE_GCM) cipher_text, tag = cipher_config.encrypt_and_digest(bytes(plain_text, "utf-8")) return { @@ -40,7 +42,9 @@ def decrypt(enc_dict, password): cipher_text = b64decode(enc_dict["cipher_text"]) nonce = b64decode(enc_dict["nonce"]) tag = b64decode(enc_dict["tag"]) - private_key = hashlib.scrypt(password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32) + private_key = hashlib.scrypt( + password.encode(), salt=salt, n=2**14, r=8, p=1, dklen=32 + ) cipher = AES.new(private_key, AES.MODE_GCM, nonce=nonce) decrypted = cipher.decrypt_and_verify(cipher_text, tag) return decrypted.decode("utf-8") @@ -52,7 +56,7 @@ def main(): print("\t\tAES 256 Encryption and Decryption Algorithm") print("\t\t-------------------------------------------\n\n") x = input("Enter 1 to encrypt and 2 to decrypt: ") - if x == '1': + if x == "1": password = input("Enter the Password: ") secret_mssg = input("\nEnter the Secret Message: ") @@ -63,7 +67,7 @@ def main(): for k, v in encrypted.items(): print(f"{k}: {v}") - elif x == '2': + elif x == "2": try: encrypted = {} encrypted["cipher_text"] = input("Enter the cipher text: ") From 065230c3aa3dfc296e045adeb3ffc45239d0bc7d Mon Sep 17 00:00:00 2001 From: SangayThinley <20095373@tafe.wa.edu.au> Date: Sat, 9 Dec 2023 23:25:07 +0800 Subject: [PATCH 04/11] refactor(Calendar):variable name change --- .gitignore | 3 ++- projects/Calendar/displayCalendar.py | 10 +++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 1e0fbcd5b..1ae708dbc 100644 --- a/.gitignore +++ b/.gitignore @@ -152,4 +152,5 @@ dmypy.json # Cython debug symbols cython_debug/ -*.db \ No newline at end of file +*.db +.idea/ \ No newline at end of file diff --git a/projects/Calendar/displayCalendar.py b/projects/Calendar/displayCalendar.py index 05d6e6a61..d5f9e632c 100644 --- a/projects/Calendar/displayCalendar.py +++ b/projects/Calendar/displayCalendar.py @@ -1,13 +1,13 @@ # Program to display calendar -def display_calendar(y, m): +def display_calendar(year, month): import calendar - print(calendar.month(y, m)) + print(calendar.month(year, month)) -y = int(input("Enter year: ")) -m = int(input("Enter month: ")) +year = int(input("Enter year: ")) +month = int(input("Enter month: ")) -display_calendar(y, m) +display_calendar(year, month) From b0f7aa64f0fc0e99dfb5144531326b83c8ccd293 Mon Sep 17 00:00:00 2001 From: mmakrin <115393688+mmakrin@users.noreply.github.com> Date: Tue, 12 Dec 2023 16:56:58 +0200 Subject: [PATCH 05/11] Update guess_number.py i think that its a nice idea to count the times the user tried to find the right number --- projects/Guess Number/guess_number.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/projects/Guess Number/guess_number.py b/projects/Guess Number/guess_number.py index 7882a90a9..b1b344b60 100644 --- a/projects/Guess Number/guess_number.py +++ b/projects/Guess Number/guess_number.py @@ -5,6 +5,7 @@ larger_number = 10 upper_limit = 10 lower_limit = 1 +num_of_guesses=0 # function to prompt user for input. will continue to ask user for proper int if invalid num passed @@ -35,13 +36,16 @@ def guess(num, user_guess): print(f"\nNumber is higher than {user_guess}") lower_limit = user_guess user_guess = enter_and_verification(lower_limit + 1, upper_limit) + num_of_guesses++ elif num < user_guess: print(f"\nNumber is lower than {user_guess}") upper_limit = user_guess user_guess = enter_and_verification(lower_limit, upper_limit - 1) + num_of_guesses++ else: print() print(f"\nCongrats! You've guessed the correct number! It was {num}.\n") + print("\nYou have tried {num_of_guesses} times to find the number.\n") # while loop to prompt user to play intially, then continue to play or not From ce0077a29c2b3996c012f82958ee2ef645519ae6 Mon Sep 17 00:00:00 2001 From: Sergey18273 <153006768+Sergey18273@users.noreply.github.com> Date: Thu, 14 Dec 2023 19:00:15 +0500 Subject: [PATCH 06/11] Update to_do_list.py I transferred the functions to the telegram bot. --- projects/ToDoList/to_do_list.py | 155 +++++++++++++++----------------- 1 file changed, 71 insertions(+), 84 deletions(-) diff --git a/projects/ToDoList/to_do_list.py b/projects/ToDoList/to_do_list.py index bae85a8d7..4603e9f16 100644 --- a/projects/ToDoList/to_do_list.py +++ b/projects/ToDoList/to_do_list.py @@ -1,85 +1,72 @@ -from pickle import dump, load - - -def add_task(task): - todo_list.append(task) - print("Task added!") - - -def remove_task(task_num): - if 0 <= task_num < len(todo_list): - del todo_list[task_num] - print("Task removed!") +import telebot +from telebot import types + +bot = telebot.TeleBot('6540560961:AAEuobp6IGekPHPwSDxbxEEgI9LbPvYRgEc') + + +@bot.message_handler(commands=['start']) +def start(message): + keyboard = types.ReplyKeyboardMarkup() + note = types.KeyboardButton('Добавить заметку') + deletenote = types.KeyboardButton('Удалить заметку') + editnote = types.KeyboardButton('Изменить заметку') + event = types.KeyboardButton('Добавить событие') + deletevent = types.KeyboardButton('Удалить событие') + editevent = types.KeyboardButton('Изменить событие') + check = types.KeyboardButton('Открыть текущие заметки/события') + keyboard.add(note, deletenote, editnote, event, deletevent, editevent, check) + bot.send_message(message.chat.id, f'{message.from_user.first_name}, я так рад, что вы снова сдесь! \U0001F601 \nВыберите, что бы вы хотели сделать:', parse_mode='html', reply_markup=keyboard) + +@bot.message_handler(func=lambda message: True) +def handle_button_click(message): + if (message.text.lower() == 'добавить заметку') or (message.text.lower() == '/addn'): + addn(message) + elif (message.text.lower() == 'добавить событие') or (message.text.lower() == '/adde'): + adde(message) + elif (message.text.lower() == 'удалить заметку') or (message.text.lower() == '/deleten'): + deleten(message) + elif (message.text.lower() == 'удалить событие') or (message.text.lower() == '/deletev'): + deletev(message) + elif (message.text.lower() == 'изменить заметку') or (message.text.lower() == '/editn'): + editn(message) + elif (message.text.lower() == 'изменить событие') or (message.text.lower() == '/edite'): + edite(message) + elif (message.text.lower() == 'открыть текущие заметки/события') or (message.text.lower() == '/check'): + check(message) + elif message.text == '/help': + bot.send_message(message.chat.id, 'С моей помощью вы легко сможете:\n\n' + '1) Добавить для себя любую заметку коммандой - | /addn |\n\n' + '2) Создать событие с напоминанием коммандой - | /adde |\n\n' + '3) Удалить любую заметку коммандой - | /deleten |\n\n' + '4) Удалить любое событие коммандой - | /deletev |\n\n' + '5) Изменить любую заметку коммандой - | /editn |\n\n' + '6) Изменить любое событие коммандой - | /edite |\n\n' + '7) Просматривать все свои заметки коммандой - | /check |\n\n', + parse_mode='html') + elif message.text.isalpha(): + bot.send_message(message.chat.id, + 'Извини, но я не воспринимаю текст \U0001F972, тебе следует попробовать комманды!\n' + 'Чтобы узнать, что я умею, введи комманду - | /help |') + elif message.text.isdigit(): + bot.send_message(message.chat.id, + 'Извини, но я не воспринимаю цифры/числа \U0001F972, тебе следует попробовать комманды!\n' + 'Чтобы узнать, что я умею, введи комманду - | /help |') else: - print("Invalid task number!") - - -def display_tasks(): - if not todo_list: # If list is empty - print("No tasks to display.") - else: - for index, task in enumerate(todo_list, start=1): - print(f"{index}. {task}") - - -def get_choice(): - while True: - try: - choice = int( - input( - "Type a number: 1. Adding a task, 2. Removing a task, 3. Displaying tasks, 4. Quit: " - ) - ) - if 1 <= choice <= 4: - return choice - else: - print("Invalid choice. Try again.") - except ValueError: - print("Please enter a number between 1 and 4.") - - -if __name__ == "__main__": - # Loading the pickle file into python as a list - try: - with open("todo.pickle", "rb+") as file_in: - todo_list = load(file_in) - except FileNotFoundError: - todo_list = [] - - print("Welcome to ToDo List!") - - while True: - user_choice = get_choice() - - # Adding a task - if user_choice == 1: - new_task = input("Type a new task: ") - add_task(new_task) - - # Removing a task - elif user_choice == 2: - if not todo_list: # If list is empty - print("No tasks to remove.") - else: - task_num = int(input("Enter the task number to delete: ")) - 1 - remove_task(task_num) - - # Displaying tasks - elif user_choice == 3: - display_tasks() - - # Quit - elif user_choice == 4: - # Dumping the list into a pickle file - with open("todo.pickle", "wb") as file_out: - dump(todo_list, file_out) - print("Goodbye!") - break - - -##################################### - -# CODE CONTRIBUTED BY: Ota Hina -# Dynamic funcionality added by : komsenapati - -##################################### + bot.send_message(message.chat.id, 'Извини, но я воспринимаю только комманды \U0001F972\n' + 'Чтобы узнать, что я умею, введи комманду - | /help |') +def addn(message): + bot.send_message(message.chat.id, 'Вы создали заметку') +def adde(message): + bot.send_message(message.chat.id, 'Вы создали событие') +def deleten(message): + bot.send_message(message.chat.id, 'Вы хотите удалить заметку') +def deletev(message): + bot.send_message(message.chat.id, 'Вы удалили событие') +def editn(message): + bot.send_message(message.chat.id, 'Вы хотите изменить заметку') +def edite(message): + bot.send_message(message.chat.id, 'Вы хотите изменить событие') +def check(message): + bot.send_message(message.chat.id, 'Вы хотите посмотреть список заметок/событий') + +bot.polling(none_stop=True) From 6cb478bf1ac3386dac1a024bdd4e3f220a8be41b Mon Sep 17 00:00:00 2001 From: Carl283583 Date: Wed, 20 Dec 2023 17:40:21 +0000 Subject: [PATCH 07/11] From new-branch-blackjack --- projects/BlackJack/black_jack.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/projects/BlackJack/black_jack.py b/projects/BlackJack/black_jack.py index 8dfbc5f53..bd475ed61 100644 --- a/projects/BlackJack/black_jack.py +++ b/projects/BlackJack/black_jack.py @@ -114,7 +114,7 @@ def check_ace(card): BlackJack means 21. Whoever gets a total value of 21 with their cards immediately wins! (winning through blackjack results in 3x the money) -If the value of cards goes over 21, its called a BUST, which results in immediate loss... +If the value of cards goes over 21, it's called a BUST, which results in an immediate loss... If both the players get the same value of cards , it's a TIE and the bet money is returned. If none of the above cases are met ,the person with closer value to 21 wins. @@ -138,6 +138,8 @@ def check_ace(card): if bet > chips: print("You dont have enough chips.") print("Enter a valid amount. \n") + elif bet <= 0: #To prevent betting a negative value + print("Invalid Bet") else: chips -= bet break @@ -282,9 +284,12 @@ def check_ace(card): break else: + + cont = input("Do you want to continue? (y/n) :") + check= cont.upper()###So a capital or lowercase value can be entered - if cont == "y": + if check == "Y": print("\n" * 100) print( @@ -304,7 +309,9 @@ def check_ace(card): print(input("Press Enter to exit the terminal...")) break + + except Exception as error: print(f"Following error occurred : {error} \nPlease try again.") game_num -= 1 # round with error won't be counted - continue + continue \ No newline at end of file From 229c6b9bdab67ca1d81919873fb6fc397cf3797e Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 06:18:26 +0000 Subject: [PATCH 08/11] contrib-readme-action has updated readme --- README.md | 209 +++++++++++++++++++++++++++++------------------------- 1 file changed, 112 insertions(+), 97 deletions(-) diff --git a/README.md b/README.md index 54d7c5e7b..bcdf9ed09 100644 --- a/README.md +++ b/README.md @@ -874,14 +874,21 @@ Tyler-Pear + + + Gabriela20103967 +
+ Gabriela20103967 +
+ + bim22614
Bim22614
- - + jrbublitz @@ -916,15 +923,15 @@
Nayan Chandak
- + + DevTomilola-OS
Oluwatomilola
- - + herepete @@ -959,15 +966,15 @@
Kartik Nandagaon
- + + SirRomey
SirRomey
- - + ZackeryRSmith @@ -1002,15 +1009,15 @@
Harry830
- + + MrB141107
Mr.B
- - + EFFLUX110 @@ -1045,15 +1052,15 @@
Yash Parwal
- + + Zedeldi
Zack Didcott
- - + asingh4451 @@ -1088,15 +1095,15 @@
Adrija
- + + advik-student-dev
Advik Sharma
- - + tamojeetK @@ -1131,15 +1138,15 @@
Soonam Kalyan Panda
- + + Logadheep
Logadheep
- - + MattBlodgettProjects @@ -1174,15 +1181,15 @@
Rajdeep Das
- + + ShivaNagachander
SHIVA NC
- - + shashaaankkkkk @@ -1217,15 +1224,15 @@
Ota Hina
- + + parth-verma7
Parth Verma
- - + sirKiraUzumaki @@ -1260,15 +1267,15 @@
Chirag Aggarwal
- + + kom-senapati
Kom Senapati
- - + u749929 @@ -1303,15 +1310,15 @@
Akarsh Bajpai
- + + blindaks
Akrati Verma
- - + amoghak-ds @@ -1346,15 +1353,15 @@
CJ Praveen
- + + iamdestinychild
Destiny
- - + Devparihar5 @@ -1389,15 +1396,15 @@
Govind S Nair
- + + ducheharsh
Harsh Mahadev Duche
- - + HridayAg0102 @@ -1405,6 +1412,13 @@ Hriday Agrawal + + + WhoIsJayD +
+ Jaydeep +
+ khushhalgarg112 @@ -1425,7 +1439,8 @@
MINHAJ
- + + manav0702 @@ -1439,8 +1454,7 @@
Meep_
- - + rust-master @@ -1468,7 +1482,8 @@
Raj Saha
- + + robertlent @@ -1482,8 +1497,7 @@
Saanvibk
- - + Petsamuel @@ -1511,7 +1525,8 @@
Syeda Nowshin Ibnat
- + + Utkarsh-Raj20 @@ -1525,8 +1540,7 @@
Dapo Adedire
- - + dimonalik @@ -1548,28 +1562,21 @@ Maglionaire - - - Gabriela20103967 -
- Gabriela20103967 -
- Guillotine189
Sarthak Singhal
- + + newtoallofthis123
Ishan Joshi
- - + Rathish-Rajendran @@ -1604,15 +1611,15 @@
Abhay-Gupta008
- + + AbhinandanSingla
Abhinandan Singla
- - + adixoo @@ -1647,15 +1654,15 @@
Arif Shariar Rahman
- + + AtharvaDeshmukh0909
AtharvaDeshmukh0909
- - + ayushi-ras @@ -1663,6 +1670,13 @@ Ayushi Rastogi + + + Carl283583 +
+ Carl283583 +
+ Crack-er-jack @@ -1683,7 +1697,8 @@
Dhandeep
- + + Dhruvil-Lakhtaria @@ -1697,8 +1712,7 @@
Dishant Nagpal
- - + EbrG786 @@ -1726,7 +1740,8 @@
Himanshu Singh Negi
- + + JenilGajjar20 @@ -1740,8 +1755,7 @@
Jishnudeep Borah
- - + Josephtobi @@ -1769,7 +1783,8 @@
Kunal Pitale
- + + Manishak798 @@ -1783,8 +1798,7 @@
Mohamed Khaled Yousef
- - + jusinamine @@ -1812,7 +1826,8 @@
Nilay Banerjee
- + + KushalPareek @@ -1826,8 +1841,7 @@
Prajwol Shrestha
- - + pranavdasan @@ -1855,7 +1869,8 @@
Raashika0201
- + + Ramisky @@ -1869,8 +1884,7 @@
Raveny
- - + RishiPastor05 @@ -1898,7 +1912,8 @@
Samayita Kali
- + + CapedDemon @@ -1912,8 +1927,7 @@
Shubham Kumar
- - + sudhanshu-77 @@ -1941,7 +1955,8 @@
Swapnadeep Mohapatra
- + + ImaginedTime @@ -1955,8 +1970,7 @@
Vikash
- - + Vishvam10 @@ -1984,7 +1998,8 @@
Ylavish64
- + + yogesh78026 @@ -1998,8 +2013,7 @@
Ambush
- - + wre9-tesh @@ -2027,7 +2041,8 @@
D-coder111
- + + dab07 @@ -2041,8 +2056,7 @@
Darsh Baxi
- - + faizaslam11 @@ -2070,7 +2084,8 @@
Kodingkin
- + + mangnez @@ -2084,8 +2099,7 @@
Zainab Ibraheem
- - + mr-desilva @@ -2113,7 +2127,8 @@
Parthiban Marimuthu
- + + cypherab01 @@ -2127,8 +2142,7 @@
Prabin Shrestha
- - + pratyusha0710 @@ -2156,7 +2170,8 @@
Tanawat Jirawttanakul
- + + LionLostInCode From 8b45511355895f94dd40e808318c1d76046e4340 Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 26 Dec 2023 06:19:30 +0000 Subject: [PATCH 09/11] Fix code style issues with Black --- projects/ToDoList/to_do_list.py | 129 +++++++++++++++++++++----------- 1 file changed, 87 insertions(+), 42 deletions(-) diff --git a/projects/ToDoList/to_do_list.py b/projects/ToDoList/to_do_list.py index 4603e9f16..6324728f0 100644 --- a/projects/ToDoList/to_do_list.py +++ b/projects/ToDoList/to_do_list.py @@ -1,72 +1,117 @@ import telebot from telebot import types -bot = telebot.TeleBot('6540560961:AAEuobp6IGekPHPwSDxbxEEgI9LbPvYRgEc') +bot = telebot.TeleBot("6540560961:AAEuobp6IGekPHPwSDxbxEEgI9LbPvYRgEc") -@bot.message_handler(commands=['start']) +@bot.message_handler(commands=["start"]) def start(message): keyboard = types.ReplyKeyboardMarkup() - note = types.KeyboardButton('Добавить заметку') - deletenote = types.KeyboardButton('Удалить заметку') - editnote = types.KeyboardButton('Изменить заметку') - event = types.KeyboardButton('Добавить событие') - deletevent = types.KeyboardButton('Удалить событие') - editevent = types.KeyboardButton('Изменить событие') - check = types.KeyboardButton('Открыть текущие заметки/события') + note = types.KeyboardButton("Добавить заметку") + deletenote = types.KeyboardButton("Удалить заметку") + editnote = types.KeyboardButton("Изменить заметку") + event = types.KeyboardButton("Добавить событие") + deletevent = types.KeyboardButton("Удалить событие") + editevent = types.KeyboardButton("Изменить событие") + check = types.KeyboardButton("Открыть текущие заметки/события") keyboard.add(note, deletenote, editnote, event, deletevent, editevent, check) - bot.send_message(message.chat.id, f'{message.from_user.first_name}, я так рад, что вы снова сдесь! \U0001F601 \nВыберите, что бы вы хотели сделать:', parse_mode='html', reply_markup=keyboard) + bot.send_message( + message.chat.id, + f"{message.from_user.first_name}, я так рад, что вы снова сдесь! \U0001F601 \nВыберите, что бы вы хотели сделать:", + parse_mode="html", + reply_markup=keyboard, + ) + @bot.message_handler(func=lambda message: True) def handle_button_click(message): - if (message.text.lower() == 'добавить заметку') or (message.text.lower() == '/addn'): + if (message.text.lower() == "добавить заметку") or ( + message.text.lower() == "/addn" + ): addn(message) - elif (message.text.lower() == 'добавить событие') or (message.text.lower() == '/adde'): + elif (message.text.lower() == "добавить событие") or ( + message.text.lower() == "/adde" + ): adde(message) - elif (message.text.lower() == 'удалить заметку') or (message.text.lower() == '/deleten'): + elif (message.text.lower() == "удалить заметку") or ( + message.text.lower() == "/deleten" + ): deleten(message) - elif (message.text.lower() == 'удалить событие') or (message.text.lower() == '/deletev'): + elif (message.text.lower() == "удалить событие") or ( + message.text.lower() == "/deletev" + ): deletev(message) - elif (message.text.lower() == 'изменить заметку') or (message.text.lower() == '/editn'): + elif (message.text.lower() == "изменить заметку") or ( + message.text.lower() == "/editn" + ): editn(message) - elif (message.text.lower() == 'изменить событие') or (message.text.lower() == '/edite'): + elif (message.text.lower() == "изменить событие") or ( + message.text.lower() == "/edite" + ): edite(message) - elif (message.text.lower() == 'открыть текущие заметки/события') or (message.text.lower() == '/check'): + elif (message.text.lower() == "открыть текущие заметки/события") or ( + message.text.lower() == "/check" + ): check(message) - elif message.text == '/help': - bot.send_message(message.chat.id, 'С моей помощью вы легко сможете:\n\n' - '1) Добавить для себя любую заметку коммандой - | /addn |\n\n' - '2) Создать событие с напоминанием коммандой - | /adde |\n\n' - '3) Удалить любую заметку коммандой - | /deleten |\n\n' - '4) Удалить любое событие коммандой - | /deletev |\n\n' - '5) Изменить любую заметку коммандой - | /editn |\n\n' - '6) Изменить любое событие коммандой - | /edite |\n\n' - '7) Просматривать все свои заметки коммандой - | /check |\n\n', - parse_mode='html') + elif message.text == "/help": + bot.send_message( + message.chat.id, + "С моей помощью вы легко сможете:\n\n" + "1) Добавить для себя любую заметку коммандой - | /addn |\n\n" + "2) Создать событие с напоминанием коммандой - | /adde |\n\n" + "3) Удалить любую заметку коммандой - | /deleten |\n\n" + "4) Удалить любое событие коммандой - | /deletev |\n\n" + "5) Изменить любую заметку коммандой - | /editn |\n\n" + "6) Изменить любое событие коммандой - | /edite |\n\n" + "7) Просматривать все свои заметки коммандой - | /check |\n\n", + parse_mode="html", + ) elif message.text.isalpha(): - bot.send_message(message.chat.id, - 'Извини, но я не воспринимаю текст \U0001F972, тебе следует попробовать комманды!\n' - 'Чтобы узнать, что я умею, введи комманду - | /help |') + bot.send_message( + message.chat.id, + "Извини, но я не воспринимаю текст \U0001F972, тебе следует попробовать комманды!\n" + "Чтобы узнать, что я умею, введи комманду - | /help |", + ) elif message.text.isdigit(): - bot.send_message(message.chat.id, - 'Извини, но я не воспринимаю цифры/числа \U0001F972, тебе следует попробовать комманды!\n' - 'Чтобы узнать, что я умею, введи комманду - | /help |') + bot.send_message( + message.chat.id, + "Извини, но я не воспринимаю цифры/числа \U0001F972, тебе следует попробовать комманды!\n" + "Чтобы узнать, что я умею, введи комманду - | /help |", + ) else: - bot.send_message(message.chat.id, 'Извини, но я воспринимаю только комманды \U0001F972\n' - 'Чтобы узнать, что я умею, введи комманду - | /help |') + bot.send_message( + message.chat.id, + "Извини, но я воспринимаю только комманды \U0001F972\n" + "Чтобы узнать, что я умею, введи комманду - | /help |", + ) + + def addn(message): - bot.send_message(message.chat.id, 'Вы создали заметку') + bot.send_message(message.chat.id, "Вы создали заметку") + + def adde(message): - bot.send_message(message.chat.id, 'Вы создали событие') + bot.send_message(message.chat.id, "Вы создали событие") + + def deleten(message): - bot.send_message(message.chat.id, 'Вы хотите удалить заметку') + bot.send_message(message.chat.id, "Вы хотите удалить заметку") + + def deletev(message): - bot.send_message(message.chat.id, 'Вы удалили событие') + bot.send_message(message.chat.id, "Вы удалили событие") + + def editn(message): - bot.send_message(message.chat.id, 'Вы хотите изменить заметку') + bot.send_message(message.chat.id, "Вы хотите изменить заметку") + + def edite(message): - bot.send_message(message.chat.id, 'Вы хотите изменить событие') + bot.send_message(message.chat.id, "Вы хотите изменить событие") + + def check(message): - bot.send_message(message.chat.id, 'Вы хотите посмотреть список заметок/событий') + bot.send_message(message.chat.id, "Вы хотите посмотреть список заметок/событий") + bot.polling(none_stop=True) From 4b9c90edc76cf63b356837aed6692bb6a93a40df Mon Sep 17 00:00:00 2001 From: Lint Action Date: Tue, 26 Dec 2023 06:21:02 +0000 Subject: [PATCH 10/11] Fix code style issues with Black --- projects/BlackJack/black_jack.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/projects/BlackJack/black_jack.py b/projects/BlackJack/black_jack.py index bd475ed61..e58160950 100644 --- a/projects/BlackJack/black_jack.py +++ b/projects/BlackJack/black_jack.py @@ -138,7 +138,7 @@ def check_ace(card): if bet > chips: print("You dont have enough chips.") print("Enter a valid amount. \n") - elif bet <= 0: #To prevent betting a negative value + elif bet <= 0: # To prevent betting a negative value print("Invalid Bet") else: chips -= bet @@ -284,10 +284,8 @@ def check_ace(card): break else: - - cont = input("Do you want to continue? (y/n) :") - check= cont.upper()###So a capital or lowercase value can be entered + check = cont.upper() ###So a capital or lowercase value can be entered if check == "Y": print("\n" * 100) @@ -309,9 +307,7 @@ def check_ace(card): print(input("Press Enter to exit the terminal...")) break - - except Exception as error: print(f"Following error occurred : {error} \nPlease try again.") game_num -= 1 # round with error won't be counted - continue \ No newline at end of file + continue From 2ebe06427c0f152a280bc4801d24229fceaff35a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 26 Dec 2023 06:21:24 +0000 Subject: [PATCH 11/11] contrib-readme-action has updated readme --- README.md | 86 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index bcdf9ed09..9e416eaa9 100644 --- a/README.md +++ b/README.md @@ -1670,6 +1670,13 @@ Ayushi Rastogi + + + bhanushri123 +
+ Bhanushri Chinta +
+ Carl283583 @@ -1690,15 +1697,15 @@
David-hosting
- + + Dhandeep10
Dhandeep
- - + Dhruvil-Lakhtaria @@ -1733,15 +1740,15 @@
HarsH
- + + HimanshuSinghNegi
Himanshu Singh Negi
- - + JenilGajjar20 @@ -1776,15 +1783,15 @@
Krishna13515
- + + iamkunalpitale
Kunal Pitale
- - + Manishak798 @@ -1819,15 +1826,15 @@
Nischay Goyal
- + + NooBIE-Nilay
Nilay Banerjee
- - + KushalPareek @@ -1862,15 +1869,15 @@
Faris Faikar
- + + Raashika0201
Raashika0201
- - + Ramisky @@ -1905,15 +1912,22 @@
Sai Uttej R
- + + samayita1606
Samayita Kali
- - + + + + Sergey18273 +
+ Sergey18273 +
+ CapedDemon @@ -1941,7 +1955,8 @@
Suliman Sagindykov
- + + sumitbaroniya @@ -1955,8 +1970,7 @@
Swapnadeep Mohapatra
- - + ImaginedTime @@ -1984,7 +1998,8 @@
Vivek Kumar Gupta
- + + YashTariyal @@ -1998,8 +2013,7 @@
Ylavish64
- - + yogesh78026 @@ -2027,7 +2041,8 @@
Prajwal Benedict A
- + + chimerson @@ -2041,8 +2056,7 @@
D-coder111
- - + dab07 @@ -2070,7 +2084,8 @@
Dhruv Jagdish
- + + jonascarvalh @@ -2084,8 +2099,7 @@
Kodingkin
- - + mangnez @@ -2113,7 +2127,8 @@
Muchamad Yuda Tri Ananda
- + + NebulaAnish @@ -2127,8 +2142,7 @@
Parthiban Marimuthu
- - + cypherab01 @@ -2156,7 +2170,8 @@
Samual Martin
- + + rathoreshreya @@ -2170,8 +2185,7 @@
Tanawat Jirawttanakul
- - + LionLostInCode