Skip to content
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

add/update: New program to automate sending messages. #2095

Merged
merged 12 commits into from
Jan 15, 2024
Merged
130 changes: 130 additions & 0 deletions area_of_square_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
__author__ = "Nitkarsh Chourasia"
__author_GitHub_profile__ = "https://github.com/NitkarshChourasia"
__author_email_address__ = "playnitkarsh@gmal.com"
__created_on__ = "10/10/2021"
__last_updated__ = "10/10/2021"

from word2number import w2n


def convert_words_to_number(word_str):
"""
Convert a string containing number words to an integer.

Args:
- word_str (str): Input string with number words.

Returns:
- int: Numeric equivalent of the input string.
"""
numeric_result = w2n.word_to_num(word_str)
return numeric_result


# Example usage:
number_str = "two hundred fifteen"
result = convert_words_to_number(number_str)
print(result) # Output: 215


class Square:
def __init__(self, side=None):
if side is None:
self.ask_side()
# else:
# self.side = float(side)
else:
if not isinstance(side, (int, float)):
try:
side = float(side)
except ValueError:
# return "Invalid input for side."
raise ValueError("Invalid input for side.")
else:
self.side = float(side)
# Check if the result is a float and remove unnecessary zeros

self.calculate_square()
self.truncate_decimals()

# If ask side or input directly into the square.
# That can be done?
def calculate_square(self):
self.area = self.side * self.side
return self.area

# Want to add a while loop asking for the input.
# Also have an option to ask the user in true mode or in repeat mode.
def ask_side(self):
# if true bool then while if int or float then for loop.
# I will have to learn inheritance and polymorphism.
condition = 3
# condition = True
if condition == True and isinstance(condition, bool):
while condition:
n = input("Enter the side of the square: ")
self.side = float(n)
elif isinstance(condition, (int, float)):
for i in range(_=condition):
n = input("Enter the side of the square: ")
self.side = float(n)
# n = input("Enter the side of the square: ")
# self.side = float(n)
# return

def truncate_decimals(self):
return (
f"{self.area:.10f}".rstrip("0").rstrip(".")
if "." in str(self.area)
else self.area
)

# Prettifying the output.

def calculate_perimeter(self):
return 4 * self.side

def calculate_perimeter_prettify(self):
return f"The perimeter of the square is {self.calculate_perimeter()}."

def calculate_area_prettify(self):
return f"The area of the square is {self.area}."

def truncate_decimals_prettify(self):
return f"The area of the square is {self.truncate_decimals()}."


if __name__ == "__main__":
output_one = Square()
truncated_area = output_one.truncate_decimals()
# print(output_one.truncate_decimals())
print(truncated_area)


# add a while loop to keep asking for the user input.
# also make sure to add a about menu to input a while loop in tkinter app.

# It can use a beautiful GUI also.
# Even validation is left.
# What if string is provided in number? Then?
# What if chars are provided. Then?
# What if a negative number is provided? Then?
# What if a number is provided in alphabets characters? Then?
# Can it a single method have more object in it?

# Also need to perform testing on it.
# EXTREME FORM OF TESTING NEED TO BE PERFORMED ON IT.
# Documentation is also needed.
# Comments are also needed.
# TYPE hints are also needed.

# README.md file is also needed.
## Which will explain the whole project.
### Like how to use the application.
### List down the features in explicit detail.
### How to use different methods and classes.
### It will also a image of the project in working state.
### It will also have a video to the project in working state.

# It should also have .exe and linux executable file.
# It should also be installable into Windows(x86) system and if possible into Linux system also.
11 changes: 0 additions & 11 deletions sWAP_cASE.py

This file was deleted.

8 changes: 8 additions & 0 deletions send_message_automation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Send message automation


sources used:


Gif image creation credit goes to:
- ezgif.com used to make gif images.
7 changes: 7 additions & 0 deletions send_message_automation/author_name_NC.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

