Esempio n. 1
0
def new_arrivals(bot: Bot, match) -> None:
    """
    Gets all the new arrivals
    """
    location = match.group('location') or 'Nashville'

    bot.post(get_new_arrivals(location.strip()))
Esempio n. 2
0
def whoami(bot: Bot, message: Message) -> None:
    """
    Display a user's historical nicknames
    """
    nicknames = HistoricalNickname.objects.filter(
        group_id=bot.group_id,
        groupme_id=message.user_id).order_by('-timestamp')

    response = ''

    # We only care about central time!
    now = arrow.now(CENTRAL_TIME)

    for nickname in nicknames:
        timestamp = arrow.get(nickname.timestamp)
        next_line = f'{nickname.nickname} {timestamp.humanize(now)}\n'
        if len(response) + len(next_line) > 1000:
            bot.post(response)
            response = next_line
        else:
            response += next_line

    # make sure to post the rest at the end
    if response:
        bot.post(response)
Esempio n. 3
0
def user_named_saucerbot(bot: Bot, message: Message, force_random: bool = False) -> bool:
    """
    Chastise people who make their name saucerbot
    """
    if message.name != 'saucerbot':
        return False

    # Send something dumb
    user_attach = RefAttach(message.user_id, f'@{message.name}')

    msg = random.choice(SAUCERBOT_MESSAGE_LIST)

    if force_random or msg == 'random':
        insult = get_insult()
        prefix = "Stop being a"
        if insult[0].lower() in ['a', 'e', 'i', 'o', 'u']:
            prefix = prefix + 'n'

        msg = prefix + ' ' + insult + ', '

    if isinstance(msg, str):
        msg = msg + user_attach

    bot.post(msg)

    return True
Esempio n. 4
0
def i_barely_know_her(bot: Bot, message: Message) -> bool:
    if message.text is not None and random.choice(range(0,
                                                        100)) < PERCENT_CHANCE:
        quip = get_quip(message)
        if quip is not None:
            bot.post(quip)
            return True
    return False
Esempio n. 5
0
def dores_win(bot: Bot) -> None:
    """
    The 'dores never win RIP
    """
    result = did_the_dores_win(True, True)
    if result is None:
        bot.post("I couldn't find the Vandy game " + EmojiAttach(1, 35))
    else:
        bot.post(result)
Esempio n. 6
0
def plate_party(bot: Bot):
    """
    This is to troll clark lolz but some future work could be fun on this
    """
    clark = get_member(bot, CLARK_USER_ID)

    if not clark:
        logger.error("Somehow clark escaped the group!!!!")
    else:
        quip = random.choice(plate_party_messages).split('|')
        bot.post(quip[0] + clark + quip[1])
Esempio n. 7
0
def troll(bot: Bot) -> None:
    """
    LOL Shaina is the troll
    """
    shaina = get_member(bot, SHAINA_USER_ID)
    pre_message: Union[RefAttach, str]

    if shaina:
        pre_message = shaina
    else:
        pre_message = "Shaina"

    bot.post(pre_message + " is the troll")
Esempio n. 8
0
def mars(bot: Bot,
         message: Message,
         chances: float = PICTURE_RESPONSE_CHANCE) -> bool:
    """
    Sends a message about mars if a user posts an image
    """
    for attachment in message.attachments:
        if attachment['type'] == 'image' and random.random() < chances:
            user_attach = RefAttach(message.user_id, f'@{message.name}')
            response = random.choice(PICTURE_RESPONSES)
            bot.post(response[:-1] + ", " + user_attach + response[-1])
            return True

    return False
Esempio n. 9
0
def ask_janet(bot: Bot, message: Message) -> None:
    """
    Get images matching the text
    """
    terms = janet.select_terms_from_message(message.text)
    if not terms or random.random() < 0.125:
        terms = ['cactus']  # CACTUS!!!
    photos = janet.search_flickr(terms)
    if not photos:
        bot.post(f"Sorry! I couldn't find anything for {terms}")
    else:
        url = janet.select_url(photos)
        groupme_image = janet.add_to_groupme_img_service(bot, url)
        bot.post(janet.create_message(groupme_image))
Esempio n. 10
0
def too_early_for_thai(bot: Bot, message: Message) -> bool:
    """
    It's too early for thai
    """
    # Grab an arrow time in central time
    timestamp = arrow.get(message.created_at).to(CENTRAL_TIME)

    hour = timestamp.time().hour

    with Path(tempfile.gettempdir(), 'thailock') as lockfile:
        if 3 <= hour < 8 and not lockfile.exists():
            bot.post("It's too early for thai")
            lockfile.touch()
            return True
        else:
            return False
