首页 > 解决方案 > 检查文本消息是否包含单词,如果是,则发送 CustomText

问题描述

我使用一个工作 python 脚本来检查加密硬币价格下降,如果硬币下降 -3% 或更多,我会在 Telegram 中收到一条消息,并将相同的消息发送到我的电子邮件。

现在我想为每个市场发送一个自定义文本,比如 BTC/ETH/USDT 等等……

我想用 python 检查消息,如果消息包含来自 BTC 市场的价格下跌发送 text1 ETH 市场发送 text2 USDT 市场发送 text3

Bot 像这样获取 CoinName 示例:IOTA/BTC < 在这种情况下,我需要 bot 来查看单词 BTC 并发送 text1。我尝试了一些东西,但无法弄清楚。

这里是消息文本所在的部分,

`bot.send_message(parse_mode='HTML', chat_id=BINANCE_ID,
 text = "<a href = 'https://www.binance.com/tradeDetail.html?symbol {C}_{M}'> {Coin} </a> ".format(C = CoinItself,
                                                                                                                                     M = Market,
                                                                                                                                     Coin = Coin)
                   + "▼" + str(RoundPercent) + "%  "
                   + str(floatDictPrice) + " -> "
                   + str(floatDataPrice) + "  [Binance]")
 binance_prices.update( { CurrentCoin: dataPrice })
 send_message("<a href = 'https://www.binance.com/tradeDetail.html?symbol={C}_{M}'> {Coin} </a> ".format(C = CoinItself,
                                                                                                                                     M = Market,
                                                                                                                                     Coin = Coin)
                    + "▼" + str(RoundPercent) + "%  "
                    + str(floatDictPrice) + " -> "
                    + str(floatDataPrice) + "  [Binance]")`

bot.send_message部分将消息发送到电报,该send_message部分将相同的消息文本发送到我的电子邮件。

`search_word = input("BTC")
if(search_word == send_message):
    print("text1")
else:
    print("word not found")`

我试过这个。任何想法如何让这个工作?

标签: python

解决方案


AChampion的含义如下:

if search_word in send_message:
    print("text1")
else: 
    print("word not found") 

推荐阅读