예제 #1
0
model_api = ModelAPI(port=str(args.port))


if not self.personality:
    self.personality = random.choice(self.model_api.personalities)
    logger.info(f"Using personality={self.personality}")
    
# TODO channel whitelist, only roast people who invite it or speak in a thread
@slack.RTMClient.run_on(event="message")
def say_hello(**payload):
    print("message", payload)
    data = payload["data"]
    web_client = payload["web_client"]
    rtm_client = payload["rtm_client"]
    channel_id = data["channel"]
    thread_ts = data["ts"]
    if "text" in data and "user" in data and not "subtype" in data:
        body = data["text"]
        name = data["user"]
        msg = model_api.roast(body, name, personality=args.personality)
        web_client.chat_postMessage(channel=channel_id, text=msg, thread_ts=thread_ts)
        logger.info(
            "Out msg %s", dict(channel=channel_id, text=msg, thread_ts=thread_ts)
        )


logger.info("Starting RTMClient")
rtm_client = slack.RTMClient(token=args.token)
rtm_client.start()
예제 #2
0
async def slack_client():
    # real-time-messaging Slack client
    client = slack.RTMClient(token=token, run_async=True)

    await asyncio.gather(client.start())
예제 #3
0
        move = data.get('text', []).split(" ")[1]
        who_moves = "white" if board.turn == chess.WHITE else "black"

        try:
            board.parse_san(move)  # This throws if not legal
            board.push_san(move)
            web_client.chat_postMessage(
                channel=channel_id,
                text=f"{who_moves} plays {move}!",
            )
        except ValueError as e:
            print(e)
            web_client.chat_postMessage(
                channel=channel_id,
                text=f"Illegal Move for {who_moves}!",
            )
    elif data.get('text', []) == "help":
        board.clear()

        web_client.chat_postMessage(
            channel=channel_id,
            text="""Say `status` for current game status
            Say `move SAN` to make a move. Eg: move e4
            """,
        )


slack_token = os.environ["SLACK_API_TOKEN"]
rtm_client = slack.RTMClient(token=slack_token)
rtm_client.start()
예제 #4
0
def main() -> None:
    """Entrypoint."""
    database.load()
    door.start()
    rtm_client = slack.RTMClient(token=os.environ['SLACK_API_TOKEN'])
    rtm_client.start()
예제 #5
0
    # Create a new onboarding tutorial.
    onboarding_tutorial = OnboardingTutorial(channel)

    # Get the onboarding message payload
    message = onboarding_tutorial.get_message_payload()

    # Post the onboarding message in Slack
    response = web_client.chat_postMessage(**message)

    # Capture the timestamp of the message we've just posted so
    # we can use it to update the message after a user
    # has completed an onboarding task.
    onboarding_tutorial.timestamp = response["ts"]

    # Store the message sent in onboarding_tutorials_sent
    if channel not in onboarding_tutorials_sent:
        onboarding_tutorials_sent[channel] = {}
    onboarding_tutorials_sent[channel][user_id] = onboarding_tutorial


logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())
ssl_context = ssl_lib.create_default_context(cafile=certifi.where())

s3 = S3Connection(os.environ['S3_KEY'], os.environ['S3_SECRET'])
os.environ["DEBUSSY"] = "LOL"
slack_token = os.environ["SLACK_BOT_TOKEN"]
rtm_client = slack.RTMClient(token=slack_token, ssl=ssl_context)
rtm_client.start()
예제 #6
0
파일: trivia.py 프로젝트: xgrg/slack-trivia
 def __init__(self, token, fp, su):
     self.client = slack.RTMClient(token=token, auto_reconnect=True)
     client = slack.WebClient(token=token)
     self.table = functions.get_users_table(client)
     self.fp = fp
     self.su = su
예제 #7
0
def main():
    rtm_client = slack.RTMClient(token=SLACK_TOKEN)
    rtm_client.start()
def start():
    slack_token = os.environ["SLACK_BOT_TOKEN"]
    rtm_client = slack.RTMClient(token=slack_token)
    rtm_client.start()
예제 #9
0
def checking(loop):
    ssl_context = ssl_lib.create_default_context(cafile=certifi.where())
    slack_token = "xoxb-795840878529-856613875153-zMXfzOYTYXrfQTVuevr1LEF5"
    asyncio.set_event_loop(loop)
    rtm_client = slack.RTMClient(token=slack_token, ssl=ssl_context, run_async=True, loop=loop)
    loop.run_until_complete(rtm_client.start())
