Compare commits
2 Commits
c398cfa053
...
6dfe72a83a
Author | SHA1 | Date |
---|---|---|
randomuser | 6dfe72a83a | |
randomuser | b41d315056 |
14
main.py
14
main.py
|
@ -30,16 +30,22 @@ 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 duck_test(self):
|
||||||
|
if self.messages > 1 and random.randint(0, 99) < 10: await self.new_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":
|
||||||
|
@ -56,7 +62,7 @@ class Server(BaseServer):
|
||||||
return
|
return
|
||||||
|
|
||||||
self.messages += 1
|
self.messages += 1
|
||||||
if self.messages > 1 and random.randint(0, 100) < 10: await self.new_duck()
|
self.duck_test()
|
||||||
elif line.command == "INVITE":
|
elif line.command == "INVITE":
|
||||||
await self.send(build("JOIN", [line.params[1]]))
|
await self.send(build("JOIN", [line.params[1]]))
|
||||||
async def line_send(self, line: Line):
|
async def line_send(self, line: Line):
|
||||||
|
|
Loading…
Reference in New Issue