Beispiel #1
0
def job_response(evt: dict):
    """
    Messages users that have posted in #jobs-bulletin to remind them of the rules.

    @no_help
    """
    channel = bot.channels.get(evt.get("channel"))

    if channel.name != "jobs-bulletin":
        return

    if evt.get("subtype") in ["channel_join", "channel_leave"]:
        return

    jobs_bulletin = channel

    user = bot.users.get(evt.get("user"))

    if user is None or user.is_bot:
        return

    channel_message = (f"{user.name} has posted a new job in #jobs-bulletin! :tada: \n"
                       f"Please ask any questions in #jobs-discussion"
                       + f" or in a private message to <@{user.user_id}>")
    bot.post_message(jobs_bulletin, insert_channel_links(channel_message))

    user_message = (f"Hey {user.name}, you've just posted in #jobs-bulletin! \n"
                    f"Just a quick reminder of the conditions"
                    + f" surrounding the use of this channel:\n" +
                    f"\n".join(WELCOME_MESSAGES[1:] + [""]) +
                    f"*Broken one of these rules?*\n"
                    f"It's not too late! Please go back ASAP and"
                    + f" edit your message in #jobs-bulletin so it complies (or ask a committee"
                    + f" member to delete it). Thanks!")
    bot.post_message(user.user_id, insert_channel_links(user_message))
Beispiel #2
0
def welcome_jobs(event: dict):
    """
    Welcomes job seekers and employers to the #jobs-bulletin
    channel, setting expectations for both.

    @no_help
    """
    chan = bot.channels.get(event.get("channel"))
    if chan is None or chan.name != "jobs-bulletin":
        return

    user = bot.users.get(event.get("user"))

    if user is None or user.is_bot:
        return

    # Send instructions to user
    bot.post_message(user.user_id,
                     insert_channel_links(f"Hey {user.name}, welcome to #jobs-bulletin!"))
    for message in WELCOME_MESSAGES:
        time.sleep(MESSAGE_PAUSE)
        bot.post_message(user.user_id, insert_channel_links(message))