예제 #10
0
 def run(self):
     if self.init():
         self.log.info("Slack bot connecting to server")
         self.slack_client = slack.RTMClient(token=self.slackBotToken)
         self.slack_client.on(event='message', callback=handle_message)
         self.slack_client.start()
예제 #11
0
				game.shield = message[len(message_words[0]) + 1:]
				utils.send_channel_message(game.channel_id, "<!channel>\nThe shield has been updated to %s!" \
					% game.shield)
			elif message_words[0] == "!set_end_words":
				game.end_string = message[len(message_words[0]) + 1:]
			save_game(game)

		else:
			print("throw")
			utils.send_users_message([user], "Unrecognized command! Or maybe unformatted. I'm disappointed. " + \
											"Message !help for a list of available commands!")
	except:
		print("input error")

if __name__ == "__main__":
	global game
	# with open('stdout.log', 'w') as stdout, redirect_stdout(stdout):
	# 	with open('errors.log', 'w') as stderr, redirect_stderr(stderr):
	game = Game(channel = "test-codeassassin", weapon = "chicken egg", shield = "banana")
	#game = load_game()
	while(1):
		rtm_client =  slack.RTMClient(token=utils.get_oauth_token())
		rtm_client.start()
	print("Done at %s" % date.today().strftime("%B %d, %Y"))






예제 #12
0
 def setUp(self):
     self.client = slack.RTMClient(token="xoxp-1234", auto_reconnect=False)
예제 #13
0
                webclient = payload['web_client']
                await webclient.chat_postMessage(channel=channel, text=message)


def parse_direct_mention(message_text):
    """
		Finds a direct mention (a mention that is at the beginning) in message text
		and returns the user ID which was mentioned. If there is no direct mention, returns None
	"""
    matches = re.search(MENTION_REGEX, message_text)
    # the first group contains the username, the second group contains the remaining message
    return (matches.group(1), matches.group(2).strip()) if matches else (None,
                                                                         None)


if __name__ == "__main__":
    # TODO (Future Work): Verify if it is possible to use @mentions in a more elegant way
    slack_web_client = slack.WebClient(SLACK_BOT_TOKEN)

    # extract the bot_id in order to check if it is mentioned in a channel conversation
    if bot_id is None:
        bot_id = slack_web_client.api_call("auth.test")["user_id"]

    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    slack_client = slack.RTMClient(token=SLACK_BOT_TOKEN,
                                   run_async=True,
                                   loop=loop)
    loop.run_until_complete(slack_client.start())
예제 #14
0
import slack

import apis.keys

my_token = apis.keys.SLACK_TOKEN

rtmclient = slack.RTMClient(token=my_token)
webclient = slack.WebClient(my_token)


def get_rtm_client():
    return rtmclient


def get_web_client():
    return webclient
 def setUp(self):
     setup_mock_web_api_server(self)
     self.client = slack.RTMClient(token="xoxp-1234",
                                   base_url="http://localhost:8888",
                                   auto_reconnect=False)
예제 #16
0
async def slack_main():
    loop = asyncio.get_event_loop()
    rtm_client = slack.RTMClient(token=slack_token, run_async=True, loop=loop)
    executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
    await asyncio.gather(loop.run_in_executor(executor, sync_loop),
                         rtm_client.start())
예제 #17
0
            web_client.chat_postMessage(
                channel=channel_id,
                text=("The score is now updated.")
                )

        if ('report' in data['text']) and not ('text' in data['text']):
            web_client.chat_postMessage(
                channel=channel_id,
                text=("Sending out a graphic report...")
                )
            EmailReports.Slackbot_Screenshot()
        if ('text' in data['text']) and ('report' in data['text']):
            web_client.chat_postMessage(
                channel=channel_id,
                text=("Sending out a text report...")
                )
            EmailReports.Slackbot_Text()

def post_img(filename, channel_id):
    response = client.files_upload(
        channels=channel_id,
        file=filename)
    assert response["ok"]

if __name__ == "__main__":
    slack_token = os.environ["SLACK_API_TOKEN"] #  Get API token from virtual environment (set in Autorun.py)
    client = slack.WebClient(token=slack_token, proxy='ENTER PROXY') 
    rtm_client = slack.RTMClient(token=slack_token, proxy='ENTER PROXY')
    rtm_client.start()
    
