Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
bae60cf
first working version
ender-null Apr 7, 2024
f2294c4
delete bindings
ender-null Apr 7, 2024
11ce92a
upload to docker pull requests
ender-null Apr 7, 2024
d910068
update workflow
ender-null Apr 7, 2024
bcba11b
fix tag
ender-null Apr 7, 2024
78a2856
fix tag
ender-null Apr 7, 2024
6b9f386
fix port
ender-null Apr 7, 2024
77865c8
update format
ender-null Apr 8, 2024
34838dc
implement ping
ender-null Apr 8, 2024
933410c
remove sigkill
ender-null Apr 8, 2024
a44060b
deploy to wired
ender-null Apr 8, 2024
9b55385
update ssh action
ender-null Apr 8, 2024
7b7aef5
add commands
ender-null Apr 8, 2024
64dbbc0
fix build
ender-null Apr 8, 2024
7c871e2
fix bugfixes with locales
ender-null Apr 8, 2024
6680121
fix platform
ender-null Apr 10, 2024
20d27f2
bugfixes and debug
ender-null Apr 10, 2024
a40316c
add voice url for debug
ender-null Apr 10, 2024
a725459
fix null getAdmins
ender-null Apr 11, 2024
0ec3e47
add broadcast
ender-null Apr 11, 2024
3f6f89d
fix build
ender-null Apr 11, 2024
8badfc8
bugfixes for wow
ender-null Apr 12, 2024
1d16f07
fix format
ender-null Apr 12, 2024
d3fecd9
fix wow image
ender-null Apr 12, 2024
e743c2a
lol plugin fixes
ender-null Apr 12, 2024
757fb2a
add chatgpt plugin
ender-null Apr 12, 2024
473ae8f
add debug loggers
ender-null Apr 12, 2024
86b8144
fix debug
ender-null Apr 12, 2024
6695a4e
refactor commands
ender-null Apr 12, 2024
90cf754
add missing chatgpt plugin
ender-null Apr 12, 2024
5f9c1be
add logger for chatgpt
ender-null Apr 12, 2024
7e919ee
fix debug logs
ender-null Apr 12, 2024
e17fc81
remove logger
ender-null Apr 12, 2024
c2ee1b5
add tts to chatgpt
ender-null Apr 14, 2024
0ccdd85
fix file sending
ender-null Apr 14, 2024
f3dbd25
bugfixes
ender-null Apr 14, 2024
b611281
refactor chatgpt and voice plugins
ender-null Apr 14, 2024
b779c89
fix voice file encoding
ender-null Apr 14, 2024
0c00469
handle restart and add ping
ender-null Apr 15, 2024
93e763e
migrate to mongodb
ender-null Apr 16, 2024
634bec5
fix imports
ender-null Apr 16, 2024
6bc99cb
fix translation loading
ender-null Apr 16, 2024
1c6b731
fix poles, improve html to markdown and improve logger
ender-null Apr 16, 2024
ffe9627
don't show trailer when not available
ender-null Apr 16, 2024
887130d
fix text split
ender-null Apr 16, 2024
9cda732
small format change
ender-null Apr 16, 2024
65bf38a
fix wow format
ender-null Apr 16, 2024
ee84ce6
update docker-publish.yml
ender-null Apr 19, 2024
0de5e35
change port
ender-null Apr 22, 2024
82851a3
Merge branch 'feature/websocket' of https://github.com/ender-null/pol…
ender-null Apr 22, 2024
9953af4
fix polerank
ender-null May 5, 2024
8781c28
remove crypto plugin
ender-null May 5, 2024
229af84
fix twitter media forwarder
ender-null May 5, 2024
7c5b60b
add album art for last.fm
ender-null May 5, 2024
6fb6da1
change format
ender-null May 5, 2024
e9803da
fix getFullName
ender-null May 6, 2024
01f2db9
check if target exists on broadcast
ender-null May 6, 2024
2dc8121
broadcast refactor
ender-null May 6, 2024
0ae93a4
broadcast changes
ender-null May 6, 2024
e767f1a
don't show wow character media when not available
ender-null May 6, 2024
5fc7388
use correct config
ender-null May 6, 2024
7433632
refactor and add quotes
ender-null May 7, 2024
934535d
Merge branch 'feature/websocket' of https://github.com/ender-null/pol…
ender-null May 7, 2024
6ae0130
fix build
ender-null May 7, 2024
4129137
upgrade dependencies
ender-null May 7, 2024
455dd33
use debian base
ender-null May 7, 2024
c62ccbb
use node:slim
ender-null May 7, 2024
2123843
fix node-fetch version
ender-null May 7, 2024
66b68e8
remove title from urban dictionary
ender-null May 7, 2024
9c6caae
fix quote markdown
ender-null May 7, 2024
ec6db8c
fix html to markdown replacements
ender-null May 7, 2024
cea672c
format
ender-null May 7, 2024
d5005a4
add typings
ender-null May 7, 2024
10b23d2
fix markdown replacement
ender-null May 7, 2024
2279648
text refactor for urban dictionary
ender-null May 7, 2024
a2f3898
add redirect functionality
ender-null May 7, 2024
ab99389
fix redirect
ender-null May 7, 2024
249f6f9
fix redirect
ender-null May 7, 2024
df7a590
change exec and logger
ender-null May 8, 2024
6790be8
refactor lol plugin
ender-null May 11, 2024
1559f9c
fix build
ender-null May 11, 2024
971be28
fix region
ender-null May 11, 2024
730ab2a
add back regions
ender-null May 11, 2024
77e6e4e
fix riot api call params
ender-null May 11, 2024
26a7add
fix lol and wow plugins
ender-null May 11, 2024
210ef9c
fix gif plugin
ender-null May 11, 2024
54b6b62
small changes
ender-null May 22, 2024
bdd2837
add spica plugin
ender-null May 22, 2024
4156aed
wait for websocket to be ready
ender-null May 22, 2024
b1c656e
add loggers to spica
ender-null May 22, 2024
2bb9e59
add debug info
ender-null May 22, 2024
f11653c
use native websocket
ender-null May 22, 2024
9ca258f
refactor
ender-null May 22, 2024
5276c66
fix imports
ender-null May 22, 2024
516ec3f
fix lol region
ender-null May 22, 2024
7b4dfca
update chatgpt to gpt-4o
ender-null May 22, 2024
5857e40
add setCommands
ender-null May 22, 2024
07ce712
add parameter types
ender-null May 22, 2024
e45fa87
fix getUsername
ender-null May 23, 2024
d59460a
refactor
ender-null May 23, 2024
276a235
refactor help
ender-null May 23, 2024
4d88375
help refactor
ender-null May 23, 2024
270e22b
refactor
ender-null May 24, 2024
a5cc7e8
help and bus format
ender-null May 24, 2024
bfafad0
refactor and some bugfixes
ender-null May 25, 2024
3112c27
update dependencies
ender-null May 29, 2024
fa7bfe5
update dependencies
ender-null May 29, 2024
f052b31
fix build
ender-null May 29, 2024
a2de396
add attachment filename
ender-null Jun 4, 2024
18c485a
refactor attachment
ender-null Jun 4, 2024
ac755d5
improve attachments
ender-null Jun 4, 2024
74db511
refactor attachments
ender-null Jun 4, 2024
d8ce737
format
lunadesangre555 Jun 6, 2024
6f34ea6
update dependencies
lunadesangre555 Jun 12, 2024
e5400ef
add coffee plugin
lunadesangre555 Jun 14, 2024
acbd160
update dependencies
ender-null Apr 21, 2025
8a9574f
update version
ender-null Apr 21, 2025
1f05ae0
remove cron schedule for workflow
ender-null Apr 21, 2025
b861eed
refactor
ender-null Apr 22, 2025
9fc5ef6
update dependencies
ender-null Apr 22, 2025
58d9313
Merge branch 'feature/websocket' of https://github.com/ender-null/pol…
ender-null Jul 14, 2025
e50d72b
change api url
ender-null Jul 14, 2025
a316baf
update yarn.lock
ender-null Jul 14, 2025
404a77f
add tracking
ender-null Sep 9, 2025
9fb2284
deploy to correct server
ender-null Sep 9, 2025
db80f2f
fix aptabase event tracking
ender-null Sep 9, 2025
0ecc037
fix tracking
ender-null Sep 9, 2025
855671f
fix build
ender-null Sep 9, 2025
7a3c2b7
fix tracking
ender-null Sep 9, 2025
061f87f
add Timestamp
ender-null Sep 9, 2025
2370aa1
fix tracking
ender-null Sep 9, 2025
a098b95
update dependencies and cleanup
ender-null Sep 23, 2025
f71d36e
update dependencies
ender-null Jan 14, 2026
b4e8743
add native commands
ender-null Jan 14, 2026
348ea8e
login to ghcr.io
ender-null Jan 14, 2026
5a14dfd
handle command responses
ender-null Jan 14, 2026
737027f
set timeout to 10 sec
ender-null Jan 14, 2026
46fe372
add await to async methods
ender-null Jan 14, 2026
0365beb
add conversation type
ender-null Feb 18, 2026
54cdf4b
fix poles
ender-null Feb 18, 2026
9b547d1
fix compatibility of group ids
ender-null Feb 19, 2026
b2a4b35
move compatibility fix
ender-null Feb 19, 2026
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
28 changes: 0 additions & 28 deletions .eslintrc.json

