Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Änderungen #1

Merged
merged 9 commits into from
Mar 17, 2021
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: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
archiv/
config.json
config/config.json
.idea
mysql.json
disabled_mysql.json
Expand All @@ -21,7 +21,6 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
Expand Down
797 changes: 61 additions & 736 deletions bot.py

Large diffs are not rendered by default.

Empty file added botlibrary/__init__.py
Empty file.
Binary file added botlibrary/__pycache__/constants.cpython-38.pyc
Binary file not shown.
Binary file added botlibrary/__pycache__/utils.cpython-38.pyc
Binary file not shown.
25 changes: 25 additions & 0 deletions botlibrary/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import subprocess
import json

global VERSION, bot_prefix, ipdata_token, ipdata_url, osu_token, osu_url, lol_token, lol_url, bot_token


def assignVariables():
global VERSION, bot_prefix, ipdata_token, ipdata_url, osu_token, osu_url, lol_token, lol_url, bot_token
VERSION = subprocess.check_output(["git", "describe", "--tags", "--always"]).decode('ascii').strip()

with open('config/config.json', 'r') as f:
json_stuff = json.load(f)

bot_prefix = json_stuff["prefix"]

bot_token = json_stuff["token"]

ipdata_token = json_stuff["ipdata"]
ipdata_url = "https://api.ipdata.co/"

osu_token = json_stuff["osuapi"]
osu_url = "https://osu.ppy.sh/api/get_user?u="

lol_token = json_stuff["riotapi"]
lol_url = "https://euw1.api.riotgames.com/lol/"
61 changes: 61 additions & 0 deletions botlibrary/help.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"wetter": {
"description": "Mit {0}wetter kannst du dir das Wetter so wie einige Infos dazu anzeigen lassen",
"usage": "{0}wetter Stadt",
"example": "{0}wetter München"
},

"clear": {
"description": "Mit {0}clear kannst du eine beliebige Anzahl an Nachrichten aus einem Channel löschen",
"usage": "{0}clear (Anzahl)",
"example": "{0}clear 5"
},

"benutzerinfo":{
"description": "Mit {0}benutzerinfo kannst du dir einige Infos über einen Nutzer anzeigen lassen",
"usage": "{0}benutzerinfo (Benutzer)",
"example": "{0}benutzerinfo DCGALAXY"
},

"ping": {
"description": "Mit {0}ping kannst du dir die Discord WebSocket protocol latency anzeigen lassen",
"usage": "{0}ping",
"example": "{0}ping"
},

"give": {
"description": "Mit {0}give wird eine Minecraft Konsole simuliert",
"usage": "{0}give (item) (spieler)",
"example": "{0}give diamonds DCGALAXY"
},

"lol": {
"description": "Mit {0}lol kannst du dir eine League of Legends Stats anzeigen lassen",
"usage": "{0}lol (level/rang) (name)",
"example": "{0}lol rang Aftersh0ock"
},

"mc": {
"description": "Mit {0}mc (command) kannst du dir mehrere Interessante sachen zu Minecraft Anzeigen lassen",
"usage": "Mehr info gibt hier: {0}mc",
"example": "Mehr info gibt hier: {0}mc"
},

"osu": {
"description": "Mit {0}osu kannst du dir Osu Stats zu einem Spieler Anzeigen lassen",
"usage": "{0}osu (name)",
"example": "{0}osu Aftersh0ock"
},

"earth2": {
"description": "Mit {0}earth2 kannst du dir Earth2 Stats zu Deutschland Anzeigen lassen",
"usage": "{0}earth2",
"example": "{0}earth2"
},

"anime": {
"description": "Sende ein Bild und als Beschreibung {0}anime und es sagt dir welcher anime es ist",
"usage": "Bild mit Kommentar {0}anime",
"example": "https://i.imgur.com/P43xKu4.png"
}
}
16 changes: 16 additions & 0 deletions botlibrary/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import inspect


def get_variable(name):
stack = inspect.stack()
try:
for frames in stack:
try:
frame = frames[0]
current_locals = frame.f_locals
if name in current_locals:
return current_locals[name]
finally:
del frame
finally:
del stack
52 changes: 52 additions & 0 deletions cogs/anime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from discord.ext import commands
import discord
import requests
import urllib.parse


class Anime(commands.Cog):
def __init__(self, client):
self.client = client

