mirror of
https://github.com/SpiceBot/SpiceBot.git
synced 2026-11-11 06:00:59 -05:00
50 lines
1.8 KiB
Python
50 lines
1.8 KiB
Python
# coding=utf8
|
|
from __future__ import unicode_literals, absolute_import, division, print_function
|
|
|
|
# sopel imports
|
|
import sopel.module
|
|
|
|
import sopel_modules.spicemanip as spicemanip
|
|
|
|
import sopel_modules.SpiceBot as SpiceBot
|
|
|
|
|
|
@SpiceBot.prerun('module')
|
|
@sopel.module.commands('sherlock', 'username')
|
|
def bot_command_sherlock(bot, trigger, botcom):
|
|
|
|
netlist = list(SpiceBot.sherlock.dict.keys())
|
|
|
|
username = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
|
|
botcom.dict["args"] = spicemanip.main(botcom.dict["args"], "2+", 'list')
|
|
|
|
checklist = netlist
|
|
checklistname = 'all'
|
|
if SpiceBot.inlist(username, netlist):
|
|
checklistname = SpiceBot.inlist_match(username, netlist)
|
|
checklist = [checklistname]
|
|
username = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
|
|
|
|
bot.osd("Checking username " + username + " in " + checklistname + " network.")
|
|
|
|
inlist, notinlist = [], []
|
|
|
|
for social_network in checklist:
|
|
|
|
in_social = SpiceBot.sherlock.check_network(username, social_network)
|
|
if in_social:
|
|
inlist.append(social_network)
|
|
else:
|
|
notinlist.append(social_network)
|
|
|
|
if len(inlist):
|
|
if checklistname != 'all':
|
|
bot.osd(["The username " + username + " is in " + checklist[0], SpiceBot.sherlock.dict.get(social_network).get("url").format(username)])
|
|
else:
|
|
bot.osd(["The username " + username + " is in the following:", spicemanip.main(inlist, "andlist")], trigger.nick, 'NOTICE')
|
|
if len(notinlist):
|
|
if checklistname != 'all':
|
|
bot.osd(["The username " + username + " is NOT in the following:", spicemanip.main(notinlist, "andlist")])
|
|
else:
|
|
bot.osd(["The username " + username + " is NOT in the following:", spicemanip.main(notinlist, "andlist")], trigger.nick, 'NOTICE')
|