checking scirpt with pylint
This commit is contained in:
parent
7f2ea815b6
commit
5d72fda972
|
@ -1,65 +1,60 @@
|
||||||
import xmlrpclib
|
"""Bitmessage AutoResponder"""
|
||||||
|
import configparser
|
||||||
import json
|
import json
|
||||||
import time
|
|
||||||
import configparser
|
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
import xmlrpclib
|
||||||
|
|
||||||
class BitmessageAutoresponder():
|
class BitmessageAutoresponder():
|
||||||
|
"""Sending and receiving messages through autoresponder"""
|
||||||
config=configparser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
db_var=os.path.join(os.environ["HOME"],'.config/PyBitmessage/credentials.ini')
|
db_var = os.path.join(os.environ["HOME"], '.config/PyBitmessage/credentials.ini')
|
||||||
config.read(db_var)
|
config.read(db_var)
|
||||||
apiport=config['sqlite3']['apiport']
|
apiport = config['sqlite3']['apiport']
|
||||||
apiinterface=config['sqlite3']['apiinterface']
|
apiinterface = config['sqlite3']['apiinterface']
|
||||||
apiusername=config['sqlite3']['apiusername']
|
apiusername = config['sqlite3']['apiusername']
|
||||||
apipassword=config['sqlite3']['apipassword']
|
apipassword = config['sqlite3']['apipassword']
|
||||||
api=xmlrpclib.ServerProxy("http://%s:%s@%s:%s/" % (apiusername,apipassword,apiinterface,apiport))
|
api = xmlrpclib.ServerProxy("http://%s:%s@%s:%s/"%(apiusername, apipassword, apiinterface, apiport))
|
||||||
expire=300
|
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()
|
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')
|
||||||
fromaddress=values.get('toAddress')
|
fromaddress = values.get('toAddress')
|
||||||
subject=values.get('subject')
|
subject = values.get('subject')
|
||||||
message=values.get('message')
|
message = values.get('message')
|
||||||
try:
|
try:
|
||||||
if time.time() < track[toaddress]:
|
if time.time() < track[toaddress]:
|
||||||
continue
|
continue
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
if toaddress==fromaddress:
|
if toaddress == fromaddress:
|
||||||
continue
|
continue
|
||||||
ackData=self.api.sendMessage(toaddress,fromaddress,subject,message)
|
self.api.sendMessage(toaddress, fromaddress, subject, message)
|
||||||
self.api.trashMessage(msgid)
|
self.api.trashMessage(msgid)
|
||||||
track[toaddress]=currenttime + cls.expire
|
track[toaddress] = currenttime + self.expire
|
||||||
list_of_time_track=list(key for (key,value) in track.items() if value < currenttime)
|
list_of_time_track = list(key for (key, value) in track.items() if value < currenttime)
|
||||||
for t in list_of_time_track:
|
for address in list_of_time_track:
|
||||||
track.pop(t)
|
track.pop(address)
|
||||||
self.delete_outbox_message()
|
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')
|
||||||
for values in sent_var:
|
for values in sent_var:
|
||||||
status_ack_rcvd=values.get('status')
|
status_ack_rcvd = values.get('status')
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
BitmessageAutoresponder().send_autorepond_inbox_message()
|
BitmessageAutoresponder().send_autorepond_inbox_message()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user