Skip to content

Commit

Permalink
Merge branch 'beta'
Browse files Browse the repository at this point in the history
  • Loading branch information
ptkdev committed Nov 7, 2022
2 parents 5b520f1 + 9b6b590 commit 6774511
Show file tree
Hide file tree
Showing 34 changed files with 3,665 additions and 4,590 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Expand Up @@ -12,4 +12,8 @@ indent_size = 4

[*.py]
indent_style = space
indent_size = 4

[*.yml]
indent_style = space
indent_size = 4
7 changes: 4 additions & 3 deletions .github/workflows/beta.yml
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: "!startsWith(github.event.head_commit.message, '[🚀 Release]')"
if: "!startsWith(github.event.head_commit.message, '[🚀 Release Beta]')"
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -19,10 +19,11 @@ jobs:
- run: git config --global user.email 'support@ptkdev.io'
- run: npm ci
- run: npm run github-workflow-next-version -- --cmd beta
- run: npm run release
- run: npm run pre-commit
- id: pkgjson
run: chmod +x ./scripts/version.sh && ./scripts/version.sh
- run: git add . && git commit -m "[🚀 Release] v${{ steps.pkgjson.outputs.pkgversion }}" && git push
- run: git add . && git commit -m "[🚀 Release Beta] v${{ steps.pkgjson.outputs.pkgversion }}" && git push
- run: npm publish --tag beta
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
Expand All @@ -31,4 +32,4 @@ jobs:
- run: npm run pre-commit
- id: nextnightly
run: chmod +x ./scripts/version.sh && ./scripts/version.sh
- run: git add . && git commit -m "[🚀 Release] v${{ steps.nextnightly.outputs.pkgversion }}" && git push
- run: git add . && git commit -m "[🚀 Release Nightly] v${{ steps.nextnightly.outputs.pkgversion }}" && git push
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Expand Up @@ -6,6 +6,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
if: "!startsWith(github.event.head_commit.message, '[🚀 Release]')"
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -18,6 +19,7 @@ jobs:
- run: git config --global user.email 'support@ptkdev.io'
- run: npm ci
- run: npm run github-workflow-next-version -- --cmd main
- run: npm run release
- run: npm run pre-commit
- id: pkgjson
run: chmod +x ./scripts/version.sh && ./scripts/version.sh
Expand Down
9 changes: 4 additions & 5 deletions .github/workflows/nightly.yml
Expand Up @@ -2,13 +2,10 @@ name: Release Nightly
on:
schedule:
- cron: "30 23 * * *"
push:
branches:
- nightly
jobs:
build:
runs-on: ubuntu-latest
if: "!startsWith(github.event.head_commit.message, '[🚀 Release]') || startsWith(github.event.head_commit.message, '[🚀 Release] Nightly')"
if: "!startsWith(github.event.head_commit.message, '[🚀 Release Nightly]')"
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -22,10 +19,12 @@ jobs:
- run: git config --global user.email 'support@ptkdev.io'
- run: npm ci
- run: npm run github-workflow-next-version -- --cmd nightly
- run: npm run pkg-upgrade
- run: npm run release
- run: npm run pre-commit
- id: pkgjson
run: chmod +x ./scripts/version.sh && ./scripts/version.sh
- run: git add . && git commit -m "[🚀 Release] v${{ steps.pkgjson.outputs.pkgversion }}" && git push
- run: git add . && git commit -m "[🚀 Release Nightly] v${{ steps.pkgjson.outputs.pkgversion }}" && git push
- run: npm publish --tag nightly
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
21 changes: 21 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,21 @@
name: Try Release
on:
push:
branches:
- nightly
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.GIT_TOKEN }}
ref: nightly
- uses: actions/setup-node@v2
with:
node-version: "16.x"
registry-url: "https://registry.npmjs.org"
- run: git config --global user.name 'Patryk Rzucidlo (@PTKDev)'
- run: git config --global user.email 'support@ptkdev.io'
- run: npm ci
- run: npm run release
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -121,9 +121,11 @@ npm-debug.log

# App #
#######
.env
/app/configs/config.js
/app/configs/config.ts
/app/configs/config.json
/app/configs/version.json
/app/configs/version.json
/dist
/build
1 change: 0 additions & 1 deletion .npmignore
@@ -1,5 +1,4 @@
**/*
|.github
!/extra/**/*
!*.d.ts
!*.md
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
@@ -1,6 +1,6 @@
# v0.6.2 (Juanuary 10, 2022)
# v0.6.3 (November 07, 2022)

