import discord #discord import tweepy #twitter import requests #opening urls import shutil #saving things import os #deleting things DISCORD_TOKEN = "AAAAAAAAAAAAAAAAAAAA" CONSUMER_KEY = "AAAAAAAAAAAAAAAAAAAA" CONSUMER_SECRET = "AAAAAAAAAAAAAAAAAAAA" ACCESS_TOKEN = "AAAAAAAAAAAAAAAAAAAA" ACCESS_SECRET = "AAAAAAAAAAAAAAAAAAAA" BEARER_TOKEN = "AAAAAAAAAAAAAAAAAAAA" BREAK = "\n--------------------------------------------------------------------------------\n" superscript_map = { "0": "⁰", "1": "¹", "2": "²", "3": "³", "4": "⁴", "5": "⁵", "6": "⁶", "7": "⁷", "8": "⁸", "9": "⁹", "a": "ᵃ", "b": "ᵇ", "c": "ᶜ", "d": "ᵈ", "e": "ᵉ", "f": "ᶠ", "g": "ᵍ", "h": "ʰ", "i": "ᶦ", "j": "ʲ", "k": "ᵏ", "l": "ˡ", "m": "ᵐ", "n": "ⁿ", "o": "ᵒ", "p": "ᵖ", "q": "۹", "r": "ʳ", "s": "ˢ", "t": "ᵗ", "u": "ᵘ", "v": "ᵛ", "w": "ʷ", "x": "ˣ", "y": "ʸ", "z": "ᶻ", "A": "ᴬ", "B": "ᴮ", "C": "ᶜ", "D": "ᴰ", "E": "ᴱ", "F": "ᶠ", "G": "ᴳ", "H": "ᴴ", "I": "ᴵ", "J": "ᴶ", "K": "ᴷ", "L": "ᴸ", "M": "ᴹ", "N": "ᴺ", "O": "ᴼ", "P": "ᴾ", "Q": "Q", "R": "ᴿ", "S": "ˢ", "T": "ᵀ", "U": "ᵁ", "V": "ⱽ", "W": "ᵂ", "X": "ˣ", "Y": "ʸ", "Z": "ᶻ", "+": "⁺", "-": "⁻", "=": "⁼", "(": "⁽", ")": "⁾"} trans = str.maketrans( ''.join(superscript_map.keys()), ''.join(superscript_map.values())) intents = discord.Intents(messages=True, guilds=True, presences=True) client = discord.Client(intents=discord.Intents.all()) masterID = 147745371303444480 bot_testing = 590513073459298304 auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET) api = tweepy.API(auth) try: user = api.verify_credentials() print("Authentication OK") except: print("Error during authentication") def get_last_tweet(): tweetList = api.user_timeline(count = 1) if(len(tweetList) == 0): return "no previous tweet found" else: print("last tweet: {" + tweetList[0].text + "}") return tweetList[0].text def text_tweet(text): if(text == get_last_tweet()): print("duplicate tweet") return api.update_status(text) def image_tweet(text, path): if(text == get_last_tweet()[:len(text)]): print("duplicate tweet") return api.update_status_with_media(text, path) @client.event async def on_ready(): print('Logged in as {0.user}'.format(client)) game = discord.Game("with the API") await client.change_presence(status=discord.Status.idle, activity=game) print(get_last_tweet()) print(BREAK) @client.event async def on_message(message): if message.author.id != masterID: return if message.content.startswith('tweet'): await message.channel.send("tweeting '" + message.content[6:] + "'") print("tweeting '" + message.content[6:] + "'") text_tweet(message.content[6:]) if message.content.startswith('getStatus'): activityTuple = message.author.activities for activity in activityTuple: if(activity.type == discord.ActivityType.custom): try: #dont put anything here, the if statement flags the error if (activity.emoji.is_custom_emoji()): await message.channel.send(":" + activity.emoji.name + ": " + activity.name + "\n" + 'This is a custom emoji'.translate(trans)) await message.channel.send(activity.emoji.url) else: await message.channel.send(":" + activity.emoji.name + ": " + activity.name) except: await message.channel.send(activity.name) print(BREAK) @client.event async def on_member_update(before, after): if after.id != masterID: return #remove this to start spying on everyone in stone motion activityTuple = after.activities for activity in activityTuple: if(activity.type == discord.ActivityType.custom): if(activity.emoji == None): print(activity.name) text_tweet(activity.name) else: if (activity.emoji.is_custom_emoji()): print(":" + activity.emoji.name + ": " + activity.name + "\n" + 'This is a custom emoji'.translate(trans)) print(activity.emoji.url) filename = str(activity.emoji.url).split("/")[-1] r = requests.get(str(activity.emoji.url), stream = True) if r.status_code == 200: r.raw.decode_content = True with open(filename,'wb') as f: shutil.copyfileobj(r.raw, f) image_tweet(":" + activity.emoji.name + ": " + activity.name + "\n" + 'This is a custom emoji'.translate(trans), filename) #os.remove(filename) else: print(":" + activity.emoji.name + ": " + activity.name) text_tweet(":" + activity.emoji.name + ": " + activity.name) print(BREAK) #api.update_with_media(image_path, tweet_text) client.run(DISCORD_TOKEN)