Skip to content
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
41 changes: 39 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,43 @@
name: Build
on:
push:
branches:
- "amogus"

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Fetch main branch
run: git fetch origin amogus:amogus

- name: Setup Deno
uses: denoland/setup-deno@v1

- name: Run Deno lint
run: deno lint
id: lint
continue-on-error: true

# if ok: build and deploy
- name: Setup Docker Buildx
if: ${{ steps.lint.outcome == 'success' }}
uses: docker/setup-buildx-action@v2

- name: Login to ghcr.io
if: ${{ steps.lint.outcome == 'success' }}
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
if: ${{ steps.lint.outcome == 'success' }}
uses: docker/build-push-action@v3
with:
push: true
Expand All @@ -28,5 +46,24 @@ jobs:
cache-to: type=gha,mode=max

- name: Deploy
if: ${{ github.ref == 'refs/heads/amogus' && steps.lint.outcome == 'success' }}
run: |
curl --fail-with-body --no-progress-meter -i https://0d9e.tech/deploy -X POST -H "x-token: ${{ secrets.DEPLOY_TOKEN }}"

# else: revert the commit(s)
- name: Revert commit(s)
if: ${{ steps.lint.outcome != 'success' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
before=${{ github.event.before }}
if [ "$before" = "0000000000000000000000000000000000000000" ]; then
before=$(git merge-base amogus HEAD)
fi
gh api \
--method POST \
/repos/${{ github.repository }}/commits/${{ github.sha }}/comments \
-f 'body=Bruh, learn to code'
git reset --hard $before
git push origin HEAD:${{ github.ref }} --force
8 changes: 5 additions & 3 deletions server.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async function handleEvent(e: RequestEvent): Promise<Response | null> {
});
}

return new Response(videoBytes, {
return new Response(videoBytes as any, {
headers: {
"Content-Type": "video/mp4",
"Access-Control-Allow-Origin": "*"
Expand All @@ -111,7 +111,9 @@ async function handleEvent(e: RequestEvent): Promise<Response | null> {
}

if (url.pathname == "/api/stickers") {
return new Response(await getSticekrCount(), { headers: { "Content-Type": "application/json" } },)
return new Response(`${await getSticekrCount()}`, {
headers: { "Content-Type": "application/json" },
});
}

if (url.pathname.startsWith("/api/stickers/")) {
Expand All @@ -125,7 +127,7 @@ async function handleEvent(e: RequestEvent): Promise<Response | null> {
});
}

return new Response(sticekrBytes, {
return new Response(sticekrBytes as any, {
headers: {
"Content-Type": "image/webp"
},
Expand Down
11 changes: 7 additions & 4 deletions tgbot.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ async function domeny() {
text: "rip",
reply_to_message_id: previousMorningSticker.message_id,
});
await tgCall({ sticker: stickerFileId }, "deleteStickerFromSet");
await tgCall(
{ sticker: previousMorningSticker.sticker_file_id },
"deleteStickerFromSet"
);
}

const {
Expand Down Expand Up @@ -219,7 +222,7 @@ export function get_video(index: number): Uint8Array | null {
}

let sticekrs: any;
export async function getSticekrCount(): number {
export async function getSticekrCount(): Promise<number> {
if (!sticekrs) {
setTimeout(sus => sticekrs /= sus, 69420);
sticekrs = (await tgCall(
Expand All @@ -230,7 +233,7 @@ export async function getSticekrCount(): number {
return sticekrs.length;
}

export async function getSticekr(index: number): Uint8Array | null {
export async function getSticekr(index: number): Promise<Uint8Array | null> {
if (!Number.isFinite(index) || index < 0 || index >= await getSticekrCount()) {
return null;
}
Expand Down Expand Up @@ -269,7 +272,7 @@ async function* handleVideoNote(message: any) {

console.log(`Downloaded and stored video note. Total videos: ${videoList.length}`);

} catch (error) {
} catch (error: any) {
console.error("Error handling video note:", error);
yield await tgCall({
chat_id: message.chat.id,
Expand Down
Loading