- Fix: CI/CD
- Fix: Telegram Topics

<!-- all-shields/sponsors-badges:START -->

Expand All @@ -10,6 +10,10 @@

# v0.6.2 (Juanuary 10, 2022)

- Fix: CI/CD

# v0.6.1 (Juanuary 10, 2022)

- Fix: minor issues

# v0.6.0 (December 04, 2021)
Expand Down
4 changes: 2 additions & 2 deletions LICENSE.md
Expand Up @@ -28,7 +28,7 @@ SOFTWARE.

> Images, assets and logos
Copyleft (c) 2021 Patryk Rzucidło (PTKDev)
Copyleft (c) 2022 Patryk Rzucidło (PTKDev)

#### You are free to:

Expand All @@ -50,7 +50,7 @@ No additional restrictions — You may not apply legal terms or technological me

> Documentation and Translations
Copyleft (c) 2021 Patryk Rzucidło (PTKDev)
Copyleft (c) 2022 Patryk Rzucidło (PTKDev)

#### You are free to:

Expand Down
10 changes: 5 additions & 5 deletions README.md
Expand Up @@ -4,7 +4,7 @@

<!-- all-shields/header-badges:START -->

[![v0.6.2](https://img.shields.io/badge/version-v0.6.2-lightgray.svg?style=flat&logo=)](https://github.com/ptkdev/aboutmeinfo-telegram-bot/blob/main/CHANGELOG.md) [![](https://img.shields.io/npm/v/@ptkdev/aboutmeinfo-telegram-bot?color=CC3534&logo=npm)](https://www.npmjs.com/package/@ptkdev/aboutmeinfo-telegram-bot) [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat&logo=license)](https://github.com/ptkdev/aboutmeinfo-telegram-bot/blob/main/LICENSE.md) [![Language: TypeScript](https://img.shields.io/badge/language-typescript-blue.svg?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![Framework: Grammy](https://img.shields.io/badge/powered%20by-grammy-009dca.svg?style=flat&logo=telegram)](https://grammy.dev/) [![ECMAScript: 2019](https://img.shields.io/badge/ES-9-F7DF1E.svg?style=flat&logo=javascript)](https://github.com/tc39/ecma262) [![Discord Server](https://discordapp.com/api/guilds/383373985666301975/embed.png)](https://discord.ptkdev.io)
[![v0.6.3-beta.1](https://img.shields.io/badge/version-v0.6.3--beta.1-lightgray.svg?style=flat&logo=)](https://github.com/ptkdev/aboutmeinfo-telegram-bot/blob/main/CHANGELOG.md) [![](https://img.shields.io/npm/v/@ptkdev/aboutmeinfo-telegram-bot?color=CC3534&logo=npm)](https://www.npmjs.com/package/@ptkdev/aboutmeinfo-telegram-bot) [![License: MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat&logo=license)](https://github.com/ptkdev/aboutmeinfo-telegram-bot/blob/main/LICENSE.md) [![Language: TypeScript](https://img.shields.io/badge/language-typescript-blue.svg?style=flat&logo=typescript)](https://www.typescriptlang.org/) [![Framework: Grammy](https://img.shields.io/badge/powered%20by-grammy-009dca.svg?style=flat&logo=telegram)](https://grammy.dev/) [![ECMAScript: 2019](https://img.shields.io/badge/ES-9-F7DF1E.svg?style=flat&logo=javascript)](https://github.com/tc39/ecma262) [![Discord Server](https://discordapp.com/api/guilds/383373985666301975/embed.png)](https://discord.ptkdev.io)

<!-- all-shields/header-badges:END -->

Expand Down Expand Up @@ -75,7 +75,7 @@ About Me Info Bot: Share your social media and links on Telegram
1. Clone this repository or download [nightly](https://github.com/ptkdev/aboutmeinfo-telegram-bot/archive/nightly.zip), [beta](https://github.com/ptkdev/aboutmeinfo-telegram-bot/archive/beta.zip) or [stable](https://github.com/ptkdev/aboutmeinfo-telegram-bot/archive/main.zip).
2. Write to [@botfather](https://t.me/botfather) on telegram and create new bot (save token and set bot username)
3. Run with correct values: `npm run init:token --username name_bot --token 1234:asdfghjkl`
4. Run `npm run init`
4. Run `npm install`
5. Run `npm run dev`
6. Write `/start` on telegram bot.

Expand All @@ -84,7 +84,7 @@ About Me Info Bot: Share your social media and links on Telegram
Deploy bot to your server and:

1. Run with correct values: `npm run init:token --token asdfghjkl`
2. Run init `npm run init`
2. Run init npm install
3. Generate release `npm run release`
4. Start bot `npm run start-pm2`

Expand All @@ -100,7 +100,7 @@ Thanks to all our backers! 🙏 Donate 3$ or more on [paypal](https://www.paypal

## 👨‍💻 Contributing

I ❤️ contributions! I will happily accept your pull request! Translations, grammatical corrections (GrammarNazi you are welcome! Yes my English is bad, sorry), etc... Do not be afraid, if the code is not perfect we will work together 👯 and remember to insert your name in `.all-contributorsrc` and `package.json` file.
I ❤️ contributions! I will happily accept your pull request! (**IMPORTANT**: Only to nightly branch!) Translations, grammatical corrections (GrammarNazi you are welcome! Yes my English is bad, sorry), etc... Do not be afraid, if the code is not perfect we will work together 👯 and remember to insert your name in `.all-contributorsrc` and `package.json` file.

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

Expand Down Expand Up @@ -146,4 +146,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
- Images and logos have **CC BY-NC 4.0 License**
- Documentations and Translations have **CC BY 4.0 License**

###### Copyleft (c) 2021 [Patryk Rzucidło](https://ptk.dev) ([@PTKDev](https://twitter.com/ptkdev)) <[support@ptkdev.io](mailto:support@ptkdev.io)>
###### Copyleft (c) 2022 [Patryk Rzucidło](https://ptk.dev) ([@PTKDev](https://twitter.com/ptkdev)) <[support@ptkdev.io](mailto:support@ptkdev.io)>
2 changes: 1 addition & 1 deletion app/configs/config.js.tpl
Expand Up @@ -16,7 +16,7 @@ module.exports = {
database: { URL: process.env.MONGODB || "mongodb://localhost:27017/aboutmeinfodb" },

// Debug
debug: process.env.DEBUG || true,
debug: process.env.DEBUG || "disabled",

// LOGS
// https://github.com/ptkdev/ptkdev-logger
Expand Down
18 changes: 3 additions & 15 deletions app/functions/api/database/about.ts
Expand Up @@ -56,11 +56,7 @@ const add = async (about: AboutInterface): Promise<void> => {
*/
const remove = async (search: Record<string, number | string | boolean>): Promise<void> => {
try {
await query.findOneAndDelete(search, function (error: string) {
if (error) {
logger.error(error || "");
}
});
await query.findOneAndDelete(search);
} catch (error: any) {
logger.error(JSON.stringify(error || ""), "about.ts:remove()");
}
Expand All @@ -76,11 +72,7 @@ const remove = async (search: Record<string, number | string | boolean>): Promis
*/
const update = async (search: Record<string, number | string | boolean>, about: AboutInterface): Promise<void> => {
try {
await query.findOneAndUpdate(search, about, function (error: string) {
if (error) {
logger.error(error || "");
}
});
await query.findOneAndUpdate(search, about);
} catch (error: any) {
logger.error(JSON.stringify(error || ""), "about.ts:update()");
}
Expand All @@ -97,11 +89,7 @@ const update = async (search: Record<string, number | string | boolean>, about:
*/
const get = async (search: Record<string, number | string | boolean | { $regex: RegExp }>): Promise<AboutInterface> => {
try {
const about = await query.findOne(search, { _id: 0, __v: 0 }, function (error: string) {
if (error) {
logger.error(JSON.stringify(error || ""), "about.ts:get()");
}
});
const about = await query.findOne(search, { _id: 0, __v: 0 });

return (await about) || new query().toJSON();
} catch (error: any) {
Expand Down
18 changes: 3 additions & 15 deletions app/functions/api/database/settings.ts
Expand Up @@ -44,11 +44,7 @@ const add = async (settings: SettingsInterface): Promise<void> => {
*/
const remove = async (search: Record<string, number | string | boolean>): Promise<void> => {
try {
await query.findOneAndDelete(search, function (error: string) {
if (error) {
logger.error(error || "");
}
});
await query.findOneAndDelete(search);
} catch (error: any) {
logger.error(JSON.stringify(error || ""), "settings.ts:remove()");
}
Expand All @@ -67,11 +63,7 @@ const update = async (
settings: SettingsInterface,
): Promise<void> => {
try {
await query.findOneAndUpdate(search, settings, function (error: string) {
if (error) {
logger.error(error || "");
}
});
await query.findOneAndUpdate(search, settings);
} catch (error: any) {
logger.error(JSON.stringify(error || ""), "settings.ts:update()");
}
Expand All @@ -88,11 +80,7 @@ const update = async (
*/
const get = async (search: Record<string, number | string | boolean>): Promise<SettingsInterface> => {
try {
const settings = await query.findOne(search, { _id: 0, __v: 0 }, function (error: string) {
if (error) {
logger.error(JSON.stringify(error || ""), "settings.ts:get()");
}
});
const settings = await query.findOne(search, { _id: 0, __v: 0 });

return (await settings) || new query().toJSON();
} catch (error: any) {
Expand Down
18 changes: 3 additions & 15 deletions app/functions/api/database/users.ts
Expand Up @@ -47,11 +47,7 @@ const add = async (user: TelegramUserInterface): Promise<void> => {
*/
const remove = async (search: Record<string, number | string | boolean>): Promise<void> => {
try {
await query.findOneAndDelete(search, function (error: string) {
if (error) {
logger.error(error || "");
}
});
await query.findOneAndDelete(search);
} catch (error: any) {
logger.error(JSON.stringify(error || ""), "users.ts:remove()");
}
Expand All @@ -70,11 +66,7 @@ const update = async (
user: TelegramUserInterface,
): Promise<void> => {
try {
await query.findOneAndUpdate(search, user, function (error: string) {
if (error) {
logger.error(error || "");
}
});
await query.findOneAndUpdate(search, user);
} catch (error: any) {
logger.error(JSON.stringify(error || ""), "users.ts:update()");
}
Expand All @@ -91,11 +83,7 @@ const update = async (
*/
const get = async (search: Record<string, number | string | boolean>): Promise<TelegramUserInterface> => {
try {
const user = await query.findOne(search, { _id: 0, __v: 0 }, function (error: string) {
if (error) {
logger.error(JSON.stringify(error || ""), "users.ts:get()");
}
});
const user = await query.findOne(search, { _id: 0, __v: 0 });

return (await user) || new query().toJSON();
} catch (error: any) {
Expand Down
25 changes: 25 additions & 0 deletions app/functions/api/telegram/message.ts
Expand Up @@ -45,6 +45,15 @@ const getChatID = (ctx: any): number => {
);
};

const getThreadID = (ctx: any): number => {
return (
ctx?.update.message?.message_thread_id ||
ctx?.message?.message_thread_id ||
ctx?.update?.callback_query?.message?.message_thread_id ||
null
);
};

const getActionType = (ctx: any): string => {
return ctx?.update?.callback_query?.data || "";
};
Expand All @@ -65,6 +74,10 @@ const send = async (ctx: any, group_id: number, text: string, options: any = { p
if (group_id && text) {
let message;

const thread_id = getThreadID(ctx);
if (thread_id) {
options.message_thread_id = thread_id;
}
try {
message = await ctx.api.sendMessage(group_id, text, options);
return message;
Expand All @@ -83,6 +96,11 @@ const sendPhoto = async (
if (group_id && photo) {
let message;

const thread_id = getThreadID(ctx);
if (thread_id) {
options.message_thread_id = thread_id;
}

try {
message = await ctx.api.sendPhoto(group_id, photo, options);
return message;
Expand All @@ -102,6 +120,11 @@ const pin = async (
logger.debug(`message_id: ${message_id}`, "message.ts:pin()");

if (group_id && message_id) {
const thread_id = getThreadID(ctx);
if (thread_id) {
options.message_thread_id = thread_id;
}

try {
await ctx.api.pinChatMessage(group_id, message_id, options);
} catch (err: any) {
Expand All @@ -114,6 +137,7 @@ export {
getFullUser,
getUsername,
getChatID,
getThreadID,
getText,
getUserID,
getUserFirstName,
Expand All @@ -128,6 +152,7 @@ export default {
getFullUser,
getUsername,
getChatID,
getThreadID,
getText,
getUserID,
getUserFirstName,
Expand Down

0 comments on commit 6774511

Please sign in to comment.