This file was deleted.

15 changes: 10 additions & 5 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ name: Docker
# documentation.

on:
schedule:
- cron: '0 5 */7 * *'
push:
branches:
- main
- 'feature/**'
# Publish semver tags as releases.
tags: ['v*.*.*']
pull_request:
Expand Down Expand Up @@ -115,6 +114,7 @@ jobs:
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}
deploy:
if: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-latest
needs: build
steps:
Expand All @@ -127,7 +127,7 @@ jobs:
CONTAINER_NAME="${REPO#$OWNER}"
CONTAINER_NAME="${CONTAINER_NAME#/}"

TAG=$(echo "${{github.sha}}" | cut -c1-8)
TAG=$(echo "${{github.sha}}" | cut -c1-7)
TAG="sha-$TAG"
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')

Expand All @@ -144,24 +144,29 @@ jobs:
export-env: true
env:
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN }}
CR_PAT: op://end.works/GitHub Token/credential
HOST: op://end.works/end.works/URL
PORT: op://end.works/end.works/port
USERNAME: op://end.works/end.works/username
KEY: op://end.works/SSH Key/private key
FINGERPRINT: op://end.works/SSH Key/fingerprint
MONGODB_URI: op://end.works/Polaris Config/mongodb uri
APTABASE_HOST: op://end.works/Polaris Aptabase/username
APTABASE_APP_KEY: op://end.works/Polaris Aptabase/credential

