Upload files to ''

Added an Autoresponder script
This commit is contained in:
prachiyadav 2020-05-13 09:45:11 +00:00
parent 8d6d54e2ca
commit 7745c14720

66
autoresponder_mailing.py Normal file
View File

@ -0,0 +1,66 @@
import xmlrpclib
import json
import time
import datetime
from datetime import timedelta
class Bitmessage_Autorespond_To_Recipient():
api = xmlrpclib.ServerProxy("http://prachi.y@cisinlabs.com:7509963795d@localhost:8442/")
def api_sending_and_delete_mnessage_through_auto_responder(self):
"""Sending Auto Message To The Recipient"""
track={}
while True:
inboxMessages=json.loads(self.api.getAllInboxMessages())
inbox_var=inboxMessages.get('inboxMessages')
for values in inbox_var:
msgid=values.get('msgid')
to_address=values.get('fromAddress')
from_address=values.get('toAddress')
subject=values.get('subject')
message=values.get('message')
try:
if datetime.datetime.now() < track[to_address]:
continue
except KeyError:
pass
ackData=self.api.sendMessage(to_address,from_address,subject,message)
print 'The ackData is:', ackData
print("Message Sent")
self.api.trashMessage(msgid)
print("Deleted bitmessage")
seconds = 300
currenttime_with_date = datetime.datetime.now()
track[to_address]= currenttime_with_date + timedelta(seconds=seconds)
print("Store time of sending messages",track[to_address])
list_of_time_track = list(key for (key,value) in track.items() if value < currenttime_with_date)
# import pdb;pdb.set_trace()
for t in list_of_time_track:
track.pop(t)
print("------remove address time--------")
print("-----------********_-_*******-----------")
time.sleep(10)
def check_and_delete_outbox_message_recieved_or_not(self):
"""Deleting Messages from Outbox Having Status ackreceived or msgsentnoackexpected"""
SentMessage=json.loads(self.api.getAllSentMessages())
sent_var=SentMessage.get('sentMessages')
for values in sent_var:
status_ack_rcvd=values.get('status')
ackData=values.get('ackData')
if status_ack_rcvd=='ackreceived' or status_ack_rcvd=='msgsentnoackexpected':
self.api.trashSentMessageByAckData(ackData)
print("deleted outbox messages")
else:
print("--------********----------")
if __name__ == '__main__':
Bitmessage_Autorespond_To_Recipient().api_sending_and_delete_mnessage_through_auto_responder()
# Bitmessage_Autorespond_To_Recipient().check_and_delete_outbox_message_recieved_or_not()