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()))
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)
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
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
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)
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])
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")
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
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))
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
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.")
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
def black(bot: Bot) -> None: """ BLACK GOLD """ bot.post("GOLD")
def teenage_saucerbot(bot: Bot) -> None: """ 69 """ bot.post('Nice 👌')
def dont_at_me(bot: Bot) -> None: """ @saucerbot - Don't @ me 🙄 """ bot.post("don't @ me 🙄")
def sneaky(bot: Bot) -> None: """ Handle other @saucerbot variants """ bot.post("you think you're sneaky don't you")
def catfacts(bot: Bot) -> None: """ Sends catfacts! """ catfact = requests.get(CATFACTS_URL).json() bot.post(catfact['fact'])
def lit(bot: Bot) -> None: """ Battle with the lit bot """ bot.post("You're not lit, I'm lit")
def gold(bot: Bot) -> None: """ GOLD BLACK """ bot.post("BLACK")
def you_suck_too_coach(bot: Bot) -> None: """ Sends 'YOU SUCK TOO COACH' """ bot.post("YOU SUCK TOO COACH")
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()
def pizza(bot: Bot) -> None: """ Complain about pizza """ bot.post("That is a false binary and you know it, asshole")
def like_if(bot: Bot) -> None: """ Nobody else can use like if! """ bot.post("Hey that's my job")
def anchor_down(bot: Bot) -> None: """ Posts go dores! """ bot.post("GO DORES")
def zo_is_dead(bot: Bot) -> None: """ Zo sux """ bot.post("Zo is dead. Long live saucerbot.")
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))
def go_dores(bot: Bot) -> None: """ Posts anchor down ⚓️ """ bot.post("ANCHOR DOWN ⚓️")