How to use the sopel.module.priority 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 sopel-irc / sopel-extras / dicelog.py View on Github external
@priority('medium')
def dicelog(bot, trigger):
    """
    .dice [logfile]   - Rolls dice using the XdY format, also does
    basic math and drop lowest (XdYvZ). Saves result in logfile if given.
    """
    if not trigger.group(2):
        return bot.reply('You have to specify the dice you wanna roll.')

    # extract campaign
    if trigger.group(2).startswith('['):
        campaign, rollStr = trigger.group(2)[1:].split(']')
    else:
        campaign = ''
        rollStr = trigger.group(2).strip()
    campaign = campaign.strip()
    rollStr = rollStr.strip()
github sopel-irc / sopel-extras / dicelog.py View on Github external
@priority('medium')
def campaign(bot, trigger):
    if trigger.group(2):
        command, campaign = trigger.group(2).partition(' ')[::2]
    else:
        return bot.say('usage: campaign (list|add|del) ')
    if not command in ['list', 'add', 'del']:
        return bot.say('usage: campaign (list|add|del) ')
    if not command == 'list':
        if not trigger.admin:
            return
        elif not campaign:
            return bot.say('usage: campaign (list|add|del) ')
    campaign = campaign.lower().strip()
    campaigns = bot.config.dicelog.campaigns.split(', ')
    if campaign in campaigns:
        if command == 'del':
github openshift / openshift-tools / openshift_tools / ircbot / openshift_sre / openshift_sre.py View on Github external
@module.priority('high')
@module.rule(r'(.*)')
@module.example('++', ' has X karma')
@module.example('--', ' has X karma')
def apply_karma(bot, trigger):
    """Adds or removes karma from a given nick. Karma extends to all channels the bot exists in."""
    for karma_match in finditer(KARMA_REGEX, trigger):
        karma = karma_match.groupdict()
        if karma['nick'] == trigger.nick:
            bot.say('You can\'t change your own karma.')
            return
        debug(bot, 'Applying karma to {nick} in direction {direction}'.format(nick=karma['nick'],
                                                                              direction=karma['direction']))
        karma_amt = 1 if karma['direction'] == '++' else -1
        curr_karma = bot.db.get_nick_value(karma['nick'], 'karma')
        if curr_karma is None:
            curr_karma = 0
github anqxyr / jarvis / jarvis / modules / notes.py View on Github external
@sopel.module.priority('low')
def chat_activity(bot, tr):
    jarvis.notes.log_message(tr.nick, tr.sender, tr.group(0))
    tells = jarvis.notes.get_tells(tr.nick)
    if tells:
        bot.notice('You have {} new messages'.format(len(tells)), tr.nick)
    for t in tells:
        bot.send(t, private=True, force=True)
    for alert in jarvis.notes.get_alerts(tr.nick):
        bot.notice(alert, tr.nick)
github openshift / openshift-tools / openshift_tools / ircbot / openshift_sre / openshift_sre.py View on Github external
@module.priority('high')
def refer_to_topic(bot, trigger):
    """If any 'monitored channels' are mentioned in their own channel, refer the user to shift-lead or on-call user."""
    if bot.db.get_channel_value(trigger.sender, 'monitoring') and str(trigger.sender)[1:] in str(trigger):
        bot.say('Please reach out to the shift lead or on-call SRE')
        say_shift_leads(bot, trigger)