Open virtuacool opened 1 month ago
Snippet from my copytrader bot:
import sys
from telethon import TelegramClient, events
tgram_trigger_name = "Intelligent Trading Signals"
tgram_phone_number = "+316123456789"
tgram_api_id = "yout telegram chat id"
tgram_api_hash = "your telegram hash"
# Initialize the Telegram client
client = TelegramClient(
"Sample Snippet",
tgram_api_id,
tgram_api_hash,
).start(tgram_phone_number)
for dialog in client.iter_dialogs():
DIALOG_ID = None
if dialog.title == tgram_trigger_name or dialog.entity.username == tgram_trigger_name:
DIALOG_ID = dialog.id
print(f"Listening to trade signals from '{dialog.title}'", True)
break
if DIALOG_ID:
@client.on(events.NewMessage(chats=DIALOG_ID))
async def callback_smarttrade(event):
"""Receive Telegram message."""
await handle_telegram_event(event)
else:
print(
f"Channel '{tgram_trigger_name}' not found in your telegram account"
)
sys.exit(1)
async def handle_telegram_event(event):
"""
Handle a message from the Telegram channel
"""
side = ""
message = event.message.message
print(message)
if "BOUGHT:" in message:
side = "Buy"
if "SOLD:" in message:
side = "Sell"
if side:
print(f"Found {side} signal")
# Create trade_details
trade_details = {
"symbol": "BTC-USDT",
"side": side,
}
# Handle buy signal logic here
# trader.create_trade(trade_details)
# Start telegram client
client.start()
client.run_until_disconnected()
Thank you!
I still haven't been able to get it to work!
I'm having a lot of trouble creating the application on Telegram, to get the Channel and hash ID!
I've tried everything, and now it won't let me log in because it says I've already logged in several times!
In other words, I was able to log in to the platform, and enter the application data, and then it returned "ERROR".
Now it won't let me log in, because it says I've tried several times (of course, I couldn't create the application!)
I've tried the various procedures in this topic #273 (without a VPN, with another browser, another network, with a GSM network, etc...).
Can anyone help?
I've already done it!
I tried at my brother's house and he managed to get the Telegram credentials and I already have the signals!
However, I noticed that the channel is not emitting signals with a frequency of 1 minute.
How to "listen" to your channel with my bot on Telegram?
I would like my Telegram bot to listen to your channel's signals.
I see that there are more than 2,400 subscribers.
How can I do this?