Skip to content

Commit

Permalink
very simple upload!
Browse files Browse the repository at this point in the history
  • Loading branch information
HAV0X1014 authored Feb 5, 2023
1 parent 8b0fbb9 commit e63e7a6
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
54 changes: 54 additions & 0 deletions bot.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import selfcord
import re
from discord_webhook import DiscordWebhook
#put the server and channel IDs here, preferably above the channel you want to listen to. comma separate them with no spaces
serverids = []
channelids = []

#put URLs of webhooks you want to send the images to- quote enclosed and comma separated. using only 1 webhook is ok
WEBHOOK_URL = ["",]
#put the token of the listener account here
DISCORD_USER_TOKEN = ""

#put the listener account's ID here so it doesnt relay its own messages
BOT_ID =
LISTEN_GUILD_IDS = serverids
LISTEN_CHANNEL_IDS = channelids

def main():
dc = selfcord.Client()

@dc.event
async def on_ready():
print(f"Listening User: {dc.user}")

@dc.event
async def on_message(message):
guild_id = message.guild.id
if guild_id not in LISTEN_GUILD_IDS:
return

channel_id = message.channel.id
if channel_id not in LISTEN_CHANNEL_IDS:
return

author_id = message.author.id
if author_id == BOT_ID:
return

if not message.attachments:
return
attachmentUnformatted = message.attachments #get the message's attachment, it is not returned as a string
attachmentLastSplit = re.split(r".*url='", str(attachmentUnformatted))[1] #split it at the URL part and also cast it to a string
attachmentURL = attachmentLastSplit[: len (attachmentLastSplit) - 3] #remove the last three characters and assign it to the final variable

msg_to_send = f"[{str(message.guild.name).upper()}] {message.author.name}:\t{attachmentURL}"

for i in range(0, len(WEBHOOK_URL)): #iterate through the webhook URLs in case you want to send to multiple places
webhook = DiscordWebhook(url=WEBHOOK_URL[i], username='Unify', content=msg_to_send)
webhook.execute()

dc.run(DISCORD_USER_TOKEN)

if __name__ == '__main__':
main()
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
discord-webhook
git+https://github.com/dolfies/discord.py-self@renamed#egg=selfcord.py[voice]

0 comments on commit e63e7a6

Please sign in to comment.