Change file path credentials.ini
This commit is contained in:
parent
cc3edf151a
commit
7f2ea815b6
|
@ -1,25 +1,30 @@
|
||||||
import xmlrpclib
|
import xmlrpclib
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import time
|
|
||||||
from datetime import timedelta
|
|
||||||
import configparser
|
import configparser
|
||||||
seconds=300
|
import os
|
||||||
|
|
||||||
|
|
||||||
class BitmessageAutoresponder():
|
class BitmessageAutoresponder():
|
||||||
|
|
||||||
config = configparser.ConfigParser()
|
config=configparser.ConfigParser()
|
||||||
config.read('/home/cis/PyBitmessage/examples/credentials.ini')
|
db_var=os.path.join(os.environ["HOME"],'.config/PyBitmessage/credentials.ini')
|
||||||
apiusername = config['sqlite3']['apiusername']
|
config.read(db_var)
|
||||||
apipassword = config['sqlite3']['apipassword']
|
apiport=config['sqlite3']['apiport']
|
||||||
api = xmlrpclib.ServerProxy("http://%s:%s@localhost:8442/" % (apiusername, apipassword))
|
apiinterface=config['sqlite3']['apiinterface']
|
||||||
|
apiusername=config['sqlite3']['apiusername']
|
||||||
|
apipassword=config['sqlite3']['apipassword']
|
||||||
|
api=xmlrpclib.ServerProxy("http://%s:%s@%s:%s/" % (apiusername,apipassword,apiinterface,apiport))
|
||||||
|
expire=300
|
||||||
|
|
||||||
def send_autorepond_inbox_message(self):
|
def send_autorepond_inbox_message(self):
|
||||||
"""Sending Auto Message To The Recipient"""
|
"""Sending Auto Message To The Recipient"""
|
||||||
|
cls = self.__class__
|
||||||
track={}
|
track={}
|
||||||
while True:
|
while True:
|
||||||
inboxMessages=json.loads(self.api.getAllInboxMessages())
|
inboxMessages=json.loads(self.api.getAllInboxMessages())
|
||||||
inbox_var=inboxMessages.get('inboxMessages')
|
inbox_var=inboxMessages.get('inboxMessages')
|
||||||
|
currenttime=time.time()
|
||||||
for values in inbox_var:
|
for values in inbox_var:
|
||||||
msgid=values.get('msgid')
|
msgid=values.get('msgid')
|
||||||
toaddress=values.get('fromAddress')
|
toaddress=values.get('fromAddress')
|
||||||
|
@ -31,18 +36,19 @@ class BitmessageAutoresponder():
|
||||||
continue
|
continue
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
|
if toaddress==fromaddress:
|
||||||
|
continue
|
||||||
ackData=self.api.sendMessage(toaddress,fromaddress,subject,message)
|
ackData=self.api.sendMessage(toaddress,fromaddress,subject,message)
|
||||||
print 'The ackData is:', ackData
|
|
||||||
self.api.trashMessage(msgid)
|
self.api.trashMessage(msgid)
|
||||||
global seconds
|
track[toaddress]=currenttime + cls.expire
|
||||||
currenttime = time.time()
|
list_of_time_track=list(key for (key,value) in track.items() if value < currenttime)
|
||||||
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:
|
for t in list_of_time_track:
|
||||||
track.pop(t)
|
track.pop(t)
|
||||||
|
self.delete_outbox_message()
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
|
||||||
def delete_outbox_message(self):
|
def delete_outbox_message(self):
|
||||||
|
print("hello sent dlt")
|
||||||
"""Deleting Messages from Outbox Having Status ackreceived or msgsentnoackexpected"""
|
"""Deleting Messages from Outbox Having Status ackreceived or msgsentnoackexpected"""
|
||||||
SentMessage=json.loads(self.api.getAllSentMessages())
|
SentMessage=json.loads(self.api.getAllSentMessages())
|
||||||
sent_var=SentMessage.get('sentMessages')
|
sent_var=SentMessage.get('sentMessages')
|
||||||
|
@ -51,11 +57,9 @@ class BitmessageAutoresponder():
|
||||||
ackData=values.get('ackData')
|
ackData=values.get('ackData')
|
||||||
if status_ack_rcvd in ('ackreceived','msgsentnoackexpected'):
|
if status_ack_rcvd in ('ackreceived','msgsentnoackexpected'):
|
||||||
self.api.trashSentMessageByAckData(ackData)
|
self.api.trashSentMessageByAckData(ackData)
|
||||||
else:
|
|
||||||
print("--------********----------")
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
BitmessageAutoresponder().send_autorepond_inbox_message()
|
BitmessageAutoresponder().send_autorepond_inbox_message()
|
||||||
# Bitmessage_Autorespond_To_Recipient().delete_outbox_message()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user