Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Net;
- using System.IO;
- using Newtonsoft.Json;
- using Telegram.Bot;
- using Telegram.Bot.Args;
- using Telegram.Bot.Types.ReplyMarkups;
- namespace BotTelegram
- {
- class Program
- {
- private static string token = "2016040925:AAGxwLKV6ZikKCqVHkrT4fQ27c9zQ8ry-QU";
- private const string UrlCoinString = "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=space-hamster&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=1h%2C24h%2C7d";
- private static TelegramBotClient client;
- private const string CommandPrefixBuy = "buy";
- private const string CommandPrefixInPrice = "/price";
- private const string CommandPrefixInNFT = "nft";
- private const string CommandPrefixInSwap = "/farm";
- private delegate void Message();
- [Obsolete]
- static void Main(string[] args)
- {
- client = new TelegramBotClient(token);
- client.OnMessage += OnMessageHandler;
- client.StartReceiving();
- }
- [Obsolete]
- private static async void OnMessageHandler(object sender, MessageEventArgs e)
- {
- if (string.IsNullOrWhiteSpace(e.Message.Text)) return;
- string textMessage = e.Message.Text.ToLower();
- bool textBuy = textMessage.Contains(CommandPrefixBuy);
- bool textPrice = textMessage.Contains(CommandPrefixInPrice);
- bool textNFT = textMessage.Contains(CommandPrefixInNFT);
- bool textFarm = textMessage.Contains(CommandPrefixInSwap);
- if (textBuy == true)
- {
- var nameDex = new InlineKeyboardMarkup(new[]{
- new [] {InlineKeyboardButton.WithUrl(text: "HAMS DEX", url: "https://dex.solhamster.space/#/market/5j6hdwx4eW3QBYZtRjKiUj7aDA1dxDpveSHBznwq7kUv")},
- new [] {InlineKeyboardButton.WithUrl(text: "DexLab", url: "https://trade.dexlab.space/#/market/5j6hdwx4eW3QBYZtRjKiUj7aDA1dxDpveSHBznwq7kUv")},
- new [] {InlineKeyboardButton.WithUrl(text: "Aldrin", url: "https://dex.aldrin.com/chart/spot/HAMS_USDC")},
- new [] {InlineKeyboardButton.WithUrl(text: "LoverDEX", url: "https://samoyedlovers.co/#/market/5j6hdwx4eW3QBYZtRjKiUj7aDA1dxDpveSHBznwq7kUv")},
- new [] {InlineKeyboardButton.WithUrl(text: "NoGoalDex", url: "https://dex.nogoal.click/#/market/5j6hdwx4eW3QBYZtRjKiUj7aDA1dxDpveSHBznwq7kUv")},
- new [] {InlineKeyboardButton.WithUrl(text: "Cato Dex", url: "https://catodex.com/#/market/5j6hdwx4eW3QBYZtRjKiUj7aDA1dxDpveSHBznwq7kUv") },
- new [] {InlineKeyboardButton.WithUrl(text: "Raydium Swap", url: "https://raydium.io/swap/?ammId=z2KxiSejQmNNsyxLFHbrewNLDeGLFZahFNSLYht2FFs")},
- new [] {InlineKeyboardButton.WithUrl(text: "Jupiter Swap", url: "https://jup.ag/swap/HAMS-USDC") }
- });
- await client.SendTextMessageAsync(e.Message.Chat.Id, text: "Buy $HAMS. Click ๐", replyMarkup: nameDex);
- }
- else if (textPrice == true)
- {
- WebRequest reqGET = WebRequest.Create(UrlCoinString);
- WebResponse resp = reqGET.GetResponse();
- Stream stream = resp.GetResponseStream();
- StreamReader sr = new StreamReader(stream);
- string s = sr.ReadToEnd();
- Coin coin = JsonConvert.DeserializeObject<Coin>(s);
- double rfeg = coin.CurrentPrice >= 0 ? coin.CurrentPrice : 0.00;
- double gergerg = coin.High24h >= 0 ? coin.High24h : 0.00;
- double frege = coin.Low24h >= 0 ? coin.Low24h : 0.00;
- double fergerge = coin.PriceChangePercentage1hInCurrency >= 0 ? coin.PriceChangePercentage1hInCurrency : 0.00;
- double egerge = coin.PriceChangePercentage24hInCurrency >= 0 ? coin.PriceChangePercentage24hInCurrency : 0.00;
- double egerg = coin.PriceChangePercentage7dInCurrency >= 0 ? coin.PriceChangePercentage7dInCurrency : 0.00;
- double fwgrgergergre = coin.TotalVolume >= 0 ? coin.TotalVolume : 0.00;
- string coinInfo =
- $"{coin.Name} - ${coin.Symbol.ToUpper()} \n" +
- $"๐ฐ Price: ${Math.Round(rfeg, 5)}\n" +
- $"โ๏ธ H: ${Math.Round(gergerg, 5)} | L: ${Math.Round(frege, 5)}\n" +
- $"๐ 1h: {Math.Round(fergerge, 2)}%" +
- $"๐ 24h: {Math.Round(egerge, 2)}% \n" +
- $"๐ 7d: {Math.Round(egerg, 2)}%" +
- $"๐ Volume: ${Math.Round(fwgrgergergre, 5)}\n";
- //var coin = await GetFromHttpClient<List<Coin>>();
- //string d = "๐ 7d: 0.00%";
- //string h = "๐ 1h: 0.00%";
- //var h24 = coin[0].High24h;
- //if (coin[0].PriceChangePercentage1hInCurrency != null)
- //{
- // h = $"๐ 1h: {Math.Round((double)coin[0].PriceChangePercentage1hInCurrency, 2)}%";
- //}
- //if (coin[0].PriceChangePercentage7dInCurrency >= 0)
- //{
- // d = $"๐ 7d: {Math.Round((double)coin[0].PriceChangePercentage7dInCurrency, 2)}%";
- //}
- //if (h24 == null)
- //{
- // h24 = 0;
- //}
- //var coinInfo =
- // $"{coin[0].Name} - ${coin[0].Symbol.ToUpper()} \n" +
- // $"๐ฐ Price: ${Math.Round(coin[0].CurrentPrice, 5)}\n" +
- // $"โ๏ธ H: ${Math.Round((decimal)coin[0].High24h, 5)} | L: ${Math.Round((decimal)coin[0].Low24h, 5)}\n" +
- // $"{h}\n" +
- // $"๐ 24h: {Math.Round((double)coin[0].PriceChangePercentage24hInCurrency, 2)}% \n" +
- // $"{d}\n" +
- // $"๐ Volume: ${Math.Round((double)coin[0].TotalVolume, 5)}\n";
- await client.SendTextMessageAsync(e.Message.Chat.Id, text: coinInfo);
- }
- else if (textNFT == true)
- {
- var nftCollection = new InlineKeyboardMarkup(new[]
- {
- new [] {InlineKeyboardButton.WithUrl(text: "Metaplex", url: "https://hams.holaplex.com/#/") },
- new [] {InlineKeyboardButton.WithUrl(text: "DigitalEyes", url: "https://digitaleyes.market/collections/Space%20Hamster") }
- });
- await client.SendTextMessageAsync(e.Message.Chat.Id, text: "Buy $HAMS NFT collection", replyMarkup: nftCollection);
- }
- else if (textFarm == true)
- {
- var farm = new InlineKeyboardMarkup(new[]
- {
- new [] {InlineKeyboardButton.WithUrl(text: "Cropper Farm", url: "https://cropper.finance/farms/?s=Be5mLMaSg1PpBJbK3P6DMAsd9arGi6xeDEApwEVeyHau") }
- });
- await client.SendTextMessageAsync(e.Message.Chat.Id, text: "Farm $HAMS. Click ๐", replyMarkup: farm);
- }
- Console.WriteLine(e.Message.Chat.Id);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement