twitter.d.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. }
  16. export declare class ScreenNameNormalizer {
  17. static _queryUser: (username: string) => Promise<string>;
  18. static normalize: (username: string) => string;
  19. static normalizeLive(username: string): Promise<string>;
  20. }
  21. export declare let sendTweet: (id: string, receiver: IChat) => void;
  22. export interface ITimelineQueryConfig {
  23. username: string;
  24. count?: number;
  25. since?: string;
  26. until?: string;
  27. noreps?: boolean;
  28. norts?: boolean;
  29. }
  30. export declare let sendTimeline: (conf: {
  31. username: string;
  32. count?: string;
  33. since?: string;
  34. until?: string;
  35. noreps?: string;
  36. norts?: string;
  37. }, receiver: IChat) => void;
  38. export declare type FullUser = TwitterTypes.FullUser;
  39. export declare type Entities = TwitterTypes.Entities;
  40. export declare type ExtendedEntities = TwitterTypes.ExtendedEntities;
  41. export declare type MediaEntity = TwitterTypes.MediaEntity;
  42. interface ITweet extends TwitterTypes.Status {
  43. user: FullUser;
  44. retweeted_status?: Tweet;
  45. }
  46. export declare type Tweet = ITweet;
  47. export declare type Tweets = ITweet[];
  48. export default class {
  49. private client;
  50. private lock;
  51. private lockfile;
  52. private workInterval;
  53. private bot;
  54. private webshotDelay;
  55. private webshot;
  56. private mode;
  57. private wsUrl;
  58. constructor(opt: IWorkerOption);
  59. launch: () => void;
  60. queryUser: (username: string) => Promise<string>;
  61. queryTimelineReverse: (conf: ITimelineQueryConfig) => Promise<ITweet[]>;
  62. queryTimeline: ({ username, count, since, until, noreps, norts }: ITimelineQueryConfig) => Promise<ITweet[]>;
  63. private workOnTweets;
  64. getTweet: (id: string, sender: (msg: string, text: string, author: string) => void) => Promise<void>;
  65. private sendTweets;
  66. work: () => void;
  67. }
  68. export {};