-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 379ec0e
Showing
34 changed files
with
2,266 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
FROM python:3 | ||
|
||
WORKDIR /usr/src/app | ||
|
||
ENV token '' | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Oops, something went wrong.