Esempio n. 11
0
def save_saucer_id(bot: Bot, message: Message, match) -> None:
    """
    Save a person's saucer ID, so we can lookup tasted beers later
    """
    saucer_id = match.group('saucer_id')

    tasted_beers = get_tasted_brews(saucer_id)

    if not tasted_beers:
        bot.post(f"Hmmm, it looks like {saucer_id} isn't a valid Saucer ID.")
        return

    # Otherwise it's valid.  Just update or create
    _, created = SaucerUser.objects.update_or_create(groupme_id=message.user_id,
                                                     defaults={'saucer_id': saucer_id})

    user_attach = RefAttach(message.user_id, f'@{message.name}')

    action = 'saved' if created else 'updated'

    bot.post("Thanks, " + user_attach + f"!  I {action} your Saucer ID.")
Esempio n. 12
0
def system_messages(bot: Bot, message: Message) -> bool:
    """
    Process system messages:
    * Nickname changes
    * Added users
    * Removed users
    """
    if not message.system:
        return False

    remove_match = REMOVE_RE.match(message.text)
    add_match = ADD_RE.match(message.text)
    change_name_match = CHANGE_RE.match(message.text)

    # Grab an arrow time in UTC
    timestamp = arrow.get(message.created_at)

    if remove_match:
        bot.post(ComplexMessage([EmojiAttach(4, 36)]))
        return True

    if add_match:
        bot.post(ComplexMessage([EmojiAttach(2, 44)]))

        # Log the new member
        new_member = add_match.group('addee')
        nickname_entry(bot, new_member, timestamp)

        return True

    if change_name_match:
        bot.post(ComplexMessage([EmojiAttach(1, 81)]))

        # Log the name change
        new_name = change_name_match.group('new_name')
        nickname_entry(bot, new_name, timestamp)

        return True

    return False
Esempio n. 13
0
def black(bot: Bot) -> None:
    """
    BLACK GOLD
    """
    bot.post("GOLD")
Esempio n. 14
0
def teenage_saucerbot(bot: Bot) -> None:
    """
    69
    """
    bot.post('Nice 👌')
Esempio n. 15
0
def dont_at_me(bot: Bot) -> None:
    """
    @saucerbot - Don't @ me 🙄
    """
    bot.post("don't @ me 🙄")
Esempio n. 16
0
def sneaky(bot: Bot) -> None:
    """
    Handle other @saucerbot variants
    """
    bot.post("you think you're sneaky don't you")
Esempio n. 17
0
def catfacts(bot: Bot) -> None:
    """
    Sends catfacts!
    """
    catfact = requests.get(CATFACTS_URL).json()
    bot.post(catfact['fact'])
Esempio n. 18
0
def lit(bot: Bot) -> None:
    """
    Battle with the lit bot
    """
    bot.post("You're not lit, I'm lit")
Esempio n. 19
0
def gold(bot: Bot) -> None:
    """
    GOLD BLACK
    """
    bot.post("BLACK")
Esempio n. 20
0
def you_suck_too_coach(bot: Bot) -> None:
    """
    Sends 'YOU SUCK TOO COACH'
    """
    bot.post("YOU SUCK TOO COACH")
Esempio n. 21
0
            test_bot = Bot(
                gmi,
                group_id=test_group.group_id,
                name=TEST_BOT_NAME,
                callback_url="http://example.com",
                avatar_url=
                "https://i.groupme.com/750x700.jpeg.bda7c13e72f00b58193bd6af2114cb24c3919d1a",
                dm_notification=False,
            )
            test_bot.save()

        test_bot.save()
        test_group.save()
        test_group.refresh()

        test_bot.post("BotMessage")
        test_group.post("UserMessage")
        message = test_group.messages.recent()[0]
        message.like()
        message.refresh()

        gmi.user.get().enable_sms(15, "test")
        gmi.user.get().disable_sms()
        gmi.user.get().save()

    gmi.refresh()

    gmi.user.filter()
    gmi.groups.filter()
    gmi.groups.former()
    gmi.bots.filter()
Esempio n. 22
0
def pizza(bot: Bot) -> None:
    """
    Complain about pizza
    """
    bot.post("That is a false binary and you know it, asshole")
Esempio n. 23
0
def like_if(bot: Bot) -> None:
    """
    Nobody else can use like if!
    """
    bot.post("Hey that's my job")
Esempio n. 24
0
def anchor_down(bot: Bot) -> None:
    """
    Posts go dores!
    """
    bot.post("GO DORES")
Esempio n. 25
0
def zo_is_dead(bot: Bot) -> None:
    """
    Zo sux
    """
    bot.post("Zo is dead.  Long live saucerbot.")
Esempio n. 26
0
def search_brews(bot: Bot, match) -> None:
    """
    Search for beers from various saucers
    """
    search_text = match.group('search_text').strip()
    bot.post(brew_searcher.brew_info(search_text))
Esempio n. 27
0
def go_dores(bot: Bot) -> None:
    """
    Posts anchor down ⚓️
    """
    bot.post("ANCHOR DOWN ⚓️")