summary_parser = subparsers.add_parser('summary',
                                       help='Summarize a cluster by ID.')
summary_parser.add_argument('cluster', metavar='ID', help='The cluster ID.')
summary_parser.set_defaults(func=handle_summary)
set_summary_parser = subparsers.add_parser(
    'set-summary',
    help=
    'Set (or edit) the cluster summary.  The line following the set-summary command will be used in the summary subject, and subsequent lines will be used in the summary body.'
)
set_summary_parser.add_argument('cluster',
                                metavar='ID',
                                help='The cluster ID.')
set_summary_parser.set_defaults(func=handle_set_summary)
detail_parser = subparsers.add_parser(
    'detail',
    help='Upload a file to Slack with the cluster summary and all comments.')
detail_parser.add_argument('cluster', metavar='ID', help='The cluster ID.')
detail_parser.set_defaults(func=handle_detail)
comment_parser = subparsers.add_parser(
    'comment',
    help=
    'Add a comment on a cluster by ID.  The line following the comment command will be used in the summary subject, and subsequent lines will be used in the summary body.'
)
comment_parser.add_argument('cluster', metavar='ID', help='The cluster ID.')
comment_parser.set_defaults(func=handle_comment)

# start the RTM socket
rtm_client = slack.RTMClient(token=os.environ['SLACK_BOT_TOKEN'])
logger.info("bot starting...")
rtm_client.start()
예제 #19
0
def main():
    rtm_client = slack.RTMClient(token=os.environ["BOT_ACCESS_TOKEN"])
    print("bot START!")
    print(register)
    res = rtm_client.start()
    print(res)
예제 #20
0
 def live(self):
     info("Starting Real-Time Message monitoring")
     rtm_client = slack.RTMClient(token=self.args.get('token'))
     rtm_client.start()
예제 #21
0
slack_client = slack.WebClient(token=bot_token)


@slack.RTMClient.run_on(event='message')
def express_pure_rage(**payload):
    #RETURN ALL NEEDED INFORMATION TO DECIDE WHETHER OR NOT THE USER
    #SHOULD DIE
    data = payload['data']
    web_client = payload['web_client']
    rtm_client = payload['rtm_client']
    MESSAGE = data['text']
    if not MESSAGE.isupper():
        RESPONSE = "ICI, ON ÉCRIT EN MAJUSCULE! TU DEVRAIS ÉCRIRE: " + MESSAGE.upper(
        )
        channel_id = data['channel']
        thread_ts = data['ts']
        user = data['user']

        web_client.chat_postMessage(channel=channel_id,
                                    text=RESPONSE,
                                    as_user=True)


if __name__ == "__main__":
    if slack_client.rtm_connect():
        print("RAGEBOT IS CONNECTED! REEEEEEEEEE")
        rtm_client = slack.RTMClient(token=bot_token)
        rtm_client.start()
    else:
        print("CONNECTION FAILED! CHECK YOUR BOT TOKEN YOU DAMNED NORMIE!")
예제 #22
0
 def open(self, token):
     self.rtm_client = slack.RTMClient(token=token)
     self.rtm_client.start()
예제 #23
0
from BasicBot import respond


@slack.RTMClient.run_on(event='message')
def respond_to_message(**payload):

    data = payload['data']

    if 'subtype' in data and data['subtype'] == 'bot_message':
        return

    web_client = payload['web_client']
    content = data['text']

    print('Got a message: {}'.format(content))

    if content.startswith('<@'):
        content = content.split(' ', 1)[1]

    channel_id = data['channel']
    user = data['user']

    web_client.chat_postMessage(channel=channel_id,
                                text='<@{}> {}'.format(user, respond(content)))


print('Bot running ------------\n')

client = slack.RTMClient(token=bot_token, connect_method='rtm.start')
client.start()
예제 #24
0

@slack.RTMClient.run_on(event='message')
def say_hello(**payload):
    # print(payload.keys())
    data = payload['data']
    # print(data)
    web_client = payload['web_client']
    # rtm_client = payload['rtm_client']
    if 'text' in data.keys():
        print(data['text'])
        if 'Hello' in data['text']:
            channel_id = data['channel']
            thread_ts = data['ts']
            user = data['user']

            web_client.chat_postMessage(channel=channel_id,
                                        text=f'Hi <@{user}>!',
                                        thread_ts=thread_ts,
                                        username=USER)
            # print('Done!')


