Change file path credentials.ini

This commit is contained in:
prachi 2020-05-15 21:44:39 +05:30
parent cc3edf151a
commit 7f2ea815b6
No known key found for this signature in database
GPG Key ID: 2940E6901747AAAF

View File

@ -1,25 +1,30 @@
import xmlrpclib
import json
import time
import time
from datetime import timedelta
import configparser
seconds=300
import configparser
import os
class BitmessageAutoresponder():
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))
config=configparser.ConfigParser()
db_var=os.path.join(os.environ["HOME"],'.config/PyBitmessage/credentials.ini')
config.read(db_var)
apiport=config['sqlite3']['apiport']
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):
"""Sending Auto Message To The Recipient"""
cls = self.__class__
track={}
while True:
inboxMessages=json.loads(self.api.getAllInboxMessages())
inbox_var=inboxMessages.get('inboxMessages')
currenttime=time.time()
for values in inbox_var:
msgid=values.get('msgid')
toaddress=values.get('fromAddress')
@ -30,19 +35,20 @@ class BitmessageAutoresponder():
if time.time() < track[toaddress]:
continue
except KeyError:
pass
pass
if toaddress==fromaddress:
continue
ackData=self.api.sendMessage(toaddress,fromaddress,subject,message)
print 'The ackData is:', ackData
self.api.trashMessage(msgid)
global seconds
currenttime = time.time()
track[toaddress]= currenttime + seconds
list_of_time_track = list(key for (key,value) in track.items() if value < currenttime)
track[toaddress]=currenttime + cls.expire
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)
self.delete_outbox_message()
time.sleep(10)
def delete_outbox_message(self):
print("hello sent dlt")
"""Deleting Messages from Outbox Having Status ackreceived or msgsentnoackexpected"""
SentMessage=json.loads(self.api.getAllSentMessages())
sent_var=SentMessage.get('sentMessages')
@ -51,11 +57,9 @@ class BitmessageAutoresponder():
ackData=values.get('ackData')
if status_ack_rcvd in ('ackreceived','msgsentnoackexpected'):
self.api.trashSentMessageByAckData(ackData)
else:
print("--------********----------")
if __name__ == '__main__':
BitmessageAutoresponder().send_autorepond_inbox_message()
# Bitmessage_Autorespond_To_Recipient().delete_outbox_message()