- name: Run container on host
uses: appleboy/ssh-action@v0.1.10
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ env.HOST }}
port: ${{ env.PORT }}
username: ${{ env.USERNAME }}
key: ${{ env.KEY }}
script: |
echo ${{ env.CR_PAT }} | docker login ghcr.io -u USERNAME --password-stdin
docker pull ghcr.io/${{ github.repository }}:${{ env.TAG }}
docker stop ${{ env.CONTAINER_NAME }}
docker rm ${{ env.CONTAINER_NAME }}
docker run -v $PWD/logs:/usr/src/app/logs -v $PWD/docs/data:/usr/src/app/data -v $PWD/docs/firebase.json:/usr/src/app/firebase.json -p 1984:1984/tcp -ti -d --restart unless-stopped --name ${{ env.CONTAINER_NAME }} ghcr.io/${{ github.repository }}:${{ env.TAG }}
docker run -e APTABASE_HOST=${{ env.APTABASE_HOST }} -e APTABASE_APP_KEY=${{ env.APTABASE_APP_KEY }} -e MONGODB_URI=${{ env.MONGODB_URI }} -v $PWD/logs:/usr/src/app/logs -p 8040:8080 -e TZ=Europe/Madrid -ti -d --restart unless-stopped --name ${{ env.CONTAINER_NAME }} ghcr.io/${{ github.repository }}:${{ env.TAG }}

- name: Generate summary
id: generate-summary
Expand Down
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn run format
13 changes: 11 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
FROM ghcr.io/ender-null/polaris-base:latest-debian as builder
FROM node:slim as builder

RUN npm install yarn@latest -g --force

RUN mkdir -p /usr/src/app

Expand All @@ -13,7 +15,7 @@ COPY . .

RUN yarn run build

FROM ghcr.io/ender-null/polaris-base:latest-debian as release
FROM node:slim as release

LABEL org.opencontainers.image.source https://github.com/ender-null/polaris

Expand All @@ -23,4 +25,11 @@ COPY --from=builder /usr/src/app/node_modules ./node_modules
COPY --from=builder /usr/src/app/build ./build
COPY --from=builder /usr/src/app/package.json ./

RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y ffmpeg opus-tools cron
RUN npm install yarn@latest -g --force
RUN crontab -l -u root | echo "*/15 * * * * find /tmp -type f -delete" | crontab -u root -
ENV TZ=Europe/Madrid

