Skip to content

Commit

Permalink
updated some small things
Browse files Browse the repository at this point in the history
  • Loading branch information
mikedegeofroy committed Oct 15, 2024
1 parent 3e4c85f commit ea7b31b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 33 deletions.
2 changes: 1 addition & 1 deletion src/github-stats/github-stats.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class GithubStatsController {

await this.statsService.createStat({
stat_id: 'github_commit_count',
name: 'коммита',
name: '— количество коммитов в гитхабе',
count: updatedCount,
});

Expand Down
51 changes: 19 additions & 32 deletions src/telegram-stats/telegram-stats.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class TelegramStatsService {

await this.statsService.createStat({
stat_id: 'telegram_channel_count',
name: 'подписчиков в телеграм канале',
name: 'в телеграм канале',
count: updatedCount,
});

Expand All @@ -36,38 +36,25 @@ export class TelegramStatsService {
}
}

@On('message')
async onMessage(ctx: Context) {
if (ctx.message.chat.type !== 'private') return;

const stat_id = ctx.text.split(' ')[0];
const count = parseInt(ctx.text.split(' ')[1]);
const name = ctx.text.split(' ').slice(2).join(' ');

await this.statsService.createStat({
stat_id,
count,
name,
});
}

@On('text')
async onComment(ctx: Context) {
const lastMessage = ctx.message;

await this.statsService.createStat({
stat_id: 'telegram_channel_commented',
name: `${lastMessage.from.first_name} прокоментировал "${ctx.text}"`,
count: 0,
});
}

@On('boost_added')
async onBoost(ctx: Context) {
await this.statsService.createStat({
stat_id: 'telegram_channel_boost',
name: `${ctx.chatBoost.boost.source.user.first_name} кинул буст`,
count: 0,
});
if (ctx.chat.type === 'private') {
console.info('updated stat');
const stat_id = ctx.text.split(' ')[0];
const count = parseInt(ctx.text.split(' ')[1]);
const name = ctx.text.split(' ').slice(2).join(' ');
await this.statsService.createStat({
stat_id,
count,
name,
});
} else {
console.info('added comment');
await this.statsService.createStat({
stat_id: 'telegram_channel_commented',
name: `"${ctx.text}"`,
count: 0,
});
}
}
}

0 comments on commit ea7b31b

Please sign in to comment.