-
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.
Merge pull request #19 from mi3lix9/change-docker-image
Modify docker image to run the bot
- Loading branch information
Showing
12 changed files
with
101 additions
and
149 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 |
---|---|---|
|
@@ -11,5 +11,10 @@ | |
node_modules/ | ||
jspm_packages/ | ||
|
||
# Develolpment directories | ||
.devcontainer | ||
.github | ||
.vscode | ||
out | ||
# config file | ||
config |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
BOT_TOKEN=123456789:COPYTHETOKENFROMBOTFATHER | ||
JELLYSEERR_URL="https://localhost:5055/api/v1" | ||
JELLYSEERR_URL="https://localhost:5055" | ||
JELLYSEERR_KEY="COPYTHEAPIKEYFROMJELLYSEERR" |
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,30 @@ | ||
name: Build and Push to GHCR | ||
|
||
on: | ||
push: | ||
branches: | ||
- "develop" | ||
- "main" | ||
|
||
jobs: | ||
build_and_push: | ||
permissions: | ||
packages: write | ||
contents: read | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Build and Push the Image to GHCR | ||
run: | | ||
docker login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} | ||
if [ "${{ github.ref_name }}" == "main" ]; then | ||
TAG="latest" | ||
else | ||
TAG="${{ github.ref_name }}" | ||
fi | ||
docker build -t ghcr.io/${{ github.repository }}:$TAG . | ||
docker push ghcr.io/${{ github.repository }}:$TAG |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { z } from "zod"; | ||
|
||
const envSchema = z.object({ | ||
|
||
BOT_TOKEN: z.string({ message: "BOT_TOKEN is not defined." }), | ||
JELLYSEERR_URL: z.string({ message: "JELLYSEERR_URL is not defined." }).url(), | ||
JELLYSEERR_URL: z.string({ message: "JELLYSEERR_URL is not defined." }).url().transform((url) => url + "/api/v1"), | ||
JELLYSEERR_KEY: z.string({ message: "JELLYSEERR_KEY is not defined." }), | ||
}); | ||
|
||
export default envSchema.parse(process.env); | ||
|
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
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
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,39 @@ | ||
import type { InlineQueryResultArticle } from "grammy/types"; | ||
import { search } from "../jellyseerr"; | ||
import { createTemplate } from "./createTemplate"; | ||
import type { MyContext } from "./types"; | ||
import type { Filter } from "grammy"; | ||
|
||
export async function inlineQueryHandler( | ||
ctx: Filter<MyContext, "inline_query"> | ||
) { | ||
const query = ctx.inlineQuery.query.trim(); | ||
|
||
if (query === "") { | ||
return; // Ignore empty queries | ||
} | ||
|
||
const results = await search({ query }); | ||
|
||
// Format the results to send as inline query answers | ||
const inlineResults: InlineQueryResultArticle[] = results | ||
.filter((result) => typeof result.posterPath !== "undefined") | ||
.map((result) => ({ | ||
type: "article", | ||
id: String(result.mediaId), | ||
title: result.mediaType + ": " + result.title, | ||
input_message_content: { | ||
message_text: createTemplate({ | ||
title: result.title, | ||
overview: result.overview ?? "", | ||
releaseDate: result.releaseDate ?? "", | ||
mediaType: result.mediaType, | ||
}), | ||
}, | ||
description: result.overview, | ||
thumb_url: result.posterPath, | ||
})); | ||
|
||
// Answer the inline query | ||
await ctx.answerInlineQuery(inlineResults); | ||
} |
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