Created
April 21, 2024 13:09
-
-
Save sedovolosiy/cae213bd6f9446febd06408d8f5ce6fc to your computer and use it in GitHub Desktop.
A Telegram bot designed to verify if tokens are scams.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters | |
import requests | |
# Токен, который вы получили от BotFather | |
TELEGRAM_TOKEN = '6316632422:AAElNs3y4HW_pL3DltyIHqxrhtT_XluEvPafU' | |
# Словарь для хранения выбранного языка пользователем | |
user_language = {} | |
def set_language(update, context): | |
""" Устанавливает язык пользователя """ | |
if context.args and context.args[0].lower() in ['ua', 'eng']: | |
user_language[update.message.chat_id] = context.args[0].lower() | |
reply_text = 'Мова встановлена: Українська.' if context.args[0].lower() == 'ua' else 'Language set: English.' | |
update.message.reply_text(reply_text) | |
else: | |
update.message.reply_text('Використовуйте /language [ua/eng] для встановлення мови.') | |
def get_message(lang, key): | |
""" Возвращает соответствующее сообщение на выбранном языке """ | |
messages = { | |
'start': { | |
'ua': 'Привіт! Надішліть мені адресу у форматі /check [адреса] для перевірки. Опціонально /language [ua/eng]', | |
'eng': 'Hello! Send me an address in the format /check [address] for checking. Option /language [ua/eng] ' | |
}, | |
'send_address': { | |
'ua': 'Будь ласка, надішліть адресу після команди.', | |
'eng': 'Please send the address after the command.' | |
}, | |
'api_error': { | |
'ua': 'Помилка при запиті до API.', | |
'eng': 'Error while requesting the API.' | |
}, | |
'reply_message': { | |
'ua': ( | |
"🔎 Аналіз токена: {name} ({symbol})\n" "💼 Всього тримачів: {totalHolders}\n" | |
"🌐 Мережа: {chain_name} ({currency})\n" | |
"🚨 Результат аналізу на шахрайство: {scam_result}\n" | |
"Причина: {reason}\n" | |
"🔗 Адреса контракту: {address}\n" | |
"🛠 Ринок: {marketplace}\n" | |
"💰 Ліквідність: {liquidity}\n" | |
"🛒 Роутер: {router}" | |
), | |
'eng': ( | |
"🔎 Token analysis: {name} ({symbol})\n" | |
"💼 Total holders: {totalHolders}\n" | |
"🌐 Network: {chain_name} ({currency})\n" | |
"🚨 Scam analysis result: {scam_result}\n" | |
"Reason: {reason}\n" | |
"🔗 Contract address: {address}\n" | |
"🛠 Marketplace: {marketplace}\n" | |
"💰 Liquidity: {liquidity}\n" | |
"🛒 Router: {router}" | |
) | |
} | |
# Добавьте здесь другие ключи и их переводы | |
} | |
return messages[key].get(lang, messages[key]['eng']) # По умолчанию английский | |
def format_reply_message(data, lang): | |
""" Форматирует ответное сообщение в зависимости от языка """ | |
scam_result = 'Так' if data['honeypotResult']['isHoneypot'] else 'Ні' if lang == 'ua' else 'Yes' if data['honeypotResult']['isHoneypot'] else 'No' | |
reason = data['honeypotResult'].get('honeypotReason', '') | |
return get_message(lang, 'reply_message').format( | |
name=data['token']['name'], | |
symbol=data['token']['symbol'], | |
totalHolders=data['token']['totalHolders'], | |
chain_name=data['chain']['name'], | |
currency=data['chain']['currency'], | |
scam_result=scam_result, | |
reason=reason, | |
address=data['token']['address'], | |
marketplace=data['pair']['pair']['name'], | |
liquidity=data['pair']['liquidity'], | |
router=data['router'] | |
) | |
def check_honeypot(update, context): | |
lang = user_language.get(update.message.chat_id, 'eng') # По умолчанию английский | |
address = ' '.join(context.args) | |
if not address: | |
update.message.reply_text(get_message(lang, 'send_address')) | |
return | |
url = f'https://api.honeypot.is/v2/IsHoneypot?address={address}' | |
response = requests.get(url) | |
if response.status_code == 200: | |
data = response.json() | |
reply_message = format_reply_message(data, lang) | |
update.message.reply_text(reply_message) | |
else: | |
update.message.reply_text(get_message(lang, 'api_error')) | |
def start(update, context): | |
lang = user_language.get(update.message.chat_id, 'eng') | |
update.message.reply_text(get_message(lang, 'start')) | |
def main(): | |
updater = Updater(TELEGRAM_TOKEN, use_context=True) | |
dp = updater.dispatcher | |
dp.add_handler(CommandHandler("start", start)) | |
dp.add_handler(CommandHandler("check", check_honeypot)) | |
dp.add_handler(CommandHandler("language", set_language)) | |
updater.start_polling() | |
updater.idle() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment