From 4a51c8e3f60dd5499c2c32b5264242edd5759775 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Mon, 1 Jul 2019 11:10:37 -0400 Subject: [PATCH 1/5] hmmmm ' --- sopel_modules/SpiceBot/Database.py | 3 +++ sopel_modules/SpiceBot/Users.py | 5 +++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sopel_modules/SpiceBot/Database.py b/sopel_modules/SpiceBot/Database.py index 42c2b80..078d3b1 100644 --- a/sopel_modules/SpiceBot/Database.py +++ b/sopel_modules/SpiceBot/Database.py @@ -612,6 +612,9 @@ class BotDatabase(): def alias_nick(self, nick, alias): return self.db.alias_nick(nick, alias) + def unalias_nick(self, alias): + return self.db.unalias_nick(alias) + def check_nick_id(self, nick): try: self.db.get_nick_id(nick, create=False) diff --git a/sopel_modules/SpiceBot/Users.py b/sopel_modules/SpiceBot/Users.py index 560596f..47e9fa4 100644 --- a/sopel_modules/SpiceBot/Users.py +++ b/sopel_modules/SpiceBot/Users.py @@ -240,12 +240,13 @@ class BotUsers(): self.mark_user_offline(nick_id) def nick(self, bot, trigger): + oldnick = trigger.nick newnick = Identifier(trigger) - if trigger.nick == bot.nick or newnick == bot.nick: + if oldnick == bot.nick or newnick == bot.nick: return # alias the nick if not botdb.check_nick_id(newnick): - botdb.alias_nick(trigger.nick, newnick) + botdb.alias_nick(oldnick, newnick) # Identify nick_id = self.whois_ident(newnick) # Verify nick is in the all list From 49a60567aff5644ed3d5870821e0831e53e965fa Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Mon, 1 Jul 2019 12:02:35 -0400 Subject: [PATCH 2/5] test --- sopel_modules/SpiceBot/Users.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sopel_modules/SpiceBot/Users.py b/sopel_modules/SpiceBot/Users.py index 47e9fa4..ba393f9 100644 --- a/sopel_modules/SpiceBot/Users.py +++ b/sopel_modules/SpiceBot/Users.py @@ -241,24 +241,26 @@ class BotUsers(): def nick(self, bot, trigger): oldnick = trigger.nick + old_nick_id = self.whois_ident(oldnick) newnick = Identifier(trigger) if oldnick == bot.nick or newnick == bot.nick: return - # alias the nick - if not botdb.check_nick_id(newnick): - botdb.alias_nick(oldnick, newnick) - # Identify - nick_id = self.whois_ident(newnick) # Verify nick is in the all list - self.add_to_all(newnick, nick_id) + self.add_to_all(oldnick, old_nick_id) # Verify nick is in the all list - self.add_to_current(newnick, nick_id) + self.add_to_current(oldnick, old_nick_id) # set current nick - self.mark_current_nick(newnick, nick_id) + self.mark_current_nick(newnick, old_nick_id) # add joined channel to nick list - self.add_channel(trigger.sender, nick_id) + self.add_channel(trigger.sender, old_nick_id) # mark user as online - self.mark_user_online(nick_id) + self.mark_user_online(old_nick_id) + # alias the nick + try: + botdb.alias_nick(oldnick, newnick) + except Exception as e: + old_nick_id = e + return def mode(self, bot, trigger): return From 1ead336e9b628ac45e231a5d557aabfed14b402d Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Mon, 1 Jul 2019 12:04:57 -0400 Subject: [PATCH 3/5] user command --- sopel_modules/SpiceBot_Core_Commands/Users.py | 15 +++++++++++++++ sopel_modules/SpiceBot_Core_Commands/__init__.py | 1 + 2 files changed, 16 insertions(+) create mode 100644 sopel_modules/SpiceBot_Core_Commands/Users.py diff --git a/sopel_modules/SpiceBot_Core_Commands/Users.py b/sopel_modules/SpiceBot_Core_Commands/Users.py new file mode 100644 index 0000000..5f0723f --- /dev/null +++ b/sopel_modules/SpiceBot_Core_Commands/Users.py @@ -0,0 +1,15 @@ +# coding=utf8 +from __future__ import unicode_literals, absolute_import, division, print_function +""" +This is the SpiceBot Users system. +""" +import sopel + +import sopel_modules.SpiceBot as SpiceBot + + +@SpiceBot.prerun('nickname') +@sopel.module.nickname_commands('users', 'user') +def nickname_comand_channels(bot, trigger, botcom): + bot.say("WIP") + return diff --git a/sopel_modules/SpiceBot_Core_Commands/__init__.py b/sopel_modules/SpiceBot_Core_Commands/__init__.py index e4b9d44..468cf8b 100644 --- a/sopel_modules/SpiceBot_Core_Commands/__init__.py +++ b/sopel_modules/SpiceBot_Core_Commands/__init__.py @@ -9,6 +9,7 @@ This module contains references only for other modules to utilize. from .CommandsQuery import * from .Commands import * from .Channels import * +from .Users import * from .Database import * from .Uptime import * from .Logs import * From 03ae15cdcf071f4714e88a860205724f2cb19718 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Mon, 1 Jul 2019 12:05:17 -0400 Subject: [PATCH 4/5] test --- sopel_modules/SpiceBot_Core_Commands/Users.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sopel_modules/SpiceBot_Core_Commands/Users.py b/sopel_modules/SpiceBot_Core_Commands/Users.py index 5f0723f..bb36e6c 100644 --- a/sopel_modules/SpiceBot_Core_Commands/Users.py +++ b/sopel_modules/SpiceBot_Core_Commands/Users.py @@ -10,6 +10,6 @@ import sopel_modules.SpiceBot as SpiceBot @SpiceBot.prerun('nickname') @sopel.module.nickname_commands('users', 'user') -def nickname_comand_channels(bot, trigger, botcom): +def nickname_comand_users(bot, trigger, botcom): bot.say("WIP") return From 51c2c8599967edbbef4673bacfb40729a051bdd0 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Mon, 1 Jul 2019 12:06:28 -0400 Subject: [PATCH 5/5] tweak defs --- sopel_modules/SpiceBot_Core_Processing/Channels.py | 4 ++-- sopel_modules/SpiceBot_Core_Processing/Users.py | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sopel_modules/SpiceBot_Core_Processing/Channels.py b/sopel_modules/SpiceBot_Core_Processing/Channels.py index 92b4a66..09940fd 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Channels.py +++ b/sopel_modules/SpiceBot_Core_Processing/Channels.py @@ -142,7 +142,7 @@ def bot_channelscan(bot, trigger): @sopel.module.event(SpiceBot.events.RPL_NAMREPLY) @sopel.module.rule('(.*)') -def handle_names(bot, trigger): +def handle_names_channels(bot, trigger): SpiceBot.channels.rpl_names(bot, trigger) @@ -150,5 +150,5 @@ def handle_names(bot, trigger): @sopel.module.rule('.*') @sopel.module.priority('high') @sopel.module.unblockable -def recv_who(bot, trigger): +def recv_who_channels(bot, trigger): SpiceBot.channels.rpl_who(bot, trigger) diff --git a/sopel_modules/SpiceBot_Core_Processing/Users.py b/sopel_modules/SpiceBot_Core_Processing/Users.py index d97fa11..07a7009 100644 --- a/sopel_modules/SpiceBot_Core_Processing/Users.py +++ b/sopel_modules/SpiceBot_Core_Processing/Users.py @@ -52,13 +52,13 @@ def bot_channelscan_users(bot, trigger): @sopel.module.rule('.*') -def bot_users_chat(bot, trigger): +def bot_users_chat_users(bot, trigger): SpiceBot.users.chat(bot, trigger) @sopel.module.event(SpiceBot.events.RPL_NAMREPLY) @sopel.module.rule('(.*)') -def handle_names(bot, trigger): +def handle_names_users(bot, trigger): SpiceBot.users.rpl_names(bot, trigger) @@ -66,17 +66,17 @@ def handle_names(bot, trigger): @sopel.module.rule('.*') @sopel.module.priority('high') @sopel.module.unblockable -def recv_who(bot, trigger): +def recv_who_users(bot, trigger): SpiceBot.users.rpl_who(bot, trigger) @sopel.module.event('ACCOUNT') @sopel.module.rule('.*') -def account_notify(bot, trigger): +def account_notify_users(bot, trigger): SpiceBot.users.account(bot, trigger) @sopel.module.event('AWAY') @sopel.module.rule('.*') -def track_notify(bot, trigger): +def track_notify_users(bot, trigger): SpiceBot.users.track_notify(bot, trigger)