mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
update user tracking
This commit is contained in:
parent
ac10cb6306
commit
31524fa4b1
@ -91,6 +91,20 @@ class BotChannels():
|
|||||||
topic = re.sub(actual_topic, r'\1', topic)
|
topic = re.sub(actual_topic, r'\1', topic)
|
||||||
return topic
|
return topic
|
||||||
|
|
||||||
|
def add_channel(self, channel):
|
||||||
|
channel = str(channel).lower()
|
||||||
|
self.lock.acquire()
|
||||||
|
if channel not in self.channels:
|
||||||
|
self.channels.append(channel)
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def remove_channel(self, channel):
|
||||||
|
channel = str(channel).lower()
|
||||||
|
self.lock.acquire()
|
||||||
|
if channel in self.channels:
|
||||||
|
self.channels.remove(channel)
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
def bot_part_empty(self, bot):
|
def bot_part_empty(self, bot):
|
||||||
"""Don't stay in empty channels"""
|
"""Don't stay in empty channels"""
|
||||||
ignorepartlist = []
|
ignorepartlist = []
|
||||||
@ -103,8 +117,7 @@ class BotChannels():
|
|||||||
self.lock.acquire()
|
self.lock.acquire()
|
||||||
del self.dict['list'][channel.lower()]
|
del self.dict['list'][channel.lower()]
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
if channel.lower() in self.channels:
|
self.remove_channel(channel)
|
||||||
self.channels.remove(channel.lower())
|
|
||||||
|
|
||||||
def join_all_channels(self, bot):
|
def join_all_channels(self, bot):
|
||||||
if botconfig.SpiceBot_Channels.joinall:
|
if botconfig.SpiceBot_Channels.joinall:
|
||||||
@ -116,13 +129,13 @@ class BotChannels():
|
|||||||
bot.write(('SAJOIN', bot.nick, self.dict['list'][channel]['name']))
|
bot.write(('SAJOIN', bot.nick, self.dict['list'][channel]['name']))
|
||||||
|
|
||||||
if channel in list(bot.channels.keys()):
|
if channel in list(bot.channels.keys()):
|
||||||
if channel.lower() not in self.channels:
|
self.add_channel(channel)
|
||||||
self.channels.append(channel.lower())
|
|
||||||
|
|
||||||
def chanadmin_all_channels(self, bot):
|
def chanadmin_all_channels(self, bot):
|
||||||
# Chan ADMIN +a
|
# Chan ADMIN +a
|
||||||
for channel in list(bot.channels.keys()):
|
for channel in list(bot.channels.keys()):
|
||||||
if channel.startswith("#"):
|
if channel.startswith("#"):
|
||||||
|
self.add_channel(channel)
|
||||||
if channel not in botconfig.SpiceBot_Channels.chanignore:
|
if channel not in botconfig.SpiceBot_Channels.chanignore:
|
||||||
if botconfig.SpiceBot_Channels.operadmin:
|
if botconfig.SpiceBot_Channels.operadmin:
|
||||||
if not bot.channels[channel].privileges[bot.nick] < sopel.module.ADMIN:
|
if not bot.channels[channel].privileges[bot.nick] < sopel.module.ADMIN:
|
||||||
@ -131,8 +144,7 @@ class BotChannels():
|
|||||||
bot.part(channel)
|
bot.part(channel)
|
||||||
|
|
||||||
if channel not in list(bot.channels.keys()):
|
if channel not in list(bot.channels.keys()):
|
||||||
if channel.lower() in self.channels:
|
self.remove_channel(channel)
|
||||||
self.channels.remove(channel.lower())
|
|
||||||
|
|
||||||
def whois_ident(self, nick):
|
def whois_ident(self, nick):
|
||||||
nick = Identifier(nick)
|
nick = Identifier(nick)
|
||||||
@ -140,31 +152,36 @@ class BotChannels():
|
|||||||
return nick_id
|
return nick_id
|
||||||
|
|
||||||
def add_to_channel(self, channel, nick, nick_id=None):
|
def add_to_channel(self, channel, nick, nick_id=None):
|
||||||
channel = str(channel)
|
channel = str(channel).lower()
|
||||||
|
self.lock.acquire()
|
||||||
if not nick_id:
|
if not nick_id:
|
||||||
nick_id = self.whois_ident(nick)
|
nick_id = self.whois_ident(nick)
|
||||||
if channel.lower() not in list(self.dict['list'].keys()):
|
if channel.lower() not in list(self.dict['list'].keys()):
|
||||||
self.dict['list'][channel.lower()] = dict()
|
self.dict['list'][channel.lower()] = dict()
|
||||||
if 'users' not in self.dict['list'][channel.lower()]:
|
if 'users' not in self.dict['list'][channel.lower()]:
|
||||||
self.dict['list'][channel.lower()]['users'] = []
|
self.dict['list'][channel.lower()]['users'] = []
|
||||||
if nick_id not in self.dict['list'][channel.lower()]['users']:
|
if int(nick_id) not in self.dict['list'][channel.lower()]['users']:
|
||||||
self.dict['list'][channel.lower()]['users'].append(int(nick_id))
|
self.dict['list'][channel.lower()]['users'].append(int(nick_id))
|
||||||
if channel.lower() not in self.channels:
|
if channel.lower() not in self.channels:
|
||||||
self.channels.append(channel.lower())
|
self.channels.append(channel.lower())
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
def remove_from_channel(self, channel, nick, nick_id=None):
|
def remove_from_channel(self, channel, nick, nick_id=None):
|
||||||
channel = str(channel)
|
channel = str(channel).lower()
|
||||||
|
self.lock.acquire()
|
||||||
if not nick_id:
|
if not nick_id:
|
||||||
nick_id = self.whois_ident(nick)
|
nick_id = self.whois_ident(nick)
|
||||||
if channel.lower() not in list(self.dict['list'].keys()):
|
if channel.lower() not in list(self.dict['list'].keys()):
|
||||||
self.dict['list'][channel.lower()] = dict()
|
self.dict['list'][channel.lower()] = dict()
|
||||||
if 'users' not in self.dict['list'][channel.lower()]:
|
if 'users' not in self.dict['list'][channel.lower()]:
|
||||||
self.dict['list'][channel.lower()]['users'] = []
|
self.dict['list'][channel.lower()]['users'] = []
|
||||||
if nick_id in self.dict['list'][channel.lower()]['users']:
|
if int(nick_id) in self.dict['list'][channel.lower()]['users']:
|
||||||
self.dict['list'][channel.lower()]['users'].remove(nick_id)
|
self.dict['list'][channel.lower()]['users'].remove(int(nick_id))
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
def remove_all_from_channel(self, channel):
|
def remove_all_from_channel(self, channel):
|
||||||
channel = str(channel)
|
channel = str(channel).lower()
|
||||||
|
self.lock.acquire()
|
||||||
if channel.lower() not in list(self.dict['list'].keys()):
|
if channel.lower() not in list(self.dict['list'].keys()):
|
||||||
self.dict['list'][channel.lower()] = dict()
|
self.dict['list'][channel.lower()] = dict()
|
||||||
if 'users' not in self.dict['list'][channel.lower()]:
|
if 'users' not in self.dict['list'][channel.lower()]:
|
||||||
@ -172,6 +189,7 @@ class BotChannels():
|
|||||||
self.dict['list'][channel.lower()]['users'] = []
|
self.dict['list'][channel.lower()]['users'] = []
|
||||||
if channel.lower() in self.channels:
|
if channel.lower() in self.channels:
|
||||||
self.channels.remove(channel.lower())
|
self.channels.remove(channel.lower())
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
def channel_scan(self, bot):
|
def channel_scan(self, bot):
|
||||||
for channel in list(bot.channels.keys()):
|
for channel in list(bot.channels.keys()):
|
||||||
|
|||||||
@ -9,21 +9,27 @@ from .Tools import is_number, inlist, similar, array_arrangesort
|
|||||||
|
|
||||||
import spicemanip
|
import spicemanip
|
||||||
|
|
||||||
|
import threading
|
||||||
|
|
||||||
# TODO timestamp for new .seen
|
# TODO timestamp for new .seen
|
||||||
|
|
||||||
|
|
||||||
class BotUsers():
|
class BotUsers():
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
self.lock = threading.Lock()
|
||||||
self.dict = {
|
self.dict = {
|
||||||
"all": botdb.get_bot_value('users') or {},
|
"all": botdb.get_bot_value('users') or {},
|
||||||
"online": [],
|
"online": [],
|
||||||
"offline": [],
|
"offline": [],
|
||||||
|
"away": [], # TODO
|
||||||
"current": {},
|
"current": {},
|
||||||
}
|
}
|
||||||
"""during setup, all users from database are offline until marked online"""
|
"""during setup, all users from database are offline until marked online"""
|
||||||
for user_id in list(self.dict["all"].keys()):
|
for user_id in list(self.dict["all"].keys()):
|
||||||
|
self.lock.acquire()
|
||||||
self.dict["offline"].append(int(user_id))
|
self.dict["offline"].append(int(user_id))
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
def __getattr__(self, name):
|
def __getattr__(self, name):
|
||||||
''' will only get called for undefined attributes '''
|
''' will only get called for undefined attributes '''
|
||||||
@ -34,18 +40,21 @@ class BotUsers():
|
|||||||
raise Exception('User dict does not contain a function or key ' + str(name.lower()))
|
raise Exception('User dict does not contain a function or key ' + str(name.lower()))
|
||||||
|
|
||||||
def ID(self, nickinput):
|
def ID(self, nickinput):
|
||||||
|
self.lock.acquire()
|
||||||
if is_number(nickinput):
|
if is_number(nickinput):
|
||||||
nick_id = nickinput
|
nick_id = nickinput
|
||||||
if nick_id in list(self.dict["current"].keys()):
|
if nick_id in list(self.dict["current"].keys()):
|
||||||
nick = self.dict["current"][nick_id]["nick"]
|
nick = self.dict["current"][nick_id]["nick"]
|
||||||
elif nick_id in list(self.dict["all"].keys()) and len(self.dict["all"][nick_id]):
|
elif nick_id in list(self.dict["all"].keys()) and len(self.dict["all"][int(nick_id)]):
|
||||||
nick = self.dict["all"][nick_id][0]
|
nick = self.dict["all"][int(nick_id)][0]
|
||||||
else:
|
else:
|
||||||
raise Exception('ID ' + str(nickinput) + ' does not appear to be associated with a nick')
|
raise Exception('ID ' + str(nickinput) + ' does not appear to be associated with a nick')
|
||||||
|
self.lock.release()
|
||||||
return nick
|
return nick
|
||||||
else:
|
else:
|
||||||
nick_id = self.whois_ident(nickinput)
|
nick_id = self.whois_ident(nickinput)
|
||||||
return nick_id
|
self.lock.release()
|
||||||
|
return int(nick_id)
|
||||||
|
|
||||||
def whois_ident(self, nick, usercreate=True):
|
def whois_ident(self, nick, usercreate=True):
|
||||||
nick = Identifier(nick)
|
nick = Identifier(nick)
|
||||||
@ -62,23 +71,27 @@ class BotUsers():
|
|||||||
botdb.set_bot_value('users', self.dict["all"])
|
botdb.set_bot_value('users', self.dict["all"])
|
||||||
|
|
||||||
def add_to_all(self, nick, nick_id=None):
|
def add_to_all(self, nick, nick_id=None):
|
||||||
|
self.lock.acquire()
|
||||||
if not nick_id:
|
if not nick_id:
|
||||||
nick_id = self.ID(nick)
|
nick_id = self.ID(nick)
|
||||||
# add to all if not there
|
# add to all if not there
|
||||||
if nick_id not in list(self.dict["all"].keys()):
|
if int(nick_id) not in list(self.dict["all"].keys()):
|
||||||
self.dict["all"][nick_id] = []
|
self.dict["all"][int(nick_id)] = []
|
||||||
# add nick alias as index 0
|
# add nick alias as index 0
|
||||||
if nick in self.dict["all"][nick_id]:
|
if nick in self.dict["all"][int(nick_id)]:
|
||||||
self.dict["all"][nick_id].remove(nick)
|
self.dict["all"][int(nick_id)].remove(nick)
|
||||||
self.dict["all"][nick_id].insert(0, nick)
|
self.dict["all"][int(nick_id)].insert(0, nick)
|
||||||
|
self.lock.release()
|
||||||
self.save_user_db()
|
self.save_user_db()
|
||||||
|
|
||||||
def add_to_current(self, nick, nick_id=None):
|
def add_to_current(self, nick, nick_id=None):
|
||||||
|
self.lock.acquire()
|
||||||
if not nick_id:
|
if not nick_id:
|
||||||
nick_id = self.whois_ident(nick)
|
nick_id = self.whois_ident(nick)
|
||||||
# add to current if not there
|
# add to current if not there
|
||||||
if nick_id not in list(self.dict["current"].keys()):
|
if int(nick_id) not in list(self.dict["current"].keys()):
|
||||||
self.dict["current"][nick_id] = {"channels": [], "nick": nick}
|
self.dict["current"][int(nick_id)] = {"channels": [], "nick": nick}
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
def channel_scan(self, bot):
|
def channel_scan(self, bot):
|
||||||
for channel in list(bot.channels.keys()):
|
for channel in list(bot.channels.keys()):
|
||||||
@ -90,15 +103,44 @@ class BotUsers():
|
|||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_current(user, nick_id)
|
self.add_to_current(user, nick_id)
|
||||||
# set current nick
|
# set current nick
|
||||||
self.dict["current"][nick_id]["nick"] = user
|
self.mark_current_nick(user, nick_id)
|
||||||
# add joined channel to nick list
|
# add joined channel to nick list
|
||||||
if str(channel).lower() not in self.dict["current"][nick_id]["channels"]:
|
self.add_channel(channel, nick_id)
|
||||||
self.dict["current"][nick_id]["channels"].append(str(channel).lower())
|
|
||||||
# mark user as online
|
# mark user as online
|
||||||
if nick_id not in self.dict["online"]:
|
self.mark_user_online(nick_id)
|
||||||
self.dict["online"].append(int(nick_id))
|
|
||||||
if nick_id in self.dict["offline"]:
|
def mark_current_nick(self, nick, nick_id):
|
||||||
self.dict["offline"].remove(nick_id)
|
self.lock.acquire()
|
||||||
|
self.dict["current"][int(nick_id)]["nick"] = nick
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def add_channel(self, channel, nick_id):
|
||||||
|
self.lock.acquire()
|
||||||
|
if str(channel).lower() not in self.dict["current"][int(nick_id)]["channels"]:
|
||||||
|
self.dict["current"][int(nick_id)]["channels"].append(str(channel).lower())
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def remove_channel(self, channel, nick_id):
|
||||||
|
self.lock.acquire()
|
||||||
|
if str(channel).lower() in self.dict["current"][int(nick_id)]["channels"]:
|
||||||
|
self.dict["current"][int(nick_id)]["channels"].remove(str(channel).lower())
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def mark_user_online(self, nick_id):
|
||||||
|
self.lock.acquire()
|
||||||
|
if int(nick_id) not in self.dict["online"]:
|
||||||
|
self.dict["online"].append(int(nick_id))
|
||||||
|
if int(nick_id) in self.dict["offline"]:
|
||||||
|
self.dict["offline"].remove(int(nick_id))
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def mark_user_offline(self, nick_id):
|
||||||
|
self.lock.acquire()
|
||||||
|
if int(nick_id) in self.dict["online"]:
|
||||||
|
self.dict["online"].remove(int(nick_id))
|
||||||
|
if int(nick_id) not in self.dict["offline"]:
|
||||||
|
self.dict["offline"].append(int(nick_id))
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
def join(self, bot, trigger):
|
def join(self, bot, trigger):
|
||||||
if trigger.nick == bot.nick:
|
if trigger.nick == bot.nick:
|
||||||
@ -110,15 +152,11 @@ class BotUsers():
|
|||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_current(user, nick_id)
|
self.add_to_current(user, nick_id)
|
||||||
# set current nick
|
# set current nick
|
||||||
self.dict["current"][nick_id]["nick"] = user
|
self.mark_current_nick(user, nick_id)
|
||||||
# add joined channel to nick list
|
# add joined channel to nick list
|
||||||
if str(trigger.sender).lower() not in self.dict["current"][nick_id]["channels"]:
|
self.add_channel(trigger.sender, nick_id)
|
||||||
self.dict["current"][nick_id]["channels"].append(str(trigger.sender).lower())
|
|
||||||
# mark user as online
|
# mark user as online
|
||||||
if nick_id not in self.dict["online"]:
|
self.mark_user_online(nick_id)
|
||||||
self.dict["online"].append(int(nick_id))
|
|
||||||
if nick_id in self.dict["offline"]:
|
|
||||||
self.dict["offline"].remove(nick_id)
|
|
||||||
return
|
return
|
||||||
# Identify
|
# Identify
|
||||||
nick_id = self.whois_ident(trigger.nick)
|
nick_id = self.whois_ident(trigger.nick)
|
||||||
@ -127,15 +165,27 @@ class BotUsers():
|
|||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_current(trigger.nick, nick_id)
|
self.add_to_current(trigger.nick, nick_id)
|
||||||
# set current nick
|
# set current nick
|
||||||
self.dict["current"][nick_id]["nick"] = trigger.nick
|
self.mark_current_nick(trigger.nick, nick_id)
|
||||||
# add joined channel to nick list
|
# add joined channel to nick list
|
||||||
if str(trigger.sender).lower() not in self.dict["current"][nick_id]["channels"]:
|
self.add_channel(trigger.sender, nick_id)
|
||||||
self.dict["current"][nick_id]["channels"].append(str(trigger.sender).lower())
|
|
||||||
# mark user as online
|
# mark user as online
|
||||||
if nick_id not in self.dict["online"]:
|
self.mark_user_online(nick_id)
|
||||||
self.dict["online"].append(int(nick_id))
|
|
||||||
if nick_id in self.dict["offline"]:
|
def chat(self, bot, trigger):
|
||||||
self.dict["offline"].remove(nick_id)
|
if trigger.nick == bot.nick:
|
||||||
|
return
|
||||||
|
# Identify
|
||||||
|
nick_id = self.whois_ident(trigger.nick)
|
||||||
|
# Verify nick is in the all list
|
||||||
|
self.add_to_all(trigger.nick, nick_id)
|
||||||
|
# Verify nick is in the all list
|
||||||
|
self.add_to_current(trigger.nick, nick_id)
|
||||||
|
# set current nick
|
||||||
|
self.mark_current_nick(trigger.nick, nick_id)
|
||||||
|
# add joined channel to nick list
|
||||||
|
self.add_channel(trigger.sender, nick_id)
|
||||||
|
# mark user as online
|
||||||
|
self.mark_user_online(nick_id)
|
||||||
|
|
||||||
def quit(self, bot, trigger):
|
def quit(self, bot, trigger):
|
||||||
if trigger.nick == bot.nick:
|
if trigger.nick == bot.nick:
|
||||||
@ -147,25 +197,16 @@ class BotUsers():
|
|||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_current(trigger.nick, nick_id)
|
self.add_to_current(trigger.nick, nick_id)
|
||||||
# empty nicks channel list
|
# empty nicks channel list
|
||||||
if str(trigger.sender).lower() in self.dict["current"][nick_id]["channels"]:
|
self.remove_channel(trigger.sender, nick_id)
|
||||||
self.dict["current"][nick_id]["channels"].remove(str(trigger.sender).lower())
|
|
||||||
self.dict["current"][nick_id]["channels"] = []
|
|
||||||
# mark user as offline
|
# mark user as offline
|
||||||
if nick_id in self.dict["online"]:
|
self.mark_user_offline(nick_id)
|
||||||
self.dict["online"].remove(nick_id)
|
|
||||||
if nick_id not in self.dict["offline"]:
|
|
||||||
self.dict["offline"].append(int(nick_id))
|
|
||||||
|
|
||||||
def part(self, bot, trigger):
|
def part(self, bot, trigger):
|
||||||
if trigger.nick == bot.nick:
|
if trigger.nick == bot.nick:
|
||||||
for nick_id in list(self.dict["current"].keys()):
|
for nick_id in list(self.dict["current"].keys()):
|
||||||
if str(trigger.sender).lower() in self.dict["current"][nick_id]["channels"]:
|
self.remove_channel(trigger.sender, nick_id)
|
||||||
self.dict["current"][nick_id]["channels"].remove(str(trigger.sender).lower())
|
|
||||||
# mark offline
|
# mark offline
|
||||||
if not len(self.dict["current"][nick_id]["channels"]) and nick_id in self.dict["online"]:
|
self.mark_user_offline(nick_id)
|
||||||
self.dict["online"].remove(nick_id)
|
|
||||||
if not len(self.dict["current"][nick_id]["channels"]) and nick_id not in self.dict["offline"]:
|
|
||||||
self.dict["offline"].append(int(nick_id))
|
|
||||||
return
|
return
|
||||||
# Identify
|
# Identify
|
||||||
nick_id = self.whois_ident(trigger.nick)
|
nick_id = self.whois_ident(trigger.nick)
|
||||||
@ -174,25 +215,17 @@ class BotUsers():
|
|||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_current(trigger.nick, nick_id)
|
self.add_to_current(trigger.nick, nick_id)
|
||||||
# remove channel from nick list
|
# remove channel from nick list
|
||||||
if str(trigger.sender).lower() in self.dict["current"][nick_id]["channels"]:
|
self.remove_channel(trigger.sender, nick_id)
|
||||||
self.dict["current"][nick_id]["channels"].remove(str(trigger.sender).lower())
|
|
||||||
# mark offline
|
# mark offline
|
||||||
if not len(self.dict["current"][nick_id]["channels"]) and nick_id in self.dict["online"]:
|
self.mark_user_offline(nick_id)
|
||||||
self.dict["online"].remove(nick_id)
|
|
||||||
if not len(self.dict["current"][nick_id]["channels"]) and nick_id not in self.dict["offline"]:
|
|
||||||
self.dict["offline"].append(int(nick_id))
|
|
||||||
|
|
||||||
def kick(self, bot, trigger):
|
def kick(self, bot, trigger):
|
||||||
targetnick = Identifier(str(trigger.args[1]))
|
targetnick = Identifier(str(trigger.args[1]))
|
||||||
if targetnick == bot.nick:
|
if targetnick == bot.nick:
|
||||||
for nick_id in list(self.dict["current"].keys()):
|
for nick_id in list(self.dict["current"].keys()):
|
||||||
if str(trigger.sender).lower() in self.dict["current"][nick_id]["channels"]:
|
self.remove_channel(trigger.sender, nick_id)
|
||||||
self.dict["current"][nick_id]["channels"].remove(str(trigger.sender).lower())
|
|
||||||
# mark offline
|
# mark offline
|
||||||
if not len(self.dict["current"][nick_id]["channels"]) and nick_id in self.dict["online"]:
|
self.mark_user_offline(nick_id)
|
||||||
self.dict["online"].remove(nick_id)
|
|
||||||
if not len(self.dict["current"][nick_id]["channels"]) and nick_id not in self.dict["offline"]:
|
|
||||||
self.dict["offline"].append(int(nick_id))
|
|
||||||
return
|
return
|
||||||
# Identify
|
# Identify
|
||||||
nick_id = self.whois_ident(targetnick)
|
nick_id = self.whois_ident(targetnick)
|
||||||
@ -201,13 +234,9 @@ class BotUsers():
|
|||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_current(targetnick, nick_id)
|
self.add_to_current(targetnick, nick_id)
|
||||||
# remove channel from nick list
|
# remove channel from nick list
|
||||||
if str(trigger.sender).lower() in self.dict["current"][nick_id]["channels"]:
|
self.remove_channel(trigger.sender, nick_id)
|
||||||
self.dict["current"][nick_id]["channels"].remove(str(trigger.sender).lower())
|
|
||||||
# mark offline
|
# mark offline
|
||||||
if not len(self.dict["current"][nick_id]["channels"]) and nick_id in self.dict["online"]:
|
self.mark_user_offline(nick_id)
|
||||||
self.dict["online"].remove(nick_id)
|
|
||||||
if not len(self.dict["current"][nick_id]["channels"]) and nick_id not in self.dict["offline"]:
|
|
||||||
self.dict["offline"].append(int(nick_id))
|
|
||||||
|
|
||||||
def nick(self, bot, trigger):
|
def nick(self, bot, trigger):
|
||||||
newnick = Identifier(trigger)
|
newnick = Identifier(trigger)
|
||||||
@ -223,15 +252,11 @@ class BotUsers():
|
|||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_current(newnick, nick_id)
|
self.add_to_current(newnick, nick_id)
|
||||||
# set current nick
|
# set current nick
|
||||||
self.dict["current"][nick_id]["nick"] = newnick
|
self.mark_current_nick(newnick, nick_id)
|
||||||
# add joined channel to nick list
|
# add joined channel to nick list
|
||||||
if str(trigger.sender).lower() not in self.dict["current"][nick_id]["channels"]:
|
self.add_channel(trigger.sender, nick_id)
|
||||||
self.dict["current"][nick_id]["channels"].append(str(trigger.sender).lower())
|
|
||||||
# mark user as online
|
# mark user as online
|
||||||
if nick_id not in self.dict["online"]:
|
self.mark_user_online(nick_id)
|
||||||
self.dict["online"].append(int(nick_id))
|
|
||||||
if nick_id in self.dict["offline"]:
|
|
||||||
self.dict["offline"].remove(nick_id)
|
|
||||||
|
|
||||||
def mode(self, bot, trigger):
|
def mode(self, bot, trigger):
|
||||||
return
|
return
|
||||||
|
|||||||
@ -49,3 +49,8 @@ def users_mode(bot, trigger):
|
|||||||
@sopel.module.rule('.*')
|
@sopel.module.rule('.*')
|
||||||
def bot_channelscan_users(bot, trigger):
|
def bot_channelscan_users(bot, trigger):
|
||||||
SpiceBot.users.channel_scan(bot)
|
SpiceBot.users.channel_scan(bot)
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_users_chat(bot, trigger):
|
||||||
|
SpiceBot.users.chat(bot, trigger)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user