mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-13 06:59:53 -05:00
check if nicks are regged
This commit is contained in:
parent
9712707d67
commit
017cc48d95
@ -39,6 +39,7 @@ class BotEvents(object):
|
|||||||
self.RPL_ISUPPORT = '005' # This is a defined IRC event
|
self.RPL_ISUPPORT = '005' # This is a defined IRC event
|
||||||
self.RPL_WHOREPLY = '352' # This is a defined IRC event
|
self.RPL_WHOREPLY = '352' # This is a defined IRC event
|
||||||
self.RPL_NAMREPLY = '353' # This is a defined IRC event
|
self.RPL_NAMREPLY = '353' # This is a defined IRC event
|
||||||
|
self.RPL_WHOISREGNICK = '307' # this is an unrealircd event
|
||||||
self.BOT_UPTIME = time.time()
|
self.BOT_UPTIME = time.time()
|
||||||
self.BOT_WELCOME = '1001'
|
self.BOT_WELCOME = '1001'
|
||||||
self.BOT_READY = '1002'
|
self.BOT_READY = '1002'
|
||||||
|
|||||||
@ -28,6 +28,7 @@ class BotUsers():
|
|||||||
"offline": [],
|
"offline": [],
|
||||||
"away": [],
|
"away": [],
|
||||||
"current": {},
|
"current": {},
|
||||||
|
"registered": [],
|
||||||
}
|
}
|
||||||
"""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()):
|
||||||
@ -163,6 +164,8 @@ class BotUsers():
|
|||||||
return
|
return
|
||||||
# Identify
|
# Identify
|
||||||
nick_id = self.whois_ident(trigger.nick)
|
nick_id = self.whois_ident(trigger.nick)
|
||||||
|
# check if nick is registered
|
||||||
|
self.whois_send(bot, trigger.nick)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_all(trigger.nick, nick_id)
|
self.add_to_all(trigger.nick, nick_id)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
@ -179,6 +182,8 @@ class BotUsers():
|
|||||||
return
|
return
|
||||||
# Identify
|
# Identify
|
||||||
nick_id = self.whois_ident(trigger.nick)
|
nick_id = self.whois_ident(trigger.nick)
|
||||||
|
# check if nick is registered
|
||||||
|
self.whois_send(bot, trigger.nick)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_all(trigger.nick, nick_id)
|
self.add_to_all(trigger.nick, nick_id)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
@ -195,6 +200,8 @@ class BotUsers():
|
|||||||
return
|
return
|
||||||
# Identify
|
# Identify
|
||||||
nick_id = self.whois_ident(trigger.nick)
|
nick_id = self.whois_ident(trigger.nick)
|
||||||
|
# check if nick is registered
|
||||||
|
self.whois_send(bot, trigger.nick)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_all(trigger.nick, nick_id)
|
self.add_to_all(trigger.nick, nick_id)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
@ -213,6 +220,8 @@ class BotUsers():
|
|||||||
return
|
return
|
||||||
# Identify
|
# Identify
|
||||||
nick_id = self.whois_ident(trigger.nick)
|
nick_id = self.whois_ident(trigger.nick)
|
||||||
|
# check if nick is registered
|
||||||
|
self.whois_send(bot, trigger.nick)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_all(trigger.nick, nick_id)
|
self.add_to_all(trigger.nick, nick_id)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
@ -232,6 +241,8 @@ class BotUsers():
|
|||||||
return
|
return
|
||||||
# Identify
|
# Identify
|
||||||
nick_id = self.whois_ident(targetnick)
|
nick_id = self.whois_ident(targetnick)
|
||||||
|
# check if nick is registered
|
||||||
|
self.whois_send(bot, targetnick)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_all(targetnick, nick_id)
|
self.add_to_all(targetnick, nick_id)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
@ -247,6 +258,8 @@ class BotUsers():
|
|||||||
newnick = Identifier(trigger)
|
newnick = Identifier(trigger)
|
||||||
if oldnick == bot.nick or newnick == bot.nick:
|
if oldnick == bot.nick or newnick == bot.nick:
|
||||||
return
|
return
|
||||||
|
# check if nick is registered
|
||||||
|
self.whois_send(bot, newnick)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
self.add_to_all(oldnick, old_nick_id)
|
self.add_to_all(oldnick, old_nick_id)
|
||||||
# Verify nick is in the all list
|
# Verify nick is in the all list
|
||||||
@ -297,6 +310,8 @@ class BotUsers():
|
|||||||
self.add_channel(channel, nick_id)
|
self.add_channel(channel, nick_id)
|
||||||
# mark user as online
|
# mark user as online
|
||||||
self.mark_user_online(nick_id)
|
self.mark_user_online(nick_id)
|
||||||
|
# check if nick is registered
|
||||||
|
self.whois_send(bot, nick)
|
||||||
|
|
||||||
def rpl_who(self, bot, trigger):
|
def rpl_who(self, bot, trigger):
|
||||||
if len(trigger.args) < 2 or trigger.args[1] not in self.who_reqs:
|
if len(trigger.args) < 2 or trigger.args[1] not in self.who_reqs:
|
||||||
@ -319,6 +334,28 @@ class BotUsers():
|
|||||||
self.add_channel(channel, nick_id)
|
self.add_channel(channel, nick_id)
|
||||||
# mark user as online
|
# mark user as online
|
||||||
self.mark_user_online(nick_id)
|
self.mark_user_online(nick_id)
|
||||||
|
# check if nick is registered
|
||||||
|
self.whois_send(bot, nick)
|
||||||
|
|
||||||
|
def rpl_whois(self, bot, trigger):
|
||||||
|
if not bot.config.SpiceBot_regnick.regnick:
|
||||||
|
return
|
||||||
|
nick = trigger.args[1]
|
||||||
|
if str(nick).lower() in [x.lower() for x in self.dict["registered"]]:
|
||||||
|
return
|
||||||
|
self.whois_handle(nick)
|
||||||
|
|
||||||
|
def whois_handle(self, nick):
|
||||||
|
self.lock.acquire()
|
||||||
|
if str(nick).lower() in [x.lower() for x in self.dict["registered"]]:
|
||||||
|
self.dict["registered"].append(str(nick))
|
||||||
|
self.lock.release()
|
||||||
|
|
||||||
|
def whois_send(self, bot, nick):
|
||||||
|
if not bot.config.SpiceBot_regnick.regnick:
|
||||||
|
return
|
||||||
|
if str(nick).lower() not in [x.lower() for x in self.dict["registered"]]:
|
||||||
|
bot.write(['WHOIS', str(nick)])
|
||||||
|
|
||||||
def account(self, bot, trigger):
|
def account(self, bot, trigger):
|
||||||
# Identify
|
# Identify
|
||||||
@ -423,6 +460,12 @@ class BotUsers():
|
|||||||
if str(trigger.sender).lower() not in self.dict["current"][nick_id]["channels"]:
|
if str(trigger.sender).lower() not in self.dict["current"][nick_id]["channels"]:
|
||||||
return {"targetgood": False, "error": "It looks like " + self.nick_actual(target) + " is online right now, but in a different channel.", "reason": "diffchannel"}
|
return {"targetgood": False, "error": "It looks like " + self.nick_actual(target) + " is online right now, but in a different channel.", "reason": "diffchannel"}
|
||||||
|
|
||||||
|
# not a registered nick
|
||||||
|
if "unregged" not in targetbypass:
|
||||||
|
if bot.config.SpiceBot_regnick.regnick:
|
||||||
|
if str(nick).lower() not in [x.lower() for x in self.dict["registered"]]:
|
||||||
|
return {"targetgood": False, "error": "It looks like " + self.nick_actual(target) + " is not a registered nick.", "reason": "unregged"}
|
||||||
|
|
||||||
return targetgood
|
return targetgood
|
||||||
|
|
||||||
def random_valid_target(self, bot, trigger, outputtype):
|
def random_valid_target(self, bot, trigger, outputtype):
|
||||||
|
|||||||
@ -65,4 +65,4 @@ def configure(config):
|
|||||||
config.SpiceBot_Sherlock.configure_setting('extra', 'SpiceBot_Sherlock API Extra directory')
|
config.SpiceBot_Sherlock.configure_setting('extra', 'SpiceBot_Sherlock API Extra directory')
|
||||||
|
|
||||||
config.define_section("SpiceBot_regnick", SpiceBot_RegNicks_MainSection, validate=False)
|
config.define_section("SpiceBot_regnick", SpiceBot_RegNicks_MainSection, validate=False)
|
||||||
config.SpiceBot_Channels.configure_setting('regnick', 'SpiceBot_Channels Announce New Channels')
|
config.SpiceBot_Channels.configure_setting('regnick', 'SpiceBot_regnick Only allow regged nicks')
|
||||||
|
|||||||
@ -80,3 +80,9 @@ def account_notify_users(bot, trigger):
|
|||||||
@sopel.module.rule('.*')
|
@sopel.module.rule('.*')
|
||||||
def track_notify_users(bot, trigger):
|
def track_notify_users(bot, trigger):
|
||||||
SpiceBot.users.track_notify(bot, trigger)
|
SpiceBot.users.track_notify(bot, trigger)
|
||||||
|
|
||||||
|
|
||||||
|
@sopel.module.event(SpiceBot.events.RPL_WHOISREGNICK)
|
||||||
|
@sopel.module.rule('.*')
|
||||||
|
def bot_whois_user(bot, trigger):
|
||||||
|
SpiceBot.users.rpl_whois(bot, trigger)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user