if __name__ == '__main__':

    rtm_client = slack.RTMClient(token=_TOKEN)
    try:
        rtm_client.start()
    except KeyboardInterrupt:
        rtm_client.stop()
예제 #25
0
    def __init__(self):
        _LOGGER.debug('new SlackBridge instance')

        _LOGGER.debug('connecting to redis')
        self.redis = redis.Redis(host=REDIS_HOSTNAME,
                                 port=REDIS_PORT,
                                 password=REDIS_PASSWORD,
                                 charset="utf-8",
                                 decode_responses=True)

        _LOGGER.debug('connecting to zulip')
        self.zulip_client = zulip.Client(email=ZULIP_BOT_EMAIL,
                                         api_key=ZULIP_API_KEY,
                                         site=ZULIP_URL)
        self.zulip_thread = threading.Thread(target=self.run_zulip_listener)
        self.zulip_thread.setDaemon(True)
        self.zulip_thread.start()
        #        self.zulip_ev_thread = threading.Thread(target=self.run_zulip_ev)
        #        self.zulip_ev_thread.setDaemon(True)
        #        self.zulip_ev_thread.start()

        self.user_formatter = slack_reformat.SlackUserFormatter(
            lambda user_id: self.get_slack_user(
                user_id, web_client=self.slack_web_client))

        if GROUPME_ENABLE:
            _LOGGER.debug('connecting to groupmes')
            self.groupme_threads = {}
            for channel, conf in GROUPME_TWO_WAY.items():
                self.groupme_threads[channel] = threading.Thread(
                    target=self.run_groupme_listener, args=(channel, conf))
                self.groupme_threads[channel].setDaemon(True)
                self.groupme_threads[channel].start()

        @slack.RTMClient.run_on(event='message')
        async def receive_slack_msg(**payload):
            _LOGGER.debug('caught slack message')
            _LOGGER.debug('JSON: %s' % json.dumps(payload['data']))
            try:
                data = payload['data']
                web_client = payload['web_client']
                rtm_client = payload['rtm_client']
                bot = False
                edit = False
                delete = False
                me = False
                attachments = []
                files = []

                if ('subtype' in data
                        and data['subtype'] == 'message_changed'):
                    data.update(data['message'])
                    edit = True
                elif ('subtype' in data
                      and data['subtype'] == 'message_deleted'):
                    data.update(data['previous_message'])
                    delete = True

                if ('subtype' in data
                        and data['subtype'] == 'message_replied'):
                    return

                # This needs to be below the handling of message_changed and
                # message_deleted as the message might be replaced with a
                # bot_message.
                if (('subtype' in data and data['subtype'] == 'bot_message')
                        or ('bot_id' in data and 'user' not in data)):
                    bot_id = data['bot_id']
                    user_id = await self.get_slack_bot(bot_id,
                                                       web_client=web_client)

                    if not user_id:
                        _LOGGER.debug("no bot found")
                        return
                    if user_id == SLACK_BOT_ID:
                        _LOGGER.debug("oops that's my message!")
                        return
                    bot = True

                if not bot:
                    user_id = data['user']

                channel_id = data['channel']
                thread_ts = data['ts']

                user = await self.get_slack_user(user_id,
                                                 web_client=web_client)
                if not user:
                    return
                channel = await self.get_slack_channel(channel_id,
                                                       web_client=web_client)
                if not channel:
                    return

                # Clean up formatting of message before we forward it.
                # This does not deal with attachments,
                # which are dealt with in a per-service way.
                data['text'] = \
                    await slack_reformat.reformat_slack_text(self.user_formatter,
                                                             data['text'])

                if (channel['type'] == 'channel'
                        or channel['type'] == 'private-channel'):
                    msg = data['text']
                    channel_name = channel['name']
                    private = (channel['type'] == 'private-channel')
                    if ('subtype' in data
                            and data['subtype'] in GROUP_UPDATES):
                        msg_id = None
                        user = None
                    elif ('subtype' in data
                          and data['subtype'] == 'me_message'):
                        msg_id = None
                        me = True
                        if 'edited' in data:
                            edit = True
                    elif 'client_msg_id' in data:
                        msg_id = data['client_msg_id']
                    elif 'bot_id' in data:
                        msg_id = None
                    else:
                        msg_id = None
                        _LOGGER.warning("no msg id for user %s: %s", user,
                                        data)

                    if 'attachments' in data:
                        attachments = data['attachments']

                    if 'files' in data:
                        files = data['files']

                    # TODO: When real support for 'files' is implemented,
                    # it should probably be in the format_attachments_for_zulip
                    # call.

            #        if 'files' in data:
            #            for file in data['files']:
            #                web_client.files_sharedPublicURL(id=file['id'])
            #                if msg == '':
            #                    msg = file['permalink_public']
            #                else:
            #                    msg += '\n' + file['permalink_public']

                    formatted_attachments = \
                        await slack_reformat.format_attachments_from_slack(
                            msg, attachments,
                            edit or delete, self.user_formatter)

                    # Assumes that both markdown and plaintext need a newline together.
                    needs_leading_newline = \
                        (len(msg) > 0 or len(formatted_attachments['markdown']) > 0)
                    formatted_files = slack_reformat.format_files_from_slack(
                        files, needs_leading_newline, SLACK_TOKEN,
                        self.zulip_client)

                    zulip_message_text = \
                        msg + formatted_attachments['markdown'] + formatted_files['markdown']

                    if channel_name in PUBLIC_TWO_WAY:
                        self.send_to_zulip(channel_name,
                                           zulip_message_text,
                                           user=user,
                                           send_public=True,
                                           slack_id=msg_id,
                                           edit=edit,
                                           delete=delete,
                                           me=me)

                    # If we are not sending publicly, then we are sending for
                    # logging purposes, which might be disabled.
                    if ZULIP_LOG_ENABLE:
                        self.send_to_zulip(channel_name,
                                           zulip_message_text,
                                           user=user,
                                           slack_id=msg_id,
                                           edit=edit,
                                           delete=delete,
                                           me=me,
                                           private=private)

                    # If groupme is enabled, then send there.  Note that this
                    # will also filter to only the GROUPME_TWO_WAY channels
                    # within the send_to_groupme call.
                    if GROUPME_ENABLE:
                        groupme_message_text = \
                            msg + formatted_attachments['plaintext'] + formatted_files['plaintext']

                        self.send_to_groupme(channel_name,
                                             groupme_message_text,
                                             user=user,
                                             edit=edit,
                                             delete=delete,
                                             me=me)

                elif channel['type'] == 'im':
                    _LOGGER.debug('updating user display name')
                    user = await self.get_slack_user(user_id,
                                                     web_client=web_client,
                                                     force_update=True)
                    await self.slack_web_client.chat_postMessage(
                        channel=channel_id,
                        text="OK, I have updated your display name for Slack \
messgaes on Zulip. Your name is now seen as: *" + user + "*.",
                        mrkdwn=True)
                elif channel['type'] == 'group':
                    await self.slack_web_client.chat_postMessage(
                        channel=channel_id,
                        text="I'm not sure what I'm doing here, so I'll just \
be annoying.",
                        mrkdwn=True)
            except:
                e = sys.exc_info()
                exc_type, exc_value, exc_traceback = e
                _LOGGER.error(
                    'Error receive slack message: %s, %s',
                    repr(
                        traceback.format_exception(exc_type, exc_value,
                                                   exc_traceback)), data)

        _LOGGER.debug('connecting to slack')
        self.slack_loop = asyncio.new_event_loop()
        self.slack_rtm_client = slack.RTMClient(token=SLACK_TOKEN,
                                                run_async=True,
                                                loop=self.slack_loop)
        self.slack_web_client = slack.WebClient(token=SLACK_TOKEN,
                                                run_async=True,
                                                loop=self.slack_loop)
        self.slack_log_format = '%(asctime)s %(name)-12s %(levelname)-8s %(message)s'
        self.slack_log_formatter = logging.Formatter(self.slack_log_format)
        self.slack_logger = SlackHandler(self.slack_web_client,
                                         self.slack_loop, SLACK_ERR_CHANNEL)
        self.slack_logger.setLevel(logging.INFO)
        self.slack_logger.setFormatter(self.slack_log_formatter)
        logging.getLogger('').addHandler(self.slack_logger)
        self.slack_loop.run_until_complete(self.slack_rtm_client.start())
