add formatting functions

This commit is contained in:
randomuser 2021-07-20 23:18:31 -05:00
parent c398cfa053
commit b41d315056
1 changed files with 7 additions and 3 deletions

10
main.py
View File

@ -30,16 +30,20 @@ class Server(BaseServer):
self.duckactive = True self.duckactive = True
self.duckactivetime = time.time() self.duckactivetime = time.time()
await self.msgall(lang["duck"]) await self.msgall(lang["duck"])
async def misstime(self):
return format(time.time() - self.lastduck, '.2f')
async def coughttime(self):
return format(self.lastduck - self.duckactivetime, '.2f')
async def duck_action(self, user, chan): async def duck_action(self, user, chan):
if self.duckactive: if self.duckactive:
self.duckactive = False self.duckactive = False
self.messages = 0 self.messages = 0
self.lastduck = time.time() self.lastduck = time.time()
await self.msgall(lang["duckcought"].format(user, chan, format(self.lastduck - self.duckactivetime, '.2f'))) await self.msgall(lang["duckcought"].format(user, chan, self.coughttime())))
elif self.lastduck != 0: elif self.lastduck != 0:
await self.msg(chan, lang["noduck"].format(format(time.time() - self.lastduck, '.2f')), user) await self.msg(chan, lang["noduck"].format(self.coughttime())), user)
else: else:
await self.msg(chan, lang["noduckstart"].format(format(time.time() - self.lastduck, '.2f')), user) await self.msg(chan, lang["noduckstart"], user)
async def line_read(self, line: Line): async def line_read(self, line: Line):
print(f"{self.name} < {line.format()}") print(f"{self.name} < {line.format()}")
if line.command == "001": if line.command == "001":