Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2021
1,089
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 KB | None | 0 0
  1. # discord bot token
  2.  
  3.  
  4. ###
  5.  
  6. import requests
  7. import json
  8. from decimal import Decimal
  9. import discord
  10. import time
  11. import tweepy
  12. import urllib.request
  13. import random
  14. import os
  15. import threading
  16. from json.decoder import JSONDecodeError
  17. from discord_webhook import DiscordWebhook, DiscordEmbed
  18. # discord bot token
  19.  
  20. print("test")
  21. test = ""
  22.  
  23.  
  24.  
  25.  
  26. def sales():
  27. url = 'https://api-mainnet.magiceden.io/rpc/getGlobalActivitiesByQuery?q=%7B%22%24match%22%3A%7B%22collection_symbol%22%3A%22solbots%22%7D%2C%22%24sort%22%3A%7B%22blockTime%22%3A-1%7D%2C%22%24skip%22%3A0%7D'
  28. while True:
  29. time.sleep(1)
  30. try:
  31. data = json.loads(requests.get(url).text)
  32. except JSONDecodeError:
  33. threading.Thread(target=sales).start()
  34. break
  35. for i in range(100000):
  36. if str('exchange') in str(data['results'][i]):
  37. f = open('solbots.txt').read()
  38. if str(data['results'][i]) != str(f):
  39. open('solbots.txt', 'w').write(str(data['results'][i]))
  40. print('Sale Found! Sending Info!')
  41. else:
  42. print('No Sales Found')
  43. break
  44. sale = data['results'][i]
  45. mint = sale['mint']
  46. nft_data = json.loads(requests.get('https://api-mainnet.magiceden.io/rpc/getNFTByMintAddress/' + mint).text)
  47. sale_price = str(sale['parsedTransaction']['total_amount']/1000000000)
  48. source = sale['source']
  49. webhook = DiscordWebhook(url='https://discord.com/api/webhooks/916511511030136943/VjICxP0xXV7WlhNas92fSEDsOFFik3xWG4JRnMEZcibWoLa_Kf-jDIDoUK6da4r9lpPs%27)
  50. embed = DiscordEmbed(title='', description= 'Name - ' + str(nft_data['results']['title']) + '\nAmount - ' + str(sale_price) + ' SOL\n', color=00000)
  51. embed.set_image(url=nft_data['results']['img'])
  52. embed.set_timestamp()
  53.  
  54. embed.set_author(name='SolBot Sales')
  55. if str('magiceden') in str(source):
  56. embed.set_footer(text='Sale on Magic Eden', icon_url='https://i.postimg.cc/j2TbqJ3x/favicon.png%27)
  57. webhook.add_embed(embed)
  58. webhook.execute()
  59. break
  60. sales()
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement