-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
40 lines (37 loc) · 1.36 KB
/
bot.js
File metadata and controls
40 lines (37 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const {Telegraf} = require("telegraf");
const Config = require("./config");
const {SPLData} = require("./actions");
const bot = new Telegraf(Config.BOT_TOKEN);
const SPL = new SPLData();
bot.command("start", async ctx => {
const firstName = ctx.message.chat.first_name;
let msg = `Hi *${firstName}*,\n\nI'm your companion for SPL tokens on the Solana blockchain\n\nUsage:\n/search [contract]\n\nStay ahead of the game and find detailed information about any "SPL" token`;
await ctx.reply(msg, {parse_mode: "Markdown"});
});
bot.command("search", async ctx => {
const userMessage = ctx.message.text.split(" ");
if (userMessage.length == 2) {
let data = await SPL.GetTokenInfo(userMessage[1]);
//console.log(data);
let tokenInfo = `Name:${data.tokenName} (${data.tokenSymbol})\n\n${data.description}\n\nOwner: _${data.owner}_\n\nDecimal: ${data.decimal}\n\nCurrent supply: ${data.supply}`;
if(data){
if (data.tokenLogo) {
await ctx.sendPhoto(data.tokenLogo, {
caption: `${data.tokenSymbol}`,
});
}
return await ctx.reply(tokenInfo, {
parse_mode: "Markdown",
});
}
else{
return await ctx.reply("Resources not found!\npass correct contract", {
parse_mode: "Markdown",
});
}
}
await ctx.reply("*Usage*\n/search [contract]", {
parse_mode: "Markdown",
});
});
bot.launch();