Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Added femtolink integration to graph images #62

Merged
merged 2 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.template
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ OWNER=12345
ANNOUNCEMENTS=
SECURITYGUILD=
SECURITY=
BANNEDWORDS=
BANNEDWORDS=
FEMTOLINK=
23 changes: 14 additions & 9 deletions bot.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import base64
import datetime
import json
import os
import sqlite3
import sys
import urllib
from email import message
import requests
from os import listdir
from os.path import isfile
from os.path import join
from pydoc import describe
from time import time

import discord
Expand All @@ -27,6 +24,7 @@
from get_enviroment import SECURITY_CHANNEL
from get_enviroment import SECURITY_GUILD
from get_enviroment import SWEAR_WORDS_LIST
from get_enviroment import FEMTOLINK
from get_enviroment import TOKEN

# Language Loading
Expand Down Expand Up @@ -1650,11 +1648,18 @@ async def metrics(ctx):
if len(uurl) < 2048:
embed.set_image(url=uurl)
else:
rest = uurl
i = 1020
while len(rest) > 0:
await ctx.respond(rest[:i])
rest = rest[i:]
headers = {
'Authorization': f"Bearer {FEMTOLINK}",
'Content-Type': 'application/json',
}

data ='{ "long_url": "' + uurl + '" }'

response = requests.post('https://femtolink.jaumelopez.dev/api/link', headers=headers, data=data)


embed.set_image(url=response.json()['link'])

embed.set_footer(
text=await GetTranslatedText(ctx.guild.id,
"footer_executed_by",
Expand Down
1 change: 1 addition & 0 deletions get_enviroment.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
SECURITY_GUILD = os.getenv("SECURITYGUILD")
SECURITY_CHANNEL = os.getenv("SECURITY")
SWEAR_WORDS_LIST = os.getenv("BANNEDWORDS", "").split(",")
FEMTOLINK = os.getenv("FEMTOLINK", "")