Exemplo n.º 1
0
    def test_totuzensi(self):
        """>< コマンドが実行できるかテスト"""

        client1 = TestClient()
        analyze_message('>< aaa')(client1)
        client2 = TestClient()
        hato.totuzensi('aaa')(client2)
        self.assertEqual(client1.get_post_message(),
                         client2.get_post_message())
Exemplo n.º 2
0
def healthcheck_app():
    """
    api形式で動作確認を行えます
    Slackへの投稿は行われません

    <コマンド例>
    curl -XPOST -d '{"message": "鳩"}' \
        -H "Content-Type: application/json" http://localhost:3000/healthcheck
    """
    msg = request.json['message']
    client = ApiClient()
    client.post(f'コマンド: {msg}')
    analyze.analyze_message(msg)(client)
    return client.response
Exemplo n.º 3
0
def analyze_slack_message(messages: List[dict]) -> Callable[[SlackClient], None]:
    """Slackコマンド解析"""

    if len(messages) > 0 and messages[0]['type'] == 'text':
        message = messages[0]['text'].strip()
        return analyze.analyze_message(message)

    return hato.default_action
Exemplo n.º 4
0
def http_app():
    """
    localでテストできます

    <コマンド例>
    curl -XPOST -d '{"message": "鳩", "channel": "C0123A4B5C6", "user": "******"}' \
        -H "Content-Type: application/json" http://localhost:3000/

    or

    pipenv run python post_command.py --channel C0123A4B5C6 --user U012A34BCDE "鳩"
    """
    msg = request.json['message']
    channel = request.json['channel']
    user = request.json['user']
    client = SlackClient(channel, user)
    client.post(f'コマンド: {msg}')
    analyze.analyze_message(msg)(client)
    return "success"
Exemplo n.º 5
0
 def test_version(self):
     """versionが正しく返せるかテスト"""
     self.assertEqual(analyze_message('version'), hato.version)