예제 #26
0
ombi_api = 'apikey=INSERT YOUR KEY'
root_folder = '/Users/azuser/media/movies'


headers = {
    'Content-Type': 'application/json',
    }

params = (
    ('apikey', 'xxxxxx'),
        )



# instantiate Slack client
rtmclient = slack.RTMClient(token='INSERT YOUR TOKEN')
# starterbot's user ID in Slack: value is assigned after the bot starts up
starterbot_id = None


@slack.RTMClient.run_on(event='message')
def get_movie(**payload):
    data = payload['data']
    if 'add' in data['text']:
        channel_id = data['channel']
        thread_ts = data['ts']
        user = data['user']

        full_url = ombi_url + ombi_api + "&" + "t=" + data['text']
        params = { 'apikey': 'INSERT API KEY', 't':  data['text'].strip('add ') }
        #print (data['text'].strip('add'))
예제 #27
0
파일: async_app.py 프로젝트: gml16/ichack20
# ============== Message Events ============= #
# When a user sends a DM, the event type will be 'message'.
# Here we'll link the message callback to the 'message' event.
@slack.RTMClient.run_on(event="message")
async def message(**payload):
    """Display the onboarding welcome message after receiving a message
    that contains "start".
    """
    data = payload["data"]
    web_client = payload["web_client"]
    channel_id = data.get("channel")
    user_id = data.get("user")
    text = data.get("text")

    if text and text.lower() == "start":
        return await start_onboarding(web_client, user_id, channel_id)


