Total Complexity | 2 |
Complexity/F | 1 |
Lines of Code | 28 |
Function Count | 2 |
Duplicated Lines | 0 |
Ratio | 0 % |
Coverage | 100% |
Changes | 0 |
1 | import Twit from 'twit'; |
||
2 | import Debug from 'debug'; |
||
3 | import {BotConfig} from '..'; |
||
4 | import Tweet from '../entities/Tweet'; |
||
5 | |||
6 | export interface runArgs { |
||
7 | onSuccess?: onSuccessType |
||
8 | } |
||
9 | |||
10 | type onSuccessType = (tweet: Tweet) => Promise<void>; |
||
11 | |||
12 | 5 | export abstract class AbstractAction { |
|
13 | config: BotConfig; |
||
14 | twit: Twit; |
||
15 | debug: Debug.Debugger; |
||
16 | |||
17 | constructor(config: BotConfig, twit: Twit, debug: Debug.Debugger) { |
||
18 | 3 | this.config = config; |
|
19 | 3 | this.twit = twit; |
|
20 | 3 | this.debug = debug; |
|
21 | } |
||
22 | |||
23 | abstract run(args: runArgs): void; |
||
24 | |||
25 | protected isSuccessResponse(response: Twit.PromiseResponse): boolean { |
||
26 | 8 | return response.resp.statusCode === 200; |
|
27 | } |
||
28 | } |