add language array
This commit is contained in:
parent
fff654a209
commit
c398cfa053
19
main.py
19
main.py
|
@ -7,11 +7,18 @@ from ircrobots import Bot as BaseBot
|
||||||
from ircrobots import Server as BaseServer
|
from ircrobots import Server as BaseServer
|
||||||
from ircrobots import ConnectionParams
|
from ircrobots import ConnectionParams
|
||||||
|
|
||||||
|
lang = {
|
||||||
|
"noduck": "there was no duck! you missed by {} seconds!",
|
||||||
|
"noduckstart": "there was no duck!",
|
||||||
|
"duckcought": "duck has been cought by {} in channel {} in {} seconds!",
|
||||||
|
"duck": "・゜゜・。。・゜゜\_o< QUACK!",
|
||||||
|
}
|
||||||
|
|
||||||
class Server(BaseServer):
|
class Server(BaseServer):
|
||||||
messages = 0
|
messages = 0
|
||||||
duckactive = False
|
duckactive = False
|
||||||
duckactivetime = time.time()
|
duckactivetime = 0
|
||||||
lastduck = time.time()
|
lastduck = 0
|
||||||
async def msg(self, chan, msg, usr=None):
|
async def msg(self, chan, msg, usr=None):
|
||||||
if usr != None:
|
if usr != None:
|
||||||
await self.send(build("PRIVMSG", [chan, usr + ": " + msg]))
|
await self.send(build("PRIVMSG", [chan, usr + ": " + msg]))
|
||||||
|
@ -22,15 +29,17 @@ class Server(BaseServer):
|
||||||
self.messages = 0
|
self.messages = 0
|
||||||
self.duckactive = True
|
self.duckactive = True
|
||||||
self.duckactivetime = time.time()
|
self.duckactivetime = time.time()
|
||||||
await self.msgall("oooooooooooC: QUACK!")
|
await self.msgall(lang["duck"])
|
||||||
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("duck has been cought by {} in channel {} in {} seconds!".format(user, chan, format(self.lastduck - self.duckactivetime, '.2f')))
|
await self.msgall(lang["duckcought"].format(user, chan, format(self.lastduck - self.duckactivetime, '.2f')))
|
||||||
|
elif self.lastduck != 0:
|
||||||
|
await self.msg(chan, lang["noduck"].format(format(time.time() - self.lastduck, '.2f')), user)
|
||||||
else:
|
else:
|
||||||
await self.msg(chan, "there was no duck! you missed by {} seconds!".format(format(time.time() - self.lastduck, '.2f')), user)
|
await self.msg(chan, lang["noduckstart"].format(format(time.time() - self.lastduck, '.2f')), 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":
|
||||||
|
|
Loading…
Reference in New Issue