[PYTHON] LINE BOT if ~ stumbled

For the time being, write it as a memo for yourself.

Specific explanation

First, I will explain in detail what I stumbled upon.

The sample code of LINE BOT is mostly the sample code of Echolalia.

To be honest, I'm not interested in returning parrots, so I struggled to find it.

If the text sent contains the string "apple", send it back as "apple".

test


if "Apple" in event.message.text:

I found the sample code.

I modified this a little

If the character string of the sent text matches "apple", send it back as "apple".

test


if event.message.text == "Apple":

I wanted to make the code, but I stumbled here.

How did you stumble?

test


if event.message.text == "Apple":

When I changed the code to, for some reason nothing came back.

Cause

The cause is

comp


    if event.message.text == "/url":
        line_bot_api.reply_message(
          event.reply_token,
          [TextSendMessage(text="Ah ah"))]

Can you see that there is a "[" in this code?

This was bad ...

So, when I erased the "[" and tried again, it worked.

Summary

Do not put [] in the code.

Source code

https://ux.getuploader.com/rdup/download/25

Recommended Posts

LINE BOT if ~ stumbled
Make a LINE BOT (chat)
Parrot return LINE BOT creation
Safety confirmation LINE bot [Explanation]
[Python] Make your own LINE bot
[LINE bot] I'm a ranger! Part 2
Create a LINE Bot in Django
Display Disney's waiting time with LINE bot
Creating a LINE bot ~ Creating, deploying, and launching ~
[Python] [LINE Bot] Create a parrot return LINE Bot
Upload photos from LINE Bot to Dropbox
Monitor web page updates with LINE BOT