-
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.
- Loading branch information
1 parent
810b2a8
commit 6e4a592
Showing
11 changed files
with
187 additions
and
282 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
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,18 @@ | ||
import { Test, TestingModule } from '@nestjs/testing'; | ||
import { PubSubService } from './pub-sub.service'; | ||
|
||
describe('PubSubService', () => { | ||
let service: PubSubService; | ||
|
||
beforeEach(async () => { | ||
const module: TestingModule = await Test.createTestingModule({ | ||
providers: [PubSubService], | ||
}).compile(); | ||
|
||
service = module.get<PubSubService>(PubSubService); | ||
}); | ||
|
||
it('should be defined', () => { | ||
expect(service).toBeDefined(); | ||
}); | ||
}); |
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,15 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { PubSub } from 'graphql-subscriptions'; | ||
|
||
@Injectable() | ||
export class PubSubService { | ||
private pubSub: PubSub; | ||
|
||
constructor() { | ||
this.pubSub = new PubSub(); | ||
} | ||
|
||
getPubSub(): PubSub { | ||
return this.pubSub; | ||
} | ||
} |
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
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,4 @@ | ||
import { Module } from '@nestjs/common'; | ||
|
||
@Module({}) | ||
export class TelegramStatsModule {} |
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,4 +1,43 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Hears, Help, On, Start, Update } from 'nestjs-telegraf'; | ||
import { StatsService } from 'src/stats/stats.service'; | ||
import { Context } from 'telegraf'; | ||
|
||
@Update() | ||
@Injectable() | ||
export class TelegramStatsService {} | ||
export class TelegramStatsService { | ||
constructor(private statsService: StatsService) {} | ||
|
||
getData(): { message: string } { | ||
return { message: 'Welcome to server!' }; | ||
} | ||
|
||
@Start() | ||
async startCommand(ctx: Context) { | ||
await ctx.reply('Welcome'); | ||
} | ||
|
||
@Help() | ||
async helpCommand(ctx: Context) { | ||
await ctx.reply('Send me a sticker'); | ||
} | ||
|
||
@Hears('hi') | ||
async hearsHi(ctx: Context) { | ||
await ctx.reply('Hey there'); | ||
} | ||
|
||
@On('chat_member') | ||
async onNewChatMembers(ctx: Context) { | ||
await this.statsService.createStat({ | ||
stat_id: 'telegram_channel_count', | ||
name: 'подписчиков в телеграм канале', | ||
count: await ctx.getChatMembersCount(), | ||
}); | ||
} | ||
|
||
@On('boost_added') | ||
async onBoost(ctx: Context) { | ||
console.log(ctx.botInfo); | ||
} | ||
} |
Oops, something went wrong.