if __name__ == "__main__":
    logger = logging.getLogger()
    logger.setLevel(logging.DEBUG)
    logger.addHandler(logging.StreamHandler())
    ssl_context = ssl_lib.create_default_context(cafile=certifi.where())
    slack_token = os.environ["SLACK_BOT_TOKEN"]
    loop = asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    rtm_client = slack.RTMClient(
        token=slack_token, ssl=ssl_context, run_async=True, loop=loop
    )
    loop.run_until_complete(rtm_client.start())
예제 #28
0
import slack

from rpg_helper import RPGHelper


@slack.RTMClient.run_on(event="message")
def respond_to_messages(**payload):
    '''Responds to messages on every channel if needed.'''
    if any(key not in payload for key in ("data", "web_client")):
        return
    data = payload["data"]
    web_client = payload["web_client"]

    if any(key not in data for key in ("text", "channel", "user")):
        return

    resp = RPGHELPER.handle_command(data["user"], data["text"])
    if resp:
        web_client.chat_postMessage(channel=data["channel"], text=resp)


if __name__ == "__main__":
    PARSER = argparse.ArgumentParser()
    PARSER.add_argument("-l",
                        "--load",
                        default="minatoris",
                        help="Load a game by default on start")
    ARGS = PARSER.parse_args()
    RPGHELPER = RPGHelper(ARGS.load)
    slack.RTMClient(token=os.environ["slack_token"]).start()
예제 #29
0
                # this is not supposed to happen!
                print("Oops something bad happened.")
            # checksum is right after send
            if send_index is not None:
                video_name_checksum = word_list[send_index + 1]
                print(f"Sending {video_name_checksum}.")


# web_client = payload['web_client']
# rtm_client = payload['rtm_client']
# message = data["text"]


@slack.RTMClient.run_on(event="message")
def handleCommands(**payload):
    data = payload["data"]
    if data.get("user") == "UQMNRUT88":
        parseMotionCommands(data)
        parseListCommands(data)
        parseSendCommands(data)


def get_slack_token(file_path):
    with open(file_path) as token_file:
        return token_file.readline()
    return None


if __name__ == "__main__":
    client = slack.RTMClient(token=get_slack_token("slack_token.dat"))
    client.start()
예제 #30
0
파일: app.py 프로젝트: OSU-CS/automod
    message = new_channel_message.get_message_payload()

    web_client.chat_postMessage(**message)


def send_new_user_message(web_client: slack.WebClient, report_channel: str,
                          new_user: str) -> None:
    """Send a message to a channel about a new user event. Automatically pins the message.

    :param web_client: The client to respond on
    :param report_channel: The channel to send the message to
    :param new_user: The new slack user object
    """
    new_user_message = NewUserMessage(report_channel, new_user)
    message = new_user_message.get_message_payload()

    response = web_client.chat_postMessage(**message)

    # Pin this message to the channel
    web_client.pins_add(channel=response['channel'], timestamp=response['ts'])


if __name__ == '__main__':
    logging.basicConfig(
        level=logging.INFO,
        format=
        '[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s')
    SLACK_TOKEN = os.environ['SLACK_BOT_TOKEN']
    rtm_client = slack.RTMClient(token=SLACK_TOKEN)
    rtm_client.start()