Skip to content

Commit 2bbfb45

Browse files
committed
Switch other plugins to use the new nicks checks
1 parent e3bba6e commit 2bbfb45

2 files changed

Lines changed: 4 additions & 13 deletions

File tree

plugins/foods.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@
5151
basic_food_data = defaultdict(dict)
5252

5353

54-
def is_valid(target):
55-
""" Checks if a string is a valid IRC nick. """
56-
if nick_re.match(target):
57-
return True
58-
else:
59-
return False
60-
61-
6254
def load_template_data(bot, filename, data_dict):
6355
data_dict.clear()
6456
food_dir = os.path.join(bot.data_dir, "food")
@@ -95,8 +87,8 @@ def make_cmd_list(value):
9587

9688

9789
def basic_food(food):
98-
def func(text, action):
99-
if not is_valid(text):
90+
def func(text, action, is_nick_valid):
91+
if not is_nick_valid(text):
10092
return "I can't give {} to that user.".format(food.unitname)
10193

10294
action(basic_format(text, basic_food_data[food.name]))

plugins/jokes.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,11 @@ def boobies(text):
100100

101101

102102
@hook.command("awesome", "iscool", "cool")
103-
def awesome(text):
103+
def awesome(text, is_nick_valid):
104104
"""- Prints a webpage to show <nick> how awesome they are."""
105-
nick_re = re.compile("^[A-Za-z0-9_|.\-\]\[]*$", re.I)
106105
link = 'http://is-awesome.cool/{}'
107106
nick = text.split(' ')[0]
108-
if nick_re.match(nick):
107+
if is_nick_valid(nick):
109108
return "{}: I am blown away by your recent awesome action(s). Please read \x02{}\x02".format(
110109
nick, link.format(nick)
111110
)

0 commit comments

Comments
 (0)