twitter.d.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import TwitterTypes from 'twitter-d';
  2. import QQBot from './koishi';
  3. interface IWorkerOption {
  4. lock: ILock;
  5. lockfile: string;
  6. bot: QQBot;
  7. workInterval: number;
  8. webshotDelay: number;
  9. consumerKey: string;
  10. consumerSecret: string;
  11. accessTokenKey: string;
  12. accessTokenSecret: string;
  13. mode: number;
  14. wsUrl: string;
  15. redis?: IRedisConfig;
  16. }
  17. export declare class ScreenNameNormalizer {
  18. static _queryUser: (username: string) => Promise<string>;
  19. static normalize: (username: string) => string;
  20. static normalizeLive(username: string): Promise<string>;
  21. }
  22. export declare let sendTweet: (id: string, receiver: IChat) => void;
  23. export interface ITimelineQueryConfig {
  24. username: string;
  25. count?: number;
  26. since?: string;
  27. until?: string;
  28. noreps?: boolean;
  29. norts?: boolean;
  30. }
  31. export declare let sendTimeline: (conf: {
  32. username: string;
  33. count?: string;
  34. since?: string;
  35. until?: string;
  36. noreps?: string;
  37. norts?: string;
  38. }, receiver: IChat) => void;
  39. export declare type FullUser = TwitterTypes.FullUser;
  40. export declare type Entities = TwitterTypes.Entities;
  41. export declare type ExtendedEntities = TwitterTypes.ExtendedEntities;
  42. export declare type MediaEntity = TwitterTypes.MediaEntity;
  43. interface ITweet extends TwitterTypes.Status {
  44. user: FullUser;
  45. retweeted_status?: Tweet;
  46. }
  47. export declare type Tweet = ITweet;
  48. export declare type Tweets = ITweet[];
  49. export default class {
  50. private client;
  51. private lock;
  52. private lockfile;
  53. private workInterval;
  54. private bot;
  55. private webshotDelay;
  56. private webshot;
  57. private mode;
  58. private wsUrl;
  59. private redis;
  60. constructor(opt: IWorkerOption);
  61. launch: () => void;
  62. queryUser: (username: string) => Promise<string>;
  63. queryTimelineReverse: (conf: ITimelineQueryConfig) => Promise<ITweet[]>;
  64. queryTimeline: ({ username, count, since, until, noreps, norts }: ITimelineQueryConfig) => Promise<ITweet[]>;
  65. private workOnTweets;
  66. getTweet: (id: string, sender: (id: string, msg: string, text: string, author: string) => void) => Promise<void[]>;
  67. private sendTweets;
  68. work: () => void;
  69. }
  70. export {};