@commands.command(name="anime")
async def anime_command(self, ctx):
base_url = "https://trace.moe/api/search?url="
attachment = ctx.message.attachments[0]
attachementurl = attachment.url
url = base_url + attachementurl
response = requests.post(url).json()["docs"][0]
genauigkeit = response["similarity"]
hentai = response["is_adult"]
titel = response["title_english"]
nativetitel = response["title_native"]
anilist = response["anilist_id"]
filename = response["filename"]
at = response["at"]
tokenthumb = response["tokenthumb"]
# Coming Soon
filenameencoded = urllib.parse.quote(filename)
imgrequest = "https://media.trace.moe/image/" + str(anilist) + "/" + filenameencoded + "?t=" + str(
at) + "&token=" + tokenthumb + "&size=m"
###
if titel is not None:
embed = discord.Embed(title=f"{titel}")
else:
embed = discord.Embed(title=f"{nativetitel}")
anilisturl = "https://anilist.co/anime/" + str(anilist)
embed.set_author(name="Anilist Link", url=anilisturl)
embed.add_field(name="Genauigkeit", value=f"{round(genauigkeit * 100, 2)}%")
if hentai is False:
embed.add_field(name="Hentai?", value="Nope :(")
else:
embed.add_field(name="Hentai?", value="Yess Sir")
if titel is not None:
embed.add_field(name="Titel in Orginalsprache", value=f"{nativetitel}")
else:
pass
embed.set_image(url=str(imgrequest))
await ctx.send(embed=embed)
return


def setup(client):
client.add_cog(Anime(client))
36 changes: 36 additions & 0 deletions cogs/benutzerinfo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from discord.ext import commands
import discord


class Benutzerinfo(commands.Cog):
def __init__(self, client):
self.client = client

@commands.command(name="benutzerinfo")
async def benutzerinfo_command(self, ctx, member: discord.Member):
embed = discord.Embed(title='Benutzerinfo für {}'.format(member.name),
description='Benutzerinfo für {}'.format(
member.mention),
color=0x69E82C)
embed.add_field(name='Server beigetreten',
value=member.joined_at.strftime('%d/%m/%Y'),
inline=True)
embed.add_field(name='Discord beigetreten',
value=member.created_at.strftime('%d/%m/%Y'),
inline=True)
embed.add_field(name=f"Rollen ({len(member.roles)})",
value=" ".join([role.mention for role in member.roles]))

rollen = ''
for role in member.roles:
if not role.is_default():
rollen += '{} \r\n'.format(role.mention)
embed.add_field(name='Höchste Rolle', value=member.top_role.mention, inline=True),
embed.add_field(name="Benutzer ID", value=member.id, inline=True),
embed.set_thumbnail(url=member.avatar_url)
embed.set_footer(text='Benutzerinfo')
await ctx.send(embed=embed)


def setup(client):
client.add_cog(Benutzerinfo(client))
63 changes: 63 additions & 0 deletions cogs/commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
from discord.ext import commands
import discord
from botlibrary import constants


class Commands(commands.Cog):
def __init__(self, client):
self.client = client

def ist_gepinnt(self, message):
return not message.pinned

@commands.command(name="ping")
async def ping_command(self, ctx):
await ctx.channel.send("Der Ping beträgt derzeit " f"{round(self.client.latency * 1000)}ms")

@commands.command(name="version")
async def version(self, ctx):
await ctx.channel.send(
"Der Bot läuft derzeit auf Release " + str(constants.VERSION) + " und geht auch dank discord.py Version {}".format(
discord.__version__))

@commands.command(name="einladen")
async def einladen(self, ctx):
embed = discord.Embed()
embed.set_author(name="Klicke hier zum einladen",
url=discord.utils.oauth_url(self.client.user.id, permissions=discord.Permissions(8), guild=ctx.guild))
await ctx.channel.send(embed=embed)

@commands.command(name="hosten")
async def hosten_command(self, ctx):
embed = discord.Embed()
embed.set_author(name="Klicke hier um ein Tutorial zum Selber hosten zu bekommen",
url='https://github.com/antonstech/antonstechbot/wiki/Installation')
await ctx.channel.send(embed=embed)

@commands.command(name="code")
async def code_command(self, ctx):
embed = discord.Embed()
embed.set_author(name="Hier findest du den ganzen Code vom Bot",
url='https://github.com/antonstech/antonstechbot')
await ctx.channel.send(embed=embed)

@commands.command(name="nudes")
async def nudes_command(self, ctx):
if ctx.channel.is_nsfw():
embed = discord.Embed(title="Nudes")
embed.set_image(
url="https://www.nydailynews.com/resizer/OYta-jTp2D6Xt_Wj_o6zEUqWttE=/415x562/top/arc-anglerfish-arc2-prod-tronc.s3.amazonaws.com/public/7Y53KJVE7FGLZZPD44LTN4QB5I.jpg")
await ctx.channel.send(embed=embed)
else:
await ctx.channel.send("Der Channel ist nicht nsfw")

