fiix bot init

This commit is contained in:
Dobromir Popov 2024-10-02 15:40:47 +03:00
parent 55c8fc6d71
commit 990903db30

View File

@ -24,11 +24,22 @@ TELEGRAM_BOT_TOKEN = "6805059978:AAHNJKuOeazMSJHc3-BXRCsFfEVyFHeFnjw"
# Initialize Telegram Bot
bot = Bot(token=TELEGRAM_BOT_TOKEN)
# Initialize logging
logging.basicConfig(level=logging.DEBUG)
# Token addresses (initialize with some known tokens)
TOKEN_ADDRESSES = {
"SOL": "So11111111111111111111111111111111111111112",
"USDC": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"TARD": "4nfn86ssbv7wiqcsw7bpvn46k24jhe334fudtyxhp1og"
# Add more known tokens here
}
async def send_telegram_message(message):
try:
await bot.send_message(chat_id=DEVELOPER_CHAT_ID, text=message, parse_mode=ParseMode.HTML)
except Exception as e:
print(f"Error sending Telegram message: {str(e)}")
logging.error(f"Error sending Telegram message: {str(e)}")
@app.route('/')
def index():
@ -87,10 +98,6 @@ async def follow_move():
})
# Token addresses (to be populated dynamically)
TOKEN_ADDRESSES = {}
async def get_token_balance(wallet_address, token_address):
try:
balance = await solana_client.get_token_account_balance(
@ -132,6 +139,9 @@ async def list_initial_wallet_states():
your_non_zero = await get_non_zero_token_balances(YOUR_WALLET)
TOKEN_ADDRESSES = {**followed_non_zero, **your_non_zero}
# TOKEN_ADDRESSES.update(followed_non_zero)
# TOKEN_ADDRESSES.update(your_non_zero)
logging.info(f"Getting balances for tokens : {TOKEN_ADDRESSES.keys()}")
followed_wallet_state = "\n".join([f"{token}: {amount:.6f}" for token, amount in followed_wallet_balances.items() if amount > 0])
your_wallet_state = "\n".join([f"{token}: {amount:.6f}" for token, amount in your_wallet_balances.items() if amount > 0])
@ -148,6 +158,11 @@ async def list_initial_wallet_states():
await send_telegram_message(message)
# @app.route('/initialize', methods=['GET'])
# async def initialize():
# await list_initial_wallet_states()
# return jsonify({"status": "success", "message": "Initialization complete"})
async def send_startup_message():
current_time = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
message = (
@ -160,7 +175,7 @@ async def send_startup_message():
await send_telegram_message(message)
if __name__ == '__main__':
asyncio.run(send_startup_message())
# asyncio.run(send_startup_message())
asyncio.run(list_initial_wallet_states())
print(f"Monitored Tokens: {', '.join(TOKEN_ADDRESSES.keys())}")
print(f"Initial Monitored Tokens: {', '.join(TOKEN_ADDRESSES.keys())}")
app.run(host='0.0.0.0', port=3009)