__ _ _ _ _ ___ _ _
/\ \ \(_)| |_ | | __ __ _ _ __ ___ | |__ / __\| |__ ___ _ _ _ __ __ _ ___ (_) __ _
/ \/ /| || __|| |/ / / _` || '__|/ __|| '_ \ / / | '_ \ / _ \ | | | || '__| / _` |/ __|| | / _` |
/ /\ / | || |_ | < | (_| || | \__ \| | | | / /___ | | | || (_) || |_| || | | (_| |\__ \| || (_| |
\_\ \/ |_| \__||_|\_\ \__,_||_| |___/|_| |_| \____/ |_| |_| \___/ \__,_||_| \__,_||___/|_| \__,_|

Binary file not shown.
41 changes: 41 additions & 0 deletions send_message_automation/message_automation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import pyautogui
from time import sleep

# Do you want to include the message counter?
# make a class of it.

# Can make a broswer session open and navigating to web.whatsapp
# os dependencies and browser dependencies and default browser if none
# also check for whatsapp on the system


def send_message(message):
pyautogui.write(message)
pyautogui.press("enter")


def send_repeatedly(message, repetitions, delay):
count = 1
try:
for _ in range(repetitions):
send_message(f"Message {count}: {message}")
sleep(delay)
count += 1
except KeyboardInterrupt:
print("\nProgram terminated by user.")


if __name__ == "__main__":
try:
user_message = input("Enter the message you want to send: ")
repetitions = int(input("Enter the number of repetitions: "))
delay = float(input("Enter the delay between messages (in seconds): "))

sleep(5)
send_repeatedly(user_message, repetitions, delay)

except ValueError:
print("Invalid input. Please enter a valid number.")

except Exception as e:
print(f"An error occurred: {str(e)}")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
49 changes: 49 additions & 0 deletions turtle_shapes_made.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import turtle

class ShapeDrawer:
def __init__(self, color, pensize):
self.turtle = turtle.Turtle()
self.turtle.color(color)
self.turtle.pensize(pensize)

def draw_rectangle(self, width, height):
for _ in range(2):
self.turtle.forward(width)
self.turtle.left(90)
self.turtle.forward(height)
self.turtle.left(90)

def draw_triangle(self, length):
for _ in range(3):
self.turtle.forward(length)
self.turtle.left(120)

def main():
scrn = turtle.Screen()
scrn.bgcolor("lavender")

# Draw Rectangle
rectangle_drawer = ShapeDrawer("blue", 3)
rectangle_drawer.draw_rectangle(180, 75)

# Draw Triangle
triangle_drawer = ShapeDrawer("hot pink", 4)
triangle_drawer.turtle.penup()
triangle_drawer.turtle.goto(-90, -75)
triangle_drawer.turtle.pendown()
triangle_drawer.draw_triangle(100)

# Add more drawings as needed
# ...

# Example: Draw a circle
circle_drawer = ShapeDrawer("green", 2)
circle_drawer.turtle.penup()
circle_drawer.turtle.goto(0, 0)
circle_drawer.turtle.pendown()
circle_drawer.turtle.circle(50)

scrn.exitonclick()

if __name__ == "__main__":
main()
98 changes: 44 additions & 54 deletions tweeter.py
Original file line number Diff line number Diff line change
@@ -1,82 +1,72 @@
"""
Author: Shreyas Daniel (shreydan)
Install: tweepy - "pip install tweepy"
API: Create a twitter app "apps.twitter.com" to get your OAuth requirements.
Version: 1.0

Tweet text and pics directly from the terminal.
"""
from __future__ import print_function

import os

import tweepy

try:
input = raw_input
except NameError:
pass
# TODO: Further improvements can be made to the program
# TODO: Further feature improvements and Refactoring can be done to the program
# TODO: Add a README.md file showcasing how adding it to the PATH variable can make the posting much easier


def getStatus():
def get_status():
lines = []
while True:
line = input()
if line:
lines.append(line)
else:
break
status = "\n".join(lines)
return status
return "\n".join(lines)


def tweetthis(type):
if type == "text":
print("Enter your tweet " + user.name)
tweet = getStatus()
try:
api.update_status(tweet)
except Exception as e:
print(e)
return
elif type == "pic":
print("Enter pic path " + user.name)
pic = os.path.abspath(input())
print("Enter status " + user.name)
title = getStatus()
try:
api.update_with_media(pic, status=title)
except Exception as e:
print(e)
return
def tweet_text(api, user):
print(f"Enter your tweet, {user.name}:")
tweet = get_status()
try:
api.update_status(tweet)
print("\nTweet posted successfully!")
except tweepy.TweepError as e:
print(f"Error posting tweet: {e}")

print("\n\nDONE!!")

def tweet_picture(api, user):
print(f"Enter the picture path, {user.name}:")
pic = os.path.abspath(input())
print(f"Enter the status, {user.name}:")
title = get_status()
try:
api.update_with_media(pic, status=title)
print("\nTweet with picture posted successfully!")
except tweepy.TweepError as e:
print(f"Error posting tweet with picture: {e}")

def initialize():
global api, auth, user
ck = "here" # consumer key
cks = "here" # consumer key SECRET
at = "here" # access token
ats = "here" # access token SECRET

def initialize_api():
ck = "your_consumer_key"
cks = "your_consumer_key_secret"
at = "your_access_token"
ats = "your_access_token_secret"

auth = tweepy.OAuthHandler(ck, cks)
auth.set_access_token(at, ats)

api = tweepy.API(auth)
user = api.me()
return api, user


def main():
doit = int(input("\n1. text\n2. picture\n"))
initialize()
if doit == 1:
tweetthis("text")
elif doit == 2:
tweetthis("pic")
else:
print("OK, Let's try again!")
main()
try:
doit = int(input("\n1. Text\n2. Picture\nChoose option (1/2): "))
api, user = initialize_api()

if doit == 1:
tweet_text(api, user)
elif doit == 2:
tweet_picture(api, user)
else:
print("Invalid option. Please choose 1 or 2.")
except ValueError:
print("Invalid input. Please enter a valid number.")


main()
if __name__ == "__main__":
main()
2 changes: 0 additions & 2 deletions usinglist.py

This file was deleted.

Loading
Loading