From 257042ac2ca01e6487c0cfe2cec47de959e90606 Mon Sep 17 00:00:00 2001 From: jesopo Date: Mon, 7 Oct 2019 12:51:44 +0100 Subject: [PATCH] combine find_user_settings() and find_user_settings_prefix() --- src/IRCChannel.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/IRCChannel.py b/src/IRCChannel.py index 0449e135..4920be68 100644 --- a/src/IRCChannel.py +++ b/src/IRCChannel.py @@ -187,14 +187,17 @@ class Channel(IRCObject.Object): default: typing.Any=None) -> typing.Any: return self.bot.database.user_channel_settings.get(user_id, self.id, setting, default) - def find_user_settings(self, user_id: int, pattern: str, - default: typing.Any=[]) -> typing.List[typing.Any]: - return self.bot.database.user_channel_settings.find(user_id, - self.id, pattern, default) - def find_user_settings_prefix(self, user_id: int, prefix: str, - default: typing.Any=[]) -> typing.List[typing.Any]: - return self.bot.database.user_channel_settings.find_prefix( - user_id, self.id, prefix, default) + def find_user_settings(self, user_id: int, pattern: str=None, + prefix: str=None, default: typing.Any=[] + ) -> typing.List[typing.Any]: + if not pattern == None: + return self.bot.database.user_channel_settings.find(user_id, + self.id, pattern, default) + elif not prefix == None: + return self.bot.database.user_channel_settings.find_prefix(user_id, + self.id, prefix, default) + else: + raise ValueError("Please provide 'pattern' or 'prefix'") def del_user_setting(self, user_id: int, setting: str): self.bot.database.user_channel_settings.delete(user_id, self.id, setting)