Skip to content

Commit 203fea9

Browse files
Merge branch 'python-geeks:main' into main
2 parents 55be734 + e0f9b7f commit 203fea9

File tree

53 files changed

+928
-83
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+928
-83
lines changed

.github/workflows/greetings.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

HACKTOBERFEST.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<h1 align="center"> 🎃 HacktoberFest-2021 🎃</h1>
1+
<h1 align="center"> 🎃 HacktoberFest-2022 🎃</h1>
22

3-
![Opensource](https://img.shields.io/badge/openSource-%E2%9D%A4-blue) ![PR](https://img.shields.io/badge/PRs-welcome-green) ![hacktoberfest](https://img.shields.io/badge/Hacktoberfest-2021-red) ![friendly](https://img.shields.io/badge/beginner-friendly-l)
3+
![Opensource](https://img.shields.io/badge/openSource-%E2%9D%A4-blue) ![PR](https://img.shields.io/badge/PRs-welcome-green) ![hacktoberfest](https://img.shields.io/badge/Hacktoberfest-2022-red) ![friendly](https://img.shields.io/badge/beginner-friendly-l)
44

55
# What is HacktoberFest?
66

@@ -21,7 +21,6 @@ You can sign up anytime between October 1 and October 31. Just be sure to sign u
2121
* If a maintainer reports your pull request as spam, it will not be counted toward your participation in Hacktoberfest.
2222
* If a maintainer reports behavior that’s not in line with the project’s code of conduct, you will be ineligible to participate.
2323
* To get a shirt, you must make four approved pull requests (PRs) on opted-in projects between October 1-31 in any time zone.
24-
* This year, the first 55,000 participants can earn a T-shirt.
2524

2625
# Quality Guidelines
2726

attachment-downloader/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Package/Script Name
2+
3+
A python script that automates download of attachments based on various constraints such as file extensions or file name or sender. There is no need of any external library everything is present already.
4+
5+
## Setup instructions
6+
7+
No neeed of any setup just add your email and password in the beginning and mention the path where you want to download the attachments.
8+
9+
## Author(s)
10+
11+
Somanyu
12+
13+
## Disclaimers, if any
14+
15+
Use this section to mention if any particular disclaimer is required

attachment-downloader/app.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import imaplib
2+
import email
3+
import os
4+
5+
USEREMAIL = "example@mail.com"
6+
USERPASS = "Example000"
7+
8+
9+
def downloadAttachment():
10+
11+
mail = imaplib.IMAP4_SSL("imap.gmail.com", port=993)
12+
mail.login(USEREMAIL, USERPASS)
13+
14+
mail.select()
15+
16+
result, data = mail.uid("search", None, "ALL")
17+
mails = len(data[0].split())
18+
19+
for i in range(mails):
20+
latestEmailUID = data[0].split()[i]
21+
result, emailData = mail.uid("fetch", latestEmailUID, "(RFC822)")
22+
23+
rawEmail = emailData[0][1]
24+
rawEmailString = rawEmail.decode("utf-8")
25+
emailMessage = email.message_from_string(rawEmailString)
26+
27+
for content in emailMessage.walk():
28+
if content.get_content_maintype() == "multipart":
29+
continue
30+
if content.get("Content-Disposition") is None:
31+
continue
32+
fileName = content.get_filename()
33+
fromEmail = emailMessage["from"]
34+
35+
if bool(fileName):
36+
if fileName.endswith(".pdf"):
37+
if fileName.startswith("SOMETHING"):
38+
cwd = os.getcwd()
39+
filePath = os.path.join("PATH", fileName)
40+
if not os.path.isfile(filePath):
41+
fileWrite = open(filePath, "wb")
42+
fileWrite.write(content.get_payload(decode=True))
43+
fileWrite.close()
44+
uid = latestEmailUID.decode("utf-8")
45+
print(
46+
f'Downloaded "{fileName}" in "{cwd}\\download" from "{fromEmail}" with UID "{uid}"'
47+
)
48+
49+
50+
downloadAttachment()

auto_calender/calendarauto.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def parse_time(timestamp):
130130
def format_timedelta(timedelta):
131131
# Takes a timedelta and returns a string
132132
hours = timedelta.total_seconds() / 3600
133-
return("%.2f" % hours)
133+
return ("%.2f" % hours)
134134

135135

136136
if __name__ == '__main__':

auto_completer/auto-complete.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def make_n_grams(text, n):
136136
n_seq = int(input("Enter number of more words to generate: "))
137137

138138
if len(input_text.split()) < 8:
139-
raise("""Please enter an 8 word sentence
139+
raise ("""Please enter an 8 word sentence
140140
to start with or choose from defaults!!!""")
141141

142142
out = " ".join(generate_text_ngram(model, input_text, word_ixs, n_seq)[0])

auto_crypto_alert_mail/Readme.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Crypto Exchange Mail Alert
2+
3+
Packages Used - smtplib & request
4+
5+
## Setup instructions
6+
7+
Open cmd/vscode_terminal run the following commands:
8+
```
9+
pip install secure-smtplib
10+
pip install requests
11+
```
12+
That's All, Now run script ```api_crypto_mail_alert.py```
13+
14+
## Output
15+
16+
Script will run in background and alerts automatically by sending an email wheneven the provided crypto currency reaches/crosses a target limit.
17+
18+
## Author
19+
20+
[Anshu](https://github.com/anshu189)
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# To install the unsed libraries run the below commands in the terminal
2+
# pip install secure-smtplib
3+
# pip install requests
4+
5+
import requests
6+
import smtplib
7+
8+
'''
9+
<===== IMPORTANT =====>
10+
1. THIS WILL NOT WORK WHEN SENDING MAIL FROM GMAIL BECAUSE OF NEW GOOGLE SECURITY POLICIES.
11+
2. BUT YOU CAN SEND MAIL FROM OUTLOOK OR ANY OTHER MAIL SERVICES WITHOUT ANY PROBLEM.
12+
3. ONLY UPDATE 'from_email', 'from_email_password' & 'to_email'.
13+
4. IF USING ANY OTHER MAIL SERVICE THEN CHANGE THE SERVER AND PORT TOO IN LINE 19 & 20.
14+
'''
15+
16+
# Add your Email ID & it's Password by which you are sending the email alert
17+
from_email = "<SENDER'S_EMAIL_ID>"
18+
from_email_password = "<SENDER'S_EMAIL_PASSWORD>"
19+
mail_port = 587
20+
mail_server = "smtp-mail.outlook.com"
21+
22+
# Add Email ID to whom you want to send the alert
23+
to_email = "RECEIVER'S_EMAIL_ID"
24+
25+
26+
def check_price():
27+
spot_name = input("Input the crypto currency to get alerts (eg. BTCUSDT): ")
28+
print("1.If Price hits Above\n2.If Price hits Below\n")
29+
cpolarity = int(input("Choose from 1 & 2: "))
30+
trig_point = 1
31+
if cpolarity == 1:
32+
trig_point = float(input("Input the trigger price(dollar) above at which you want to recieve mail alert: "))
33+
else:
34+
trig_point = float(input("Input the trigger price(dollar) below at which you want to recieve mail alert: "))
35+
36+
def send_mail():
37+
server = smtplib.SMTP(mail_server, mail_port)
38+
server.ehlo()
39+
server.starttls()
40+
server.ehlo()
41+
server.login(from_email, from_email_password)
42+
subject = f"{spot_name.upper()} EXCHANGE RATE"
43+
44+
if cpolarity == 1:
45+
body = f"{spot_name.upper()} Exchange is now above ${trig_point}: Current Exchange Rate: ${lprice}."
46+
else:
47+
body = f"{spot_name.upper()} Exchange is now below ${trig_point}: Current Exchange Rate: ${lprice}."
48+
49+
msg = f'''Subject: {subject}\n
50+
To: {"".join(to_email)}\n
51+
{body}'''
52+
53+
server.sendmail(from_email, to_email, msg.encode("utf8"))
54+
55+
print("Alert! The E-mail has been sent!")
56+
server.quit()
57+
58+
while True:
59+
Url = "https://api.binance.com/api/v3/ticker/24hr"
60+
r = requests.get(Url)
61+
json_list = r.json()
62+
cryptoname = {}
63+
lprice = 0
64+
for i in range(len(json_list)):
65+
if json_list[i]["symbol"] == spot_name.upper():
66+
cryptoname = json_list[i]
67+
try:
68+
lprice = float(cryptoname["lastPrice"][4:6])
69+
print(lprice)
70+
except ValueError:
71+
print("This Exchange is not available.")
72+
73+
if lprice >= trig_point and cpolarity == 1:
74+
send_mail()
75+
exit()
76+
if lprice <= trig_point and cpolarity == 2:
77+
send_mail()
78+
exit()
79+
80+
81+
check_price()

automated_calling/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
This is an automated calling script genrated using python it uses twilio for
2+
making calls thus to use this script you have to create twilio account
3+
4+
To create twilio account log in to twilio website
5+
6+
after completing the registration you will receive various credentials
7+
such as auth_token , account s_id and one auto_generated mobile number
8+
9+
**note since it is a trail version you will only able to call to only verified no.
10+
once your plan get upgraded you will able to call any number without any restriction
11+
12+
13+
requirement :
14+
15+
twilio client
16+
17+
installation : pip install twilio
18+
19+
client.calls.create will be responsible for the call process
20+
also here url is the reponse urls , i.e whatever you want to
21+
give as a response to the reciever you can give by simply creating your
22+
own at twilio.com, since it is a trail we have used trail response
23+
'to' attribute specifies whom you want to dial
24+
'from' attribute specifies from which number the receiver will receive the call
25+
**note that number will be auto genrated in the trail process

automated_calling/autocall.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
""" please go through the docs before running this scripts """
2+
3+
from twilio.rest import Client
4+
5+
print("\n" + " ***** WELCOME TO AUTOMATED PYTHON CALLING SCRIPT ***** ")
6+
print(" ***** PLEASE CREATE A TWILIO ACCOUNT BEFORE USING THE SCRIPT ***** ")
7+
print(" ***** TO CREATE TWILIO ACCOUNT GO TO WWW.TWILIO.COM ***** ")
8+
print(" ***** TYPE 'YES/yes' IF YOU WANT TO PROCEED ***** " + '\n')
9+
i = input()
10+
print("\n")
11+
12+
13+
if (i == "YES" or i == "yes"):
14+
account_sid = input(" ENTER YOUR TWILIO ACCOUNT-SID ")
15+
auth_token = input(" ENTER YOUR TWILIO AUTH-TOKEN ")
16+
17+
client = Client(account_sid, auth_token)
18+
19+
print("**** press 1 for single phone number *****")
20+
print("**** press 2 for multiple phone numbers *****")
21+
i = int(input())
22+
23+
if (i == 1):
24+
print(" ***** PLEASE ENTER RECIEVER's NUMBER **note mention your country code followed by '+' *****")
25+
number = int(input())
26+
print(" ***** PLEASE ENTER YOUR AUTOGENERATED NUMBER **note mention your country code followed by '+' *****")
27+
my_number = int(input())
28+
29+
call = client.calls.create(
30+
url='http://demo.twilio.com/docs/voice.xml',
31+
to=number,
32+
from_=my_number
33+
)
34+
print(" call success ")
35+
36+
if (i == 2):
37+
print(" ***** PLEASE ENTER RECIEVER's NUMBER SEPARTED BY SPACE AND FOLLOWED BY + COUNTRY-CODE")
38+
number = list(int(i) for i in input().strip().split(' '))
39+
print(" ***** PLEASE ENTER YOUR AUTOGENERATED NUMBER AND FOLLOWED BY + COUNTRY-CODE")
40+
my_number = int(input())
41+
for i in number:
42+
call = client.calls.create(
43+
url='http://demo.twilio.com/docs/voice.xml',
44+
to=i,
45+
from_=my_number
46+
)
47+
print(" call success to the number " + str(i))

0 commit comments

Comments
 (0)