Compare commits

15 Commits
Author SHA1 Message Date
Legonzaur ebb5042075 Create docker-publish.yml 2023-09-05 17:08:15 +02:00
legonzaur 4160f2a8d3 Merge branch 'main' of https://github.com/ToneAPI/Sonar 2023-09-05 17:03:16 +02:00
Legonzaur 8cdab50d11 Create docker-image.yml 2023-09-05 17:02:53 +02:00
legonzaur 51e801eed1 add dockerfile 2023-09-05 17:02:11 +02:00
legonzaur d04f3b63e3 switch to environment variables 2023-09-05 16:57:38 +02:00
legonzaur a8e7f0c882 create launch.json 2023-09-05 16:53:13 +02:00
legonzaur b0e2704ab7 create requirements.txt 2023-09-05 16:53:07 +02:00
iiLarsH 622f8daa81 Merge pull request #26 from ToneAPI/Development
Development
2023-07-22 15:58:51 +02:00
iiLarsH 661df1852b Merge pull request #25 from ToneAPI/Development
made Map and Gamemode filter for LB
2023-06-30 14:01:04 +02:00
iiLarsH b1294284f5 Merge pull request #24 from ToneAPI/Development
Made gamemode and map filter for /stats
2023-06-30 00:12:15 +02:00
iiLarsH a3675562e7 Merge pull request #23 from ToneAPI/Development
Add gamemode chart, autocompletion playername and fix on autocompletion AXIS servers
2023-06-29 12:39:24 +02:00
iiLarsH 070640a164 Merge pull request #22 from ToneAPI/Development
Development
2023-06-20 19:23:19 +02:00
iiLarsH 7fdde99b57 Merge pull request #21 from ToneAPI/Development
fixed bugs related to custom weapons
2023-06-20 17:11:00 +02:00
iiLarsH 6f03c0c432 Merge pull request #20 from ToneAPI/Development
Development
2023-06-19 13:35:19 +02:00
iiLarsH 3255bfae29 Merge pull request #19 from ToneAPI/Development
hot fixed all the bugs introduced
2023-06-09 16:59:43 +02:00
13 changed files with 158 additions and 11 deletions
+17
View File
@@ -0,0 +1,17 @@
name: Docker Image CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build the Docker image
run: docker build . --file Dockerfile --tag toneapi/sonar:latest
+95
View File
@@ -0,0 +1,95 @@
name: Docker
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
on:
push:
branches: [ "main" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ "main" ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: 'v2.1.1'
# Workaround: https://github.com/docker/build-push-action/issues/461
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
# Sign the resulting Docker image digest except on PRs.
# This will only write to the public Rekor transparency log when the Docker
# repository is public to avoid leaking data. If you would like to publish
# transparency data even for private images, pass --force to cosign below.
# https://github.com/sigstore/cosign
- name: Sign the published Docker image
if: ${{ github.event_name != 'pull_request' }}
env:
# https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-an-intermediate-environment-variable
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
# This step uses the identity token to provision an ephemeral certificate
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
+20
View File
@@ -0,0 +1,20 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch bot",
"type": "python",
"request": "launch",
"program": "bot.py",
"console": "integratedTerminal",
"justMyCode": true,
"env":{
"DISCORD_TOKEN":"",
"TONE_ENDPOINT":"https://toneapi.ovh"
}
}
]
}
+6
View File
@@ -0,0 +1,6 @@
FROM python:latest
WORKDIR /usr/src/app
COPY . .
RUN pip install -r requirements.txt
CMD ["python", "bot.py"]
+4
View File
@@ -8,3 +8,7 @@ for further information on commands do !help or !help <commandname> in a server
Invite link: https://discord.com/api/oauth2/authorize?client_id=1100115547515011182&permissions=414464862272&scope=bot
Githublink: https://github.com/ToneAPI/Sonar
```bash
pip install -r requirements.txt
```
+2 -1
View File
@@ -1,3 +1,4 @@
import os
import datetime
from PIL import Image, ImageDraw, ImageFont
import discord
@@ -5,7 +6,7 @@ import requests
def getleaderboard(board:str, weaponid="", server="", mapid = "", gamemodeid = ""):
payload = {"weapon": weaponid, "server": server, "map": mapid, "gamemode": gamemodeid}
response = requests.get('https://tone.sleepycat.date/v2/client/players', params=payload).json()
response = requests.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/players', params=payload).json()
players = response.keys()
if(board.lower() == "totald"):
board = "total_distance"
+2 -1
View File
@@ -1,6 +1,7 @@
import os
async def getserver(s,snippet):
server = ""
async with s.get('https://tone.sleepycat.date/v2/client/servers') as r:
async with s.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/servers') as r:
response = await r.json()
servers = response.keys()
for i in servers:
+2 -2
View File
@@ -1,5 +1,5 @@
import asyncio
import os
import discord
import requests
@@ -46,7 +46,7 @@ async def get_allplayer_stats(s, playerids, weaponid = "", weaponname= "",server
async def getstats(s, playerid, weaponid = "", server = "", mapid = "" , gamemodeid = ""):
payload = {'player': playerid, 'weapon': weaponid, 'server': server, 'gamemode': gamemodeid, 'map' : mapid}
async with s.get('https://tone.sleepycat.date/v2/client/players', params=payload) as r:
async with s.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/players', params=payload) as r:
response = await r.json()
if(response == {}):
async with s.get("https://northstar.tf/accounts/get_username", params={"uid": playerid}) as Er:
+1 -1
View File
@@ -3,7 +3,7 @@ import requests
def valueschartgamemode(playerid, weaponid):
payload = {'player': playerid, 'weapon': weaponid}
response = requests.get('https://tone.sleepycat.date/v2/client/gamemodes', params=payload).json()
response = requests.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/gamemodes', params=payload).json()
gamemode_color = {'aitdm':(1, 0.0, 0.0),'at':(1, 0.375, 0.0),'chamber':(1, 0.75, 0.0),'cp':(0.875, 1, 0.0),'ctf':(0.5, 1, 0.0),'fd':(0.125, 1, 0.0),'ffa':(0.0, 1, 0.25),'fw':(0.0, 1, 0.625),'gg':(0.0, 1.0, 1),'inf':(0.0, 0.625, 1),'lts':(0.0, 0.25, 1),'mfd':(0.125, 0.0, 1),'ps':(0.5, 0.0, 1),'sns':(0.875, 0.0, 1), 'tdm':(1, 0.0, 0.75),'ttdm':(1, 0.0, 0.375), 'other': (1, 0.0, 1)}
gamemode_dict = {'aitdm':'Attrition','at':'Bounty Hunt','chamber':'One in the Chamber','cp':'Amped Hardpoint','ctf':'Capture the Flag','fd':'Frontier Defense','ffa':'Free for All','fw':'Frontier War','gg':'GunGame','inf':'Infection','lts':'Last Titan Standing','mfd':'Marked for Death','ps':'Pilots Vs. Pilots','sns':'Sticks and Stones','tdm':'Skirmish','ttdm':'Titan Brawl'}
File diff suppressed because one or more lines are too long
+1 -2
View File
@@ -3,7 +3,6 @@ from discord import app_commands
import discord
import os
import asyncio
from discordtoken import discordtoken
client = commands.Bot(command_prefix="!", intents=discord.Intents.all())
client.remove_command('help')
@@ -38,6 +37,6 @@ async def main():
async with client:
await load()
await slashload()
await client.start(discordtoken.get())
await client.start(os.environ.get("DISCORD_TOKEN"))
asyncio.run(main())
+4
View File
@@ -0,0 +1,4 @@
discord
pillow
matplotlib
requests
+2 -2
View File
@@ -65,7 +65,7 @@ class SlashStats(commands.Cog):
async def autocomplete_player(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
data = []
async with aiohttp.ClientSession() as session:
async with session.get('https://tone.sleepycat.date/v2/client/players') as r:
async with session.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/players') as r:
players = await r.json()
for player_choice in players.keys():
@@ -89,7 +89,7 @@ class SlashStats(commands.Cog):
async def autocomplete_server(self, interaction: discord.Interaction, current: str) -> list[app_commands.Choice[str]]:
data = []
async with aiohttp.ClientSession() as session:
async with session.get('https://tone.sleepycat.date/v2/client/servers') as r:
async with session.get(os.environ.get("TONE_ENDPOINT") + '/v2/client/servers') as r:
servers = await r.json()
for server_choice in servers.keys():