From 7db9a8ea2bee07a76a15cb5de51ab37ddc8dc707 Mon Sep 17 00:00:00 2001 From: dngfx <294904+dngfx@users.noreply.github.com> Date: Sat, 1 Sep 2018 11:40:08 +0100 Subject: [PATCH] Move lists out of scope --- modules/8all.py | 33 ++++++++++++++++----------------- modules/ducks.py | 23 +++++++++++------------ 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/modules/8all.py b/modules/8all.py index db5e4d3f..57be2da4 100644 --- a/modules/8all.py +++ b/modules/8all.py @@ -1,5 +1,20 @@ import random +CHOICES = [ + "Definitely", + "Yes", + "Probably", + "Maybe", + "Probably not", + "No", + "Definitely not", + "I don't know", + "Ask again later", + "The answer is unclear", + "Absolutely", + "Dubious at best", + "I'm on a break, ask again later" +] class Module(object): def __init__(self, bot, events): @@ -11,20 +26,4 @@ class Module(object): ) def decide(selfs, event): - choices = [ - "Definitely", - "Yes", - "Probably", - "Maybe", - "Probably not", - "No", - "Definitely not", - "I don't know", - "Ask again later", - "The answer is unclear", - "Absolutely", - "Dubious at best", - "I'm on a break, ask again later" - ] - - event["stdout"].write(random.choice(choices)) + event["stdout"].write(random.choice(CHOICES)) diff --git a/modules/ducks.py b/modules/ducks.py index e50cc055..44b03d00 100644 --- a/modules/ducks.py +++ b/modules/ducks.py @@ -3,6 +3,15 @@ from threading import Timer import Utils import random +DUCK_LIST = [ + "・゜゜・。。・゜ ​ ゜\_O​< q​uack!", + "・゜゜・。。・゜ ​ ゜\_o< QUACK!", + "・゜゜・。 ​ 。・゜゜\​_ó< qu​ack!", + "・゜゜・。 ​ 。・゜゜\​_ó< qu​ack quack!", + "・゜゜ 。 ​ 。・゜ \​_ó< bawk!", + "・゜゜ 。 ​ 。・゜゜\​_ó< squawk!", + "・ ゜・。 ​ 。・゜゜ \​_ó< beep beep!" +] class Module(object): def __init__(self, bot, events): @@ -11,16 +20,6 @@ class Module(object): self.decoy_hooked = 0 self.duck_timer = None - self.duck_list = [ - "・゜゜・。。・゜ ​ ゜\_O​< q​uack!", - "・゜゜・。。・゜ ​ ゜\_o< QUACK!", - "・゜゜・。 ​ 。・゜゜\​_ó< qu​ack!", - "・゜゜・。 ​ 。・゜゜\​_ó< qu​ack quack!", - "・゜゜ 。 ​ 。・゜ \​_ó< bawk!", - "・゜゜ 。 ​ 。・゜゜\​_ó< squawk!", - "・ ゜・。 ​ 。・゜゜ \​_ó< beep beep!" - ] - events.on("received.command.bef").hook(self.duck_bef, help="Befriend a duck!") events.on("received.command.bang").hook(self.duck_bang, @@ -252,7 +251,7 @@ class Module(object): str) else active_duck if ducks_enabled == 1 and active_duck == 0: - channel.send_message(random.choice(self.duck_list)) + channel.send_message(random.choice(DUCK_LIST)) channel.set_setting("active-duck", 1) @@ -263,7 +262,7 @@ class Module(object): channel.set_setting("active-duck", 0) def duck_decoy(self, event): - event["stdout"].write(random.choice(self.duck_list)) + event["stdout"].write(random.choice(DUCK_LIST)) def set_decoy(self, event): channel = event["target"]