From 3b96eac446e58a428a7425b601118faef2fcc002 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Sat, 8 Jun 2019 14:07:33 -0400 Subject: [PATCH] channels user list --- sopel_modules/SpiceBot/Channels.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sopel_modules/SpiceBot/Channels.py b/sopel_modules/SpiceBot/Channels.py index 36faa2f..aac6c93 100644 --- a/sopel_modules/SpiceBot/Channels.py +++ b/sopel_modules/SpiceBot/Channels.py @@ -12,6 +12,7 @@ import threading from .Config import config as botconfig from .Database import db as botdb +from .Users import users as botusers class SpiceBot_Channels_MainSection(StaticSection): @@ -41,6 +42,23 @@ class BotChannels(): else: raise Exception('Channel dict does not contain a function or key ' + str(name.lower())) + def get_channel_users(self, channel, idtype="nick"): + + if channel.lower() not in list(self.dict["list"].keys()): + raise Exception('Channel ' + str(channel.lower()) + " does not seem to be on this server") + if 'users' not in list(self.dict["list"][channel.lower()].keys()): + raise Exception('Channel ' + str(channel.lower()) + " does not seem to be a channel the bot is in") + + nick_ids = self.dict["list"][channel.lower()]['users'] + if idtype.upper() == "ID": + return nick_ids + else: + nick_list = [] + for nick_id in nick_ids: + nickname = botusers.ID(nick_id) + nick_list.append(nickname) + return nick_list + def setup_channels(self): botconfig.define_section("SpiceBot_Channels", SpiceBot_Channels_MainSection, validate=False)