-
Notifications
You must be signed in to change notification settings - Fork 0
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
Robota #1
base: master
Are you sure you want to change the base?
Robota #1
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
|
||
from classes.mail_wrapper import MailWrapper | ||
from classes.imap import ImapGmailWrapper | ||
from classes.types import MailSenderSubject | ||
|
||
from config import mail, app_password, url_telegram, chat_id | ||
|
||
|
@@ -21,24 +22,23 @@ def check_gmail(): | |
current_mail_id = int(file_reader.read()) | ||
|
||
if possible_new_email_id > current_mail_id: | ||
latest_email_id = possible_new_email_id | ||
number_of_new_mails = latest_email_id - current_mail_id | ||
|
||
file_reader.close() | ||
|
||
|
||
latest_email_id = possible_new_email_id | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How can |
||
save_latest_email_id(latest_email_id) | ||
|
||
raw_email = imap.fetchs([latest_email_id]) | ||
senders_subjects = [] | ||
message = 'Shalom Adonai, irmãos. Novo(s) e-mail(s), deem uma olhada:\n' | ||
|
||
for mail_id in range(current_mail_id + 1, latest_email_id + 1): | ||
raw_email = imap.fetchs([mail_id]) | ||
|
||
mail_parser = MailWrapper(raw_email) | ||
sender = mail_parser.get_sender() | ||
mail_parser = MailWrapper(raw_email) | ||
|
||
subject = mail_parser.get_subject() | ||
senders_subjects.append(MailSenderSubject(mail_parser.get_sender(), mail_parser.get_subject())) | ||
|
||
if number_of_new_mails > 1: | ||
message = 'Shalom Adonai, irmãos. {} novos emails, deem uma olhada.'.format(number_of_new_mails) | ||
else: | ||
message = 'Shalom Adonai, irmãos. Novo email, deem uma olhada.\n\nTítulo: {}\n\nRemetente: {}'.format(subject, sender) | ||
for ss in senders_subjects: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. avoid using abbreviations or simplified names for variables, it's better to be explicit about what we are doing here. |
||
message += '\nRemetente: {}\nTítulo: {}\n'.format(ss.sender, ss.subject) | ||
|
||
send_message(message) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit messages is not clear, I believe that you want to say:
Changing email script to support multiple emails subjects in inbox
or something like.