Open rp4k opened 4 days ago
If you are using the cloud-version then you may checkout https://github.com/soranoo/TradingView-Free-Webhook-Alerts/discussions/58#discussioncomment-7658366
Cloud-Version has limitation to where you can only send 10 alerts a day through pipedream. this is why i was trying to run it locally.
for example below is the code i wrote for python to be running all the time on my machine locally and it goes from the plain text email to my telegram bot. the issue i am having is filtering out just tradingview emails and also making sure it only grabs the correct body text.
code below:
import imaplib
import email
import requests
import time
# Configuration
IMAP_SERVER = 'imap.gmail.com' # Change if using another email provider
EMAIL_ACCOUNT = 'youremail@gmail.com'
EMAIL_PASSWORD = 'appPasswordKey' # Use an app password if 2FA is enabled
TELEGRAM_BOT_TOKEN = 'BotToken'
TELEGRAM_CHAT_ID = 'ChatID' # Replace with your chat ID (-1xxxxx)
def send_to_telegram(body_text):
message = f"New email body:\n{body_text}"
requests.post(f'https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}/sendMessage',
data={'chat_id': TELEGRAM_CHAT_ID, 'text': message})
def check_email():
mail = imaplib.IMAP4_SSL(IMAP_SERVER)
mail.login(EMAIL_ACCOUNT, EMAIL_PASSWORD)
mail.select('inbox')
# Search for unread emails
result, data = mail.search(None, '(UNSEEN)')
email_ids = data[0].split()
for e_id in email_ids:
result, msg_data = mail.fetch(e_id, '(RFC822)')
msg = email.message_from_bytes(msg_data[0][1])
# Extract the body text (assuming it's in plain text)
if msg.is_multipart():
for part in msg.walk():
if part.get_content_type() == "text/plain":
body_text = part.get_payload(decode=True).decode()
send_to_telegram(body_text)
break # Exit after sending the first text/plain part
else:
body_text = msg.get_payload(decode=True).decode()
send_to_telegram(body_text)
# Mark as read (optional)
mail.store(e_id, '+FLAGS', '\\Seen')
mail.logout()
if __name__ == "__main__":
while True:
check_email()
time.sleep(10) # Check every minute
because when it gets sent. it shows the entire email including headers
New email body:
[image: TradingView]
Your BTCUSD <https://www.tradingview.com/chart/?symbol=ICMARKETS%3ABTCUSD>
alert was triggered
Action: sell Lots: 1.5 Pair: BTCUSD. New strategy position is 1
Open your chart
<https://www.tradingview.com/chart/?symbol=ICMARKETS%3ABTCUSD>
Thanks for reading,
The TradingView Team
470 Olde Worthington Rd., Suite 200
<https://www.google.com/maps/search/470+Olde+Worthington+Rd.,+Suite+200+Westerville+OH+43082?entry=gmail&source=g>
Westerville
<https://www.google.com/maps/search/470+Olde+Worthington+Rd.,+Suite+200+Westerville+OH+43082?entry=gmail&source=g>
OH
<https://www.google.com/maps/search/470+Olde+Worthington+Rd.,+Suite+200+Westerville+OH+43082?entry=gmail&source=g>
43082
<https://www.google.com/maps/search/470+Olde+Worthington+Rd.,+Suite+200+Westerville+OH+43082?entry=gmail&source=g>
App Store
<https://itunes.apple.com/us/app/tradingview-trading-community-charts-and-quotes/id1205990992>
Google Play
<https://play.google.com/store/apps/details?id=com.tradingview.tradingviewapp>
Desktop app <https://www.tradingview.com/desktop>
Facebook <https://www.facebook.com/tradingview> YouTube
<https://www.youtube.com/@TradingView> LinkedIn
<https://www.linkedin.com/company/tradingview> Twitter
<https://twitter.com/tradingview>
This email was sent to xxxxx@gmail.com
because you asked to be alerted on TradingView.com
<https://www.tradingview.com/>
also i tried to search for @Soranoo on TG but i could not find you
Well, I will consider it for the Christmas update.
For the HTML email, you may turn on the "Send plain text" option
i wanted to know if it would be possible to have it send to a telegram bot instead of a discord bot. if this feature could be added. please let me know thank you.