font reset at the beginning of commands to stop wonkiness with highlighting and fix duck decoys.

This commit is contained in:
dngfx 2018-09-22 19:10:52 +01:00
parent 000ee14711
commit febb6d66e3
2 changed files with 12 additions and 7 deletions

View file

@ -29,7 +29,8 @@ class Out(object):
].decode("utf8").lstrip())
else:
self._text = ""
self.target.send_message(text, prefix="[%s] " % self.prefix())
self.target.send_message(text, prefix=Utils.FONT_RESET + "[%s] " %
self.prefix())
def set_prefix(self, prefix):
self.module_name = prefix
def has_text(self):

View file

@ -100,6 +100,7 @@ class Module(object):
def clear_ducks(self, channel):
rand_time = self.generate_next_duck_time()
del channel.games["ducks"]
channel.games["ducks"] = {'messages': 0, 'duck_spawned': 0,
'unique_users': [],
'next_duck_time': rand_time,
@ -126,10 +127,11 @@ class Module(object):
rand_time = random.randint(int(time()) + 1, int(time()) + 2)
return rand_time
def is_duck_visible(self, event):
def is_duck_visible(self, event, decoy=False):
channel = event["target"]
visible = channel.games["ducks"]["duck_spawned"]
visible = channel.games["ducks"]["decoy_spawned"] if \
decoy else channel.games["ducks"]["duck_spawned"]
return visible
def should_kick(self, event):
@ -259,11 +261,12 @@ class Module(object):
if self.is_duck_channel(channel) == False:
return
if self.is_duck_visible(event) == False:
if self.is_duck_visible(event, False) == False:
if self.should_kick(event):
self.kick_bef(event)
self.clear_ducks(channel)
event.eat()
self.clear_ducks(channel)
return
channel.games["ducks"][
@ -293,11 +296,12 @@ class Module(object):
if self.is_duck_channel(channel) == False:
return
if self.is_duck_visible(event) == False:
if self.is_duck_visible(event, False) == False:
if self.should_kick(event):
self.kick_bang(event)
self.clear_ducks(channel)
event.eat()
self.clear_ducks(channel)
return
channel.games["ducks"][