diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d550eaa --- /dev/null +++ b/.gitignore @@ -0,0 +1,153 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ +cover/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +.pybuilder/ +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +# For a library or package, you might want to ignore these files since the code is +# intended to run in multiple environments; otherwise, check them in: +# .python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# poetry +# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. +# This is especially recommended for binary packages to ensure reproducibility, and is more +# commonly ignored for libraries. +# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control +#poetry.lock + +# pdm +# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. +#pdm.lock +# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it +# in version control. +# https://pdm.fming.dev/#use-with-ide +.pdm.toml + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# pytype static type analyzer +.pytype/ + +# Cython debug symbols +cython_debug/ \ No newline at end of file diff --git a/AutoTelegram/AutoTelegram.py b/AutoTelegram/AutoTelegram.py new file mode 100644 index 0000000..16b62cd --- /dev/null +++ b/AutoTelegram/AutoTelegram.py @@ -0,0 +1,30 @@ +from telethon.sync import TelegramClient +from telethon.errors import TimedOutError, TimeoutError, UserPrivacyRestrictedError, FloodWaitError + +import config + +client = TelegramClient("session", config.api_id, config.api_hash) + +client.connect() +if not client.is_user_authorized(): + client.send_code_request(config.phone) + client.sign_in(config.phone, input('Enter the code: ')) + +user = client.get_entity(input("User phone, or username: ")) +times = int(input("How many times to send: ")) +message = input("Message: ") + +print("!WARNING! You may get ban or restrictions for your account! Use at your own risk!") +if input("Are you sure? (y/n) ").lower() != "y": + print("Aborting...") + exit(0) + +for i in range(times): + try: + client.send_message(user, message) + except TimeoutError | TimedOutError | FloodWaitError: + print("Telegram blocked you for flodding") + except UserPrivacyRestrictedError: + print("User cant accept messages") + except Exception as e: + print("Unknown error:", e) diff --git a/AutoTelegram/config.py b/AutoTelegram/config.py new file mode 100644 index 0000000..9affdab --- /dev/null +++ b/AutoTelegram/config.py @@ -0,0 +1,6 @@ +# api_id and api_hash are from https://my.telegram.org/apps +# phone is your phone number + +api_id = 0 +api_hash = "" +phone = "" \ No newline at end of file diff --git a/CSV_to_JSON/README.md b/CSV_to_JSON/README.md index 4b195bf..7d1bd1c 100644 --- a/CSV_to_JSON/README.md +++ b/CSV_to_JSON/README.md @@ -6,14 +6,14 @@ Make sure you have python 3 or higher, that's it. ## Files before
-![before](https://github.com/TechBoyy6/Python-scripts-collection/blob/master/CSV_to_JSON/img/before.jpg)
+![before](https://github.com/fnplus/Python-scripts-collection/blob/master/CSV_to_JSON/img/before.jpg?raw=true)
## CLI interface -![image](https://github.com/TechBoyy6/Python-scripts-collection/blob/master/CSV_to_JSON/img/CLI.jpg) +![image](https://github.com/fnplus/Python-scripts-collection/blob/master/CSV_to_JSON/img/CLI.jpg?raw=true) ## Files After
-![after](https://github.com/TechBoyy6/Python-scripts-collection/blob/master/CSV_to_JSON/img/after.jpg) +![after](https://github.com/fnplus/Python-scripts-collection/blob/master/CSV_to_JSON/img/after.jpg?raw=true) ## Contact diff --git a/CSV_to_JSON/csv_to_json.py b/CSV_to_JSON/csv_to_json.py index 69cb35e..207d98a 100644 --- a/CSV_to_JSON/csv_to_json.py +++ b/CSV_to_JSON/csv_to_json.py @@ -1,29 +1,20 @@ import csv import json -file_name = input("Provide the CSV filename without extension>> ") +file_name = input("Provide the CSV filename : ") +if not file_name.strip().endswith(".csv"): + file_name += ".csv" -with open(file_name + '.csv') as f: +with open(file_name) as f: + reader = csv.reader(f, delimiter=",") - reader = csv.reader(f, delimiter=',') - - titles = [] - temp_data = {} - - for heading in reader: - titles = heading - break - - i = 1 + titles = next(reader) + temp_data = [] for row in reader: - current_row = "row{}".format(i) - temp_data['{}'.format(current_row)] = {} - for col in range(len(titles)): - temp_data[current_row][titles[col]] = row[col] - i += 1 + temp_data.append({col: val for col, val in zip(titles, row)}) -with open(file_name + '.json', 'w') as f_j: +with open(file_name.strip()[:-4] + ".json", "w") as f_j: json.dump(temp_data, f_j, indent=4) print("File converted successfully :)\n") \ No newline at end of file diff --git a/FindIPAddress/FindIPAddress.py b/FindIPAddress/FindIPAddress.py index 4171f9c..552cd1d 100644 --- a/FindIPAddress/FindIPAddress.py +++ b/FindIPAddress/FindIPAddress.py @@ -1,5 +1,7 @@ import socket -hostname = socket.gethostname() -IPAddr = socket.gethostbyname(hostname) -print("Your Computer Name is:" + hostname) -print("\nYour Computer IP Address is:" + IPAddr) \ No newline at end of file + +HostName = socket.gethostname() +IPAddr = socket.gethostbyname(HostName) + +print(f"Your Computer Name is: {HostName}\n") +print(f"Your Computer IP Address is: {IPAddr}") \ No newline at end of file diff --git a/README.md b/README.md index eccf46f..bc4f49d 100644 --- a/README.md +++ b/README.md @@ -55,4 +55,5 @@ This is a collection of short Python scripts to solve and automate tasks and sim 35 | [**SMS-SENDER**](https://github.com/CopyrightC/Python-scripts-collection/blob/master/SMS_SENDER/main.py) | A python script that uses Tkinter and Twilio to send SMS. | twilio| 36 | [**Password Validator**](https://github.com/Mannuel25/Python-scripts-collection/tree/master/Password%20Validator) | A script validates passwords to match specific rules. A valid password is one that conforms to some specific rules. | None | 37 | [**RSA Communication**](https://github.com/fnplus/Python-scripts-collection/tree/master/RSA_Communication) | Independent Python script that allows RSA communication. | None | +38 | [**AutoTelegram**](https://github.com/farkon00/Python-scripts-collection/tree/master/AutoTelegram) | A program to spam messages to a Telegram user any number of times | telethon |