CMD ["yarn", "start"]
31 changes: 31 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import tseslint from "typescript-eslint";
import tsparser from "@typescript-eslint/parser";
import prettierPlugin from "eslint-plugin-prettier";
import prettierConfig from "eslint-config-prettier";
import { defineConfig, globalIgnores } from "eslint/config";

export default defineConfig([
{
files: ["src/**/*.ts"],

languageOptions: {
parser: tsparser,
sourceType: "module",
},

plugins: {
"@typescript-eslint": tseslint,
prettier: prettierPlugin,
},

rules: {
...tseslint.configs.recommended.rules,
...prettierConfig.rules,
"@/no-unused-vars": "warn",
"no-console": "warn",
},
},
globalIgnores([
"build/**/*",
]),
]);
76 changes: 38 additions & 38 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polaris",
"version": "0.10.1",
"version": "2.0.0",
"description": "A multi platform TypeScript bot using plugins!",
"license": "AGPL-3.0",
"author": {
Expand All @@ -21,69 +21,69 @@
"typedoc": "typedoc",
"build": "tsc -p tsconfig.release.json",
"build:watch": "tsc -w -p tsconfig.release.json",
"start": "NODE_OPTIONS=\"--max_old_space_size=4096\" UV_THREADPOOL_SIZE=128 node build/src/main.js",
"start:dev": "ENV=\"dev\" node build/src/main.js",
"start": "node build/src/main.js",
"test": "echo \"No tests yet\" && exit 0",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"format": "prettier --write src"
"format": "prettier --write src",
"prepare": "husky"
},
"husky": {
"hooks": {
"pre-commit": "npm run lint"
"pre-commit": "yarn run format"
}
},
"type": "commonjs",
"engines": {
"node": ">=12"
},
"dependencies": {
"cheerio": "^1.0.0-rc.12",
"discord.js": "^14.14.1",
"firebase": "^10.10.0",
"form-data": "^4.0.0",
"cheerio": "^1.1.2",
"crypto": "^1.0.1",
"form-data": "^4.0.5",
"html-to-text": "^9.0.5",
"matrix-bot-sdk": "^0.7.1",
"mime-types": "^2.1.35",
"node-cron": "^3.0.3",
"node-fetch": "^2",
"prebuilt-tdlib": "^0.1008026.0",
"mime-types": "^3.0.2",
"mongodb": "^7.0.0",
"node-cron": "^4.2.1",
"node-fetch": "^3.3.2",
"openai": "^6.16.0",
"string-format": "^2.0.0",
"tdl": "v7.4.1",
"tdl-tdlib-addon": "^1.2.2",
"tmp": "^0.2.3",
"winston": "^3.13.0",
"winston-daily-rotate-file": "^5.0.0"
"tmp": "^0.2.5",
"uuid": "^13.0.0",
"winston": "^3.19.0",
"winston-daily-rotate-file": "^5.0.0",
"ws": "^8.19.0"
},
"devDependencies": {
"@types/mime-types": "^2.1.4",
"@types/node": "^20.12.2",
"@types/mime-types": "^3.0.1",
"@types/node": "^25.0.8",
"@types/node-cron": "^3.0.11",
"@types/node-fetch": "^3.0.3",
"@types/tmp": "^0.2.6",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"@types/ws": "^8.18.1",
"@typescript-eslint/eslint-plugin": "^8.53.0",
"@typescript-eslint/parser": "^8.53.0",
"eslint": "^9.39.2",
"eslint-config-prettier": "^10.1.8",
"eslint-config-standard": "^17.1.0",
"eslint-config-standard-with-typescript": "^21.0.1",
"eslint-plugin-ava": "^14.0.0",
"eslint-plugin-import": "^2.29.1",
"eslint-config-standard-with-typescript": "^43.0.1",
"eslint-plugin-ava": "^15.1.0",
"eslint-plugin-import": "^2.32.0",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-promise": "^6.1.1",
"fluture": "^14.0.0",
"husky": "^9.0.11",
"prettier": "^3.2.5",
"tdlib-types": "td-1.8.14",
"typedoc": "^0.25.12",
"typescript": "^5.4.3"
"eslint-plugin-prettier": "^5.5.5",
"eslint-plugin-promise": "^7.2.1",
"husky": "^9.1.7",
"pinst": "^3.0.0",
"prettier": "^3.7.4",
"tslib": "^2.8.1",
"typedoc": "^0.28.16",
"typescript": "^5.9.3",
"typescript-eslint": "^8.53.0"
},
"keywords": [
"polaris",
"polaris js",
"polaris.js",
"telegram",
"telegram bot api",
"bot",
"botapi",
"bot framework"
Expand Down
129 changes: 129 additions & 0 deletions src/actions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { Bot } from './bot';
import { ConversationInfo, Message, User } from './types';

export class Actions {
bot: Bot;

constructor(bot: Bot) {
this.bot = bot;
}

async getMessage(chatId: string | number, messageId: string | number, ignoreReply?: boolean): Promise<Message> {
return this.bot.sendCommand('getMessage', {
chatId,
messageId,
ignoreReply,
}) as Promise<Message>;
}
async deleteMessage(chatId: string | number, messageId: string | number): Promise<boolean> {
return this.bot.sendCommand('deleteMessage', {
chatId,
messageId,
}) as Promise<boolean>;
}
async getFile(fileId: string | number, link?: boolean): Promise<string> {
return this.bot.sendCommand('getFile', {
fileId,
link,
}) as Promise<string>;
}
async createInviteLink(
conversationId: string | number,
name?: string,
createsJoinRequest?: boolean,
expirationDate?: number,
memberLimit?: number,
): Promise<string> {
return this.bot.sendCommand('createInviteLink', {
conversationId,
name,
createsJoinRequest,
expirationDate,
memberLimit,
}) as Promise<string>;
}
async checkInviteLink(inviteLink: string | number): Promise<boolean> {
return this.bot.sendCommand('checkInviteLink', {
inviteLink,
}) as Promise<boolean>;
}
async joinByInviteLink(inviteLink: string | number): Promise<boolean> {
return this.bot.sendCommand('joinByInviteLink', {
inviteLink,
}) as Promise<boolean>;
}
async inviteConversationMember(conversationId: string | number, userId: string | number): Promise<boolean> {
return this.bot.sendCommand('inviteConversationMember', {
conversationId,
userId,
}) as Promise<boolean>;
}
async promoteConversationMember(conversationId: string | number, userId: string | number): Promise<boolean> {
return this.bot.sendCommand('promoteConversationMember', {
conversationId,
userId,
}) as Promise<boolean>;
}
async kickConversationMember(conversationId: string | number, userId: string | number): Promise<boolean> {
return this.bot.sendCommand('kickConversationMember', {
conversationId,
userId,
}) as Promise<boolean>;
}
async leaveConversation(conversationId: string | number): Promise<boolean> {
return this.bot.sendCommand('leaveConversation', {
conversationId,
}) as Promise<boolean>;
}
async banConversationMember(conversationId: string | number, userId: string | number): Promise<boolean> {
return this.bot.sendCommand('banConversationMember', {
conversationId,
userId,
}) as Promise<boolean>;
}
async unbanConversationMember(conversationId: string | number, userId: string | number): Promise<boolean> {
return this.bot.sendCommand('unbanConversationMember', {
conversationId,
userId,
}) as Promise<boolean>;
}
async renameConversation(conversationId: string | number, title: string): Promise<boolean> {
return this.bot.sendCommand('renameConversation', {
conversationId,
title,
}) as Promise<boolean>;
}
async changeConversationDescription(conversationId: string | number, description: string): Promise<boolean> {
return this.bot.sendCommand('changeConversationDescription', {
conversationId,
description,
}) as Promise<boolean>;
}
async changeConversationPhoto(conversationId: string | number, photo: string): Promise<boolean> {
return this.bot.sendCommand('changeConversationPhoto', {
conversationId,
photo,
}) as Promise<boolean>;
}
async createCall(conversationId: string | number, isVideo: boolean): Promise<boolean> {
return this.bot.sendCommand('createCall', {
conversationId,
isVideo,
}) as Promise<boolean>;
}
async conversationInfo(conversationId: string | number): Promise<ConversationInfo> {
return this.bot.sendCommand('conversationInfo', {
conversationId,
}) as Promise<ConversationInfo>;
}
async getChatAdministrators(conversationId: string | number): Promise<User[]> {
return this.bot.sendCommand('getChatAdministrators', {
conversationId,
}) as Promise<User[]>;
}
async setCommands(commands: any[]): Promise<boolean> {
return this.bot.sendCommand('setCommands', {
commands,
}) as Promise<boolean>;
}
}
Loading