Skip to content

AutoTelegram script, python gitignore added, code improvements #89

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
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
153 changes: 153 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
30 changes: 30 additions & 0 deletions AutoTelegram/AutoTelegram.py
Original file line number Diff line number Diff line change
@@ -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)
6 changes: 6 additions & 0 deletions AutoTelegram/config.py
Original file line number Diff line number Diff line change
@@ -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 = ""
6 changes: 3 additions & 3 deletions CSV_to_JSON/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Make sure you have python 3 or higher, that's it.

## Files
before<br/>
![before](https://github.com/TechBoyy6/Python-scripts-collection/blob/master/CSV_to_JSON/img/before.jpg)<br/>
![before](https://github.com/fnplus/Python-scripts-collection/blob/master/CSV_to_JSON/img/before.jpg?raw=true)<br/>

## 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<br/>
![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
<a href="https://twitter.com/MoiZ__2001?s=08">
Expand Down
27 changes: 9 additions & 18 deletions CSV_to_JSON/csv_to_json.py
Original file line number Diff line number Diff line change
@@ -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")
10 changes: 6 additions & 4 deletions FindIPAddress/FindIPAddress.py
Original file line number Diff line number Diff line change
@@ -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)

HostName = socket.gethostname()
IPAddr = socket.gethostbyname(HostName)

print(f"Your Computer Name is: {HostName}\n")
print(f"Your Computer IP Address is: {IPAddr}")
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |