mirror of
https://github.com/nichkara/InfinitumBotty.git
synced 2026-06-11 06:36:24 +02:00
Update MathRunObserver.py
Changed command to lowercase Command must be first word in message Implemented stopmath Minor fix in score message to send (removed apology. it's not botty's fault)
This commit is contained in:
@@ -10,7 +10,7 @@ class MathRunObserver(PrivMsgObserverPrototype):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def help():
|
def help():
|
||||||
return '.startmath startet eine Reihe von Aufgaben. .stopmath beendet sie. Lösungen mit ".s Lösung" eingeben.'
|
return '".startmath" startet eine Reihe von Aufgaben. ".stopmath" beendet sie. Lösungen mit ".s Lösung" eingeben.'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@@ -21,16 +21,18 @@ class MathRunObserver(PrivMsgObserverPrototype):
|
|||||||
self.oldSolution = 0
|
self.oldSolution = 0
|
||||||
|
|
||||||
def update_on_priv_msg(self, data, connection: Connection):
|
def update_on_priv_msg(self, data, connection: Connection):
|
||||||
if data['message'].find('.s ') != -1 :
|
if data['message'].startswith('.s ') and not data['message'].startswith('.startmath') and not data['message'].startswith('.stopmath'):
|
||||||
self.solution(data, connection)
|
self.solution(data, connection)
|
||||||
if data['message'].find('.startmath') != -1:
|
if data['message'].startswith('.startmath'):
|
||||||
self.start_math(data, connection)
|
self.start_math(data, connection)
|
||||||
|
if data['message'].startswith('.stopmath'):
|
||||||
|
self.stop_math(data, connection)
|
||||||
|
|
||||||
def solution(self, data, connection):
|
def solution(self, data, connection):
|
||||||
nick = data["nick"]
|
nick = data["nick"]
|
||||||
solutionByPlayer = data['message'].split()[1]
|
solutionByPlayer = data['message'].split()[1]
|
||||||
if solutionByPlayer is None:
|
if solutionByPlayer is None:
|
||||||
connection.send_back("Sorry du hast keine Lösung angegeben " + nick, data)
|
connection.send_back("Du hast keine Lösung angegeben " + nick, data)
|
||||||
return
|
return
|
||||||
if solutionByPlayer == str(self.solutionForGame):
|
if solutionByPlayer == str(self.solutionForGame):
|
||||||
connection.send_channel("Korrekte Lösung " + nick)
|
connection.send_channel("Korrekte Lösung " + nick)
|
||||||
@@ -63,9 +65,13 @@ class MathRunObserver(PrivMsgObserverPrototype):
|
|||||||
self.stop_Timer(data, connection)
|
self.stop_Timer(data, connection)
|
||||||
|
|
||||||
def stop_math(self, data, connection):
|
def stop_math(self, data, connection):
|
||||||
|
|
||||||
for player in self.players.keys():
|
for player in self.players.keys():
|
||||||
connection.send_channel(player + " hat\t" + str(self.players[player]) + "\t Punkte")
|
if self.players[player] == 1:
|
||||||
connection.send_channel("Spiel beendet")
|
connection.send_channel(player + " hat\t" + str(self.players[player]) + "\tPunkt")
|
||||||
|
else:
|
||||||
|
connection.send_channel(player + " hat\t" + str(self.players[player]) + "\tPunkte")
|
||||||
|
connection.send_channel("Mathrun beendet")
|
||||||
self.players = {}
|
self.players = {}
|
||||||
self.solutionForGame = 0
|
self.solutionForGame = 0
|
||||||
self.type = 0
|
self.type = 0
|
||||||
@@ -73,4 +79,5 @@ class MathRunObserver(PrivMsgObserverPrototype):
|
|||||||
|
|
||||||
def stop_Timer(self, data, connection):
|
def stop_Timer(self, data, connection):
|
||||||
sleep(120)
|
sleep(120)
|
||||||
self.stop_math(data, connection)
|
if self.running:
|
||||||
|
self.stop_math(data, connection)
|
||||||
Reference in New Issue
Block a user