Added configparser

master
prachi 2 years ago
parent 466cd2327d
commit 8bd4fe036b
No known key found for this signature in database
GPG Key ID: 2940E6901747AAAF
  1. 2
      README.md
  2. 53
      autoresponder_mailing.py

@ -1,4 +1,4 @@
# PyBitMessgae_AutoResponder
# PyBitMessage_AutoResponder
The aim of this python script is to run an bitmessages application automatically.This script will monitor the reponses from Responder and perform accordingly.

@ -1,15 +1,20 @@
import xmlrpclib
import json
import time
import datetime
import time
from datetime import timedelta
import configparser
seconds=300
class Bitmessage_Autorespond_To_Recipient():
api = xmlrpclib.ServerProxy("http://prachi.y@cisinlabs.com:7509963795d@localhost:8442/")
class BitmessageAutoresponder():
def api_sending_and_delete_mnessage_through_auto_responder(self):
config = configparser.ConfigParser()
config.read('/home/cis/PyBitmessage/examples/credentials.ini')
apiusername = config['sqlite3']['apiusername']
apipassword = config['sqlite3']['apipassword']
api = xmlrpclib.ServerProxy("http://%s:%s@localhost:8442/" % (apiusername, apipassword))
def send_autorepond_inbox_message(self):
"""Sending Auto Message To The Recipient"""
track={}
while True:
@ -17,50 +22,40 @@ class Bitmessage_Autorespond_To_Recipient():
inbox_var=inboxMessages.get('inboxMessages')
for values in inbox_var:
msgid=values.get('msgid')
to_address=values.get('fromAddress')
from_address=values.get('toAddress')
toaddress=values.get('fromAddress')
fromaddress=values.get('toAddress')
subject=values.get('subject')
message=values.get('message')
try:
if datetime.datetime.now() < track[to_address]:
if time.time() < track[toaddress]:
continue
except KeyError:
pass
ackData=self.api.sendMessage(to_address,from_address,subject,message)
ackData=self.api.sendMessage(toaddress,fromaddress,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()
global seconds
currenttime = time.time()
track[toaddress]= currenttime + seconds
list_of_time_track = list(key for (key,value) in track.items() if value < currenttime)
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):
def delete_outbox_message(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':
if status_ack_rcvd in ('ackreceived','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()
BitmessageAutoresponder().send_autorepond_inbox_message()
# Bitmessage_Autorespond_To_Recipient().delete_outbox_message()

Loading…
Cancel
Save