Use f strings for logging
This commit is contained in:
parent
3426b1fbb9
commit
6a606ad3dd
@ -69,12 +69,12 @@ class Logbot(Bot):
|
|||||||
# download file
|
# download file
|
||||||
data = urllib.request.urlopen(message.url).read()
|
data = urllib.request.urlopen(message.url).read()
|
||||||
if data:
|
if data:
|
||||||
self.log.info("downloading: ", message.url)
|
self.log.info(f"downloading: {message.url}")
|
||||||
parsed_url = urlparse(message.url)
|
parsed_url = urlparse(message.url)
|
||||||
filename = (
|
filename = (
|
||||||
os.path.basename(parsed_url.path).replace(" ", "_").replace("%20", "_")
|
os.path.basename(parsed_url.path).replace(" ", "_").replace("%20", "_")
|
||||||
) # safe url's
|
) # safe url's
|
||||||
self.log.info("as the file: ", filename)
|
self.log.info(f"as the file: {filename}")
|
||||||
roomname = re.sub(r"@.*", "", message.room)
|
roomname = re.sub(r"@.*", "", message.room)
|
||||||
path = os.path.join(self.output, roomname, media_type)
|
path = os.path.join(self.output, roomname, media_type)
|
||||||
if not os.path.isdir(path):
|
if not os.path.isdir(path):
|
||||||
@ -111,7 +111,7 @@ class Logbot(Bot):
|
|||||||
db=self.db[message.room]["messages"],
|
db=self.db[message.room]["messages"],
|
||||||
)
|
)
|
||||||
out.write(html)
|
out.write(html)
|
||||||
self.log.info("writing to: ", log_path)
|
self.log.info(f"writing to: {log_path}")
|
||||||
|
|
||||||
def _add_to_db(self, message, media_post=None):
|
def _add_to_db(self, message, media_post=None):
|
||||||
"""Save new entry to database."""
|
"""Save new entry to database."""
|
||||||
@ -163,9 +163,10 @@ class Logbot(Bot):
|
|||||||
|
|
||||||
# to debug in the terminal
|
# to debug in the terminal
|
||||||
self.log.info("------------------")
|
self.log.info("------------------")
|
||||||
self.log.info("message: ", message.text)
|
self.log.info(f"message: {message.text}")
|
||||||
self.log.info("room: ", message.room)
|
self.log.info(f"room: {message.room}")
|
||||||
self.log.info("sender: ", message.sender)
|
self.log.info(f"sender: {message.sender}")
|
||||||
|
self.log.info("------------------")
|
||||||
|
|
||||||
# image / PDF / audio / video
|
# image / PDF / audio / video
|
||||||
if message.url:
|
if message.url:
|
||||||
@ -186,7 +187,7 @@ class Logbot(Bot):
|
|||||||
key = str(match.replace("@delete ", ""))
|
key = str(match.replace("@delete ", ""))
|
||||||
|
|
||||||
if key in self.db[message.room]["messages"]:
|
if key in self.db[message.room]["messages"]:
|
||||||
self.log.info("To be deleted:", self.db[message.room]["messages"][key])
|
self.log.info(f"To be deleted: {self.db[message.room]["messages"][key]}")
|
||||||
reply = f"This message is deleted: { self.db[message.room]['messages'][key] }"
|
reply = f"This message is deleted: { self.db[message.room]['messages'][key] }"
|
||||||
del self.db[message.room]["messages"][key]
|
del self.db[message.room]["messages"][key]
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user