How to use the sopel.tools.Identifier function in sopel

To help you get started, we’ve selected a few sopel examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dasu / syrup-sopel-modules / animerss.py View on Github external
def rss(bot, trigger):
    if sopel.tools.Identifier(trigger.sender) == "#pancakes" and trigger.nick == bot.nick:
        time.sleep(5)
        bot.say("Starting RSS.")
        now = time.gmtime()
        time.sleep(3600)
        while True:
            time.sleep(7200)
            quietnow = datetime.datetime.utcnow().time()
            out = parse(now)
            if out:
                if quietnow >= datetime.time(3,00) or quietnow <= datetime.time(11,00):
                    pass
                else:
                    bot.say(out)
            now = time.gmtime()
github dasu / syrup-sopel-modules / sotd.py View on Github external
def sotd(bot, trigger):
    if(trigger.group(2)):
        res = mysql(action='select')
        if trigger.group(2).strip() == res[2].strip():
            return bot.say("Duplicate, song not added!")
        match = re.match(r'[(http(s)?):\/\/(www\.)?a-zA-Z0-9@:%._\+~#=]{2,256}(youtube|youtu|sc0tt|soundcloud|bandcamp|nicovideo)\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)', trigger.group(2), re.I)
        if match:
            bksongname = ""
            name = Identifier(trigger.nick)
            link = match.group(0)
            domain = urlparse(link)
            if(domain.netloc == 'youtu.be' or domain.netloc == 'www.youtu.be'):
                yt,bksongname = fetch_yt_video_info(bot, domain.path[1:])
                if yt == None:
                    return bot.say("Please do not .sotd a live channel")
                song = yt['title']
                if not os.path.exists("/path/to/songs/folder/{}".format(bksongname)):
                    bksongname = ""
            elif(domain.netloc == 'youtube.com' or domain.netloc == 'www.youtube.com'):
                yt,bksongname = fetch_yt_video_info(bot, domain.query[2:])
                if yt == None:
                    return bot.say("Please do not .sotd a live channel")
                song = yt['title']
                if not os.path.exists("/home/desu/htdocs/sotd/songs/{}".format(bksongname)):
                    bksongname = ""
github PromyLOPh / crocoite / contrib / celerycrocoite.py View on Github external
def checkCompletedJobs (bot, jobs):
    delete = set ()
    for i, data in jobs.items ():
        handle = data['handle']
        trigger = data['trigger']
        args = data['args']
        url = args['url']
        channel = trigger.sender
        user = trigger.nick
        if Identifier (channel) not in bot.channels:
            continue
        try:
            stats = handle.get (timeout=0.1)
            bot.msg (channel, '{}: {} ({}) finished. {} crashed, {} requests, {} failed, {} received.'.format (user, url,
                    handle.id, stats['crashed'], stats['requests'], stats['failed'],
                    prettyBytes (stats['bytesRcv'])))
            delete.add (handle.id)
        except celery.exceptions.TimeoutError:
            pass
        except Exception as e:
            # json serialization does not work well with exceptions. If their class
            # names are unique we can still distinguish them.
            ename = type (e).__name__
            if ename == 'TaskRevokedError':
                bot.msg (channel, '{}: {} ({}) was revoked'.format (user, url, handle.id))
            else: