Skip to content

Commit

Permalink
opensource unused
Browse files Browse the repository at this point in the history
  • Loading branch information
zefanjajobse committed Apr 13, 2024
0 parents commit b6f2519
Show file tree
Hide file tree
Showing 34 changed files with 2,266 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Docker

on:
pull_request:
# Publish `main` as Docker `latest` image.
branches:
- master

# Publish `v1.2.3` tags as releases.
tags:
- v*

# Run tests for any PRs.
push:

env:
# Image name
IMAGE_NAME: gamestats-telegram

jobs:
# Push image to GitHub Packages.
# See also https://docs.docker.com/docker-hub/builds/
push:

runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME

- name: Log into registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin

- name: Push image
run: |
IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# Use Docker `latest` tag convention
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__pycache__
16 changes: 16 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM python:3

WORKDIR /usr/src/app

ENV token 2023757880:AAEJxQ4483PnCDHPmrKgh7w1C4HBI4mP5Ng
ENV redishost redis-availability.1e8uve.ng.0001.euc1.cache.amazonaws.com
ENV redisport 6379
ENV redispass ''

COPY ./requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt

# https://github.com/goverfl0w/discord-interactions/
COPY . .

CMD python ./app.py
61 changes: 61 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# https://docs.aiogram.dev/en/latest/
import re
import os
import asyncio
from battlefield.api.api_requests import onReadyCheck
import logging
from aiogram import Bot, Dispatcher, executor, types
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher.filters.state import State, StatesGroup

API_TOKEN = os.environ["token"]

# Configure logging
logging.basicConfig(level=logging.INFO)


class StatState(StatesGroup):
bf2 = State()
bf3 = State()
bfh = State()
bf4 = State()
bf1 = State()
bf5 = State()

bf2weapongraph = State()
bf3weapongraph = State()
bfhweapongraph = State()
bf4weapongraph = State()
bf1weapongraph = State()
bf5weapongraph = State()

bf2vehiclegraph = State()
bf3vehiclegraph = State()
bfhvehiclegraph = State()
bf4vehiclegraph = State()
bf1vehiclegraph = State()
bf5vehiclegraph = State()


# Initialize bot and dispatcher
bot = Bot(token=API_TOKEN)

storage = MemoryStorage()
dp = Dispatcher(bot, storage=storage)


@dp.message_handler(commands=["start", "help"])
async def send_welcome(message: types.Message):
"""
This handler will be called when user sends `/start` or `/help` command
"""
await message.reply(
"This is the first initial version of the gamestats bot for telegram\nWe will start by adding the main commands:\n/bf1stats, /bf5stats, /bf4stats etc..."
)


from battlefield.handlers import *

if __name__ == "__main__":
asyncio.ensure_future(onReadyCheck())
executor.start_polling(dp, skip_updates=True)
Empty file added battlefield/api/__init__.py
Empty file.
Loading

0 comments on commit b6f2519

Please sign in to comment.