@commands.command(name="clear")
async def clear_command(self, ctx, amount=5):
try:
await ctx.channel.purge(limit=amount + 1, check=self.ist_gepinnt)
except commands.MissingPermissions:
await ctx.channel.send("Du hast keine Berechtigung dazu!")


def setup(client):
client.add_cog(Commands(client))
75 changes: 75 additions & 0 deletions cogs/corona.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
from discord.ext import commands
import discord
import requests
from botlibrary import constants


class Corona(commands.Cog):
def __init__(self, client):
self.client = client

@commands.command(name="corona")
async def corona_command(self, ctx, option=None):

if option is None:
url = "https://api.corona-zahlen.org/germany"
response = requests.get(url).json()
g_url = "https://api.corona-zahlen.org/vaccinations"
geimpft = requests.get(g_url)
data = geimpft.json()
channel = ctx.message.channel
async with channel.typing():
insgesamt = response["cases"]
todegesamt = response["deaths"]
inzidenz = response["weekIncidence"]
data = data["data"]
jetzgeimpft = data["quote"]
infor = response["r"]
rwert = infor["value"]
gesund = response["recovered"]
embed = discord.Embed(title="Impfen lassen", url="https://antonstech.de/impfung.html",
color=ctx.author.color)
await ctx.send(embed=embed)
embed = discord.Embed(title="Corona Virus Statistiken für Deutschland",
color=ctx.author.color,
timestamp=ctx.message.created_at)
embed.add_field(name="Fälle insgesammt", value=f"{insgesamt}")
embed.add_field(name="Tode insgesamt", value=f"{todegesamt}")
embed.add_field(name="Gesund", value=f"{gesund}")
embed.add_field(name="Inzidenz", value=f"{round(inzidenz, 2)}")
embed.add_field(name="Geimpft", value=f"{round(jetzgeimpft, 2) * 100}%")
embed.add_field(name="R-Wert", value=f"{rwert}")
embed.set_footer(text="Mit " + constants.bot_prefix + "corona geimpft gibts mehr zur Impfung")
await ctx.send(embed=embed)
embed = discord.Embed(title="Aktuelle Corona Map für Deutschland",
color=ctx.author.color,
timestamp=ctx.message.created_at)
embed.set_image(url="https://api.corona-zahlen.org/map/districts")
embed.set_footer(text="Mit " + constants.bot_prefix + "corona geimpft gibts mehr zur Impfung")
await ctx.send(embed=embed)

elif option == "geimpft":
url = "https://api.corona-zahlen.org/vaccinations"
response = requests.get(url).json()
channel = ctx.message.channel
async with channel.typing():
data = response["data"]
jetztgeimpft = data["quote"]
gesamt = data["vaccinated"]
second = data["secondVaccination"]
zweite_imfung = second["vaccinated"]
embed = discord.Embed(title="Impfen lassen", url="https://antonstech.de/impfung.html",
color=ctx.author.color)
await ctx.send(embed=embed)
embed = discord.Embed(title="Statistiken zur Impfung in Deutschland",
color=ctx.author.color)
embed.add_field(name="Prozent der Bevölkerung", value=f"{round(jetztgeimpft, 2) * 100}%")
embed.add_field(name="Anzahl der Geimpften", value=f"{gesamt} Personen", inline=False)
embed.add_field(name="Zweite Impfung haben bereits erhalten", value=f"{zweite_imfung} Personen")
await ctx.send(embed=embed)

return


def setup(client):
client.add_cog(Corona(client))
27 changes: 27 additions & 0 deletions cogs/earth2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from discord.ext import commands
import discord
import requests


class Earth2(commands.Cog):
def __init__(self, client):
self.client = client

@commands.command(name="earth2")
async def earth2_command(self, ctx):
url = "https://earth2stats.net/api/get_countries/199"
response = requests.get(url).json()
land = response["name"]
wert = response["marketplace_tile_value"]
verkauft = response["total_sold_tiles"]
embed = discord.Embed(title="Earth2 Statistiken für " + land, url="https://earth2stats.net/country/" + land)
embed.set_thumbnail(
url="https://static-cdn.jtvnw.net/jtv_user_pictures/99783da2-3f60-4aeb-92bd-83e953c03627-profile_image-70x70.png")
embed.add_field(name="Wert eines Tiles", value=f"{wert}E$")
embed.add_field(name="Insgesamt verkauft", value=f"{verkauft} Tiles")
await ctx.send(embed=embed)
return


def setup(client):
client.add_cog(Earth2(client))
Loading