python - 检查文本消息是否包含单词,如果是,则发送 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")`
我试过这个。任何想法如何让这个工作?
解决方案
AChampion的含义如下:
if search_word in send_message:
print("text1")
else:
print("word not found")
推荐阅读
- node.js - Angular2,找不到模块“应用程序/模型/用户”错误
- botframework - 我们无法访问您的机器人。确保您已将“teamsappstudio@microsoft.com”添加为管理员,然后重试
- kibana - 将 Elastic Search 数字字段转换为文本值
- mysql - 努力弄清楚如何设置这些约束
- vis.js - 有没有办法在节点之间建立 2 个直边?
- matlab - 在matlab中冻结轴大小
- calendar - 用于测试目的的 CloudKit 解决方法
- python - 如何将列表刮成列表熊猫
- jquery - 无法使用 CSS 类更改颜色
- jolt - 在嵌套对象中具有 null 的 Jolt 转换