Telegram bot
A reply when someone pastes a contract into a chat, with one Evidence button.
const HEY = 'https://heyresearch.xyz';
// Returns a sendMessage payload, or null to stay quiet.
async function heyTelegramReply(token) {
const r = await fetch(`${HEY}/api/v1/builder?chain=4663&token=${token}`, {
headers: { 'x-hey-integration': 'my-telegram-bot/1.0.0' },
});
if (!r.ok) return null; // 404: HEY has no page · 400: not a token · 429/5xx: stay quiet
const c = await r.json();
const lines = [c.hey_project_name];
if (!c.activity_applies_to_token) {
lines.push("The project's own site names another contract. HEY's research is about the project, not this token.");
return { text: lines.join('\n') };
}
lines.push('Builder: ' + c.hey_status_label + (c.verified_builder ? ' · Verified Builder' : ''));
if (c.latest_meaningful_ship) lines.push('Latest: ' + c.latest_meaningful_ship.title + ' · ' + ago(c.latest_meaningful_ship.timestamp));
if (c.meaningful_ships_30d !== null) lines.push('30d: ' + c.meaningful_ships_30d + ' meaningful ships');
return {
text: lines.join('\n'),
reply_markup: { inline_keyboard: [[{ text: 'Evidence on HEY', url: c.project_link }]] },
};
}
function ago(iso) {
const h = Math.floor((Date.now() - Date.parse(iso)) / 3600000);
return h < 24 ? h + 'h ago' : Math.floor(h / 24) + 'd ago';
}