twitter.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. "use strict";
  2. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  3. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  4. return new (P || (P = Promise))(function (resolve, reject) {
  5. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  6. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  7. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  8. step((generator = generator.apply(thisArg, _arguments || [])).next());
  9. });
  10. };
  11. Object.defineProperty(exports, "__esModule", { value: true });
  12. exports.sendTimeline = exports.sendTweet = exports.ScreenNameNormalizer = exports.linkBuilder = exports.parseLink = void 0;
  13. const fs = require("fs");
  14. const path = require("path");
  15. const Twitter = require("twitter-api-v2");
  16. const loggers_1 = require("./loggers");
  17. const koishi_1 = require("./koishi");
  18. const redis_1 = require("./redis");
  19. const utils_1 = require("./utils");
  20. const webshot_1 = require("./webshot");
  21. const parseLink = (link) => {
  22. let match = /twitter.com\/([^\/?#]+)\/lists\/([^\/?#]+)/.exec(link) ||
  23. /^([^\/?#]+)\/([^\/?#]+)$/.exec(link);
  24. if (match)
  25. return [match[1], `/lists/${match[2]}`];
  26. match =
  27. /twitter.com\/([^\/?#]+)\/status\/(\d+)/.exec(link);
  28. if (match)
  29. return [match[1], `/status/${match[2]}`];
  30. match =
  31. /twitter.com\/([^\/?#]+)/.exec(link) ||
  32. /^([^\/?#]+)$/.exec(link);
  33. if (match)
  34. return [match[1]];
  35. return;
  36. };
  37. exports.parseLink = parseLink;
  38. const linkBuilder = (userName, more = '') => {
  39. if (!userName)
  40. return;
  41. return `https://twitter.com/${userName}${more}`;
  42. };
  43. exports.linkBuilder = linkBuilder;
  44. class ScreenNameNormalizer {
  45. static normalizeLive(username) {
  46. return __awaiter(this, void 0, void 0, function* () {
  47. username = this.normalize(username);
  48. if (this._queryUser) {
  49. return yield this._queryUser(username)
  50. .then(userNameId => userNameId.split(':')[0])
  51. .catch((err) => {
  52. if (err.title === 'Not Found Error') {
  53. logger.warn(`error looking up user: ${showApiError(err)}`);
  54. return username;
  55. }
  56. return null;
  57. });
  58. }
  59. return username;
  60. });
  61. }
  62. }
  63. exports.ScreenNameNormalizer = ScreenNameNormalizer;
  64. ScreenNameNormalizer.normalize = (username) => username.toLowerCase().replace(/^@/, '');
  65. let sendTweet = (id, receiver, forceRefresh) => {
  66. throw Error();
  67. };
  68. exports.sendTweet = sendTweet;
  69. let sendTimeline = (conf, receiver) => {
  70. throw Error();
  71. };
  72. exports.sendTimeline = sendTimeline;
  73. const TWITTER_EPOCH = 1288834974657;
  74. const snowflake = (epoch) => Number.isNaN(epoch) ? undefined :
  75. utils_1.BigNumOps.lShift(String(epoch - 1 - TWITTER_EPOCH), 22);
  76. const logger = (0, loggers_1.getLogger)('twitter');
  77. const maxTrials = 3;
  78. const retryInterval = 1500;
  79. const ordinal = (n) => {
  80. switch ((Math.trunc(n / 10) % 10 === 1) ? 0 : n % 10) {
  81. case 1:
  82. return `${n}st`;
  83. case 2:
  84. return `${n}nd`;
  85. case 3:
  86. return `${n}rd`;
  87. default:
  88. return `${n}th`;
  89. }
  90. };
  91. const retryOnError = (doWork, onRetry) => new Promise(resolve => {
  92. const retry = (reason, count) => {
  93. setTimeout(() => {
  94. let terminate = false;
  95. onRetry(reason, count, defaultValue => { terminate = true; resolve(defaultValue); });
  96. if (!terminate)
  97. doWork().then(resolve).catch(error => retry(error, count + 1));
  98. }, retryInterval);
  99. };
  100. doWork().then(resolve).catch(error => retry(error, 1));
  101. });
  102. const showApiError = (err) => err.errors && err.errors[0].message || err.detail || err.stack || JSON.stringify(err);
  103. const toMutableConst = (o) => {
  104. return o;
  105. };
  106. const v2SingleParams = toMutableConst({
  107. expansions: ['attachments.media_keys', 'author_id', 'referenced_tweets.id'],
  108. 'tweet.fields': ['created_at', 'entities'],
  109. 'media.fields': ['url', 'variants', 'alt_text'],
  110. 'user.fields': ['id', 'name', 'username']
  111. });
  112. ;
  113. class default_1 {
  114. constructor(opt) {
  115. this.launch = () => {
  116. this.client.appLogin().then(client => {
  117. this.client = client.readOnly;
  118. this.webshot = new webshot_1.default(this.wsUrl, this.mode, () => setTimeout(this.work, this.workInterval * 1000));
  119. });
  120. };
  121. this.queryUser = (username) => {
  122. const thread = this.lock.threads[(0, exports.linkBuilder)(username)];
  123. if (thread && thread.id)
  124. return Promise.resolve(`${username}:${thread.id}`);
  125. return this.client.v2.userByUsername(username).then(({ data: { username, id }, errors }) => {
  126. if (errors && errors.length > 0)
  127. throw errors[0];
  128. if (thread)
  129. thread.id = id;
  130. return `${username}:${id}`;
  131. });
  132. };
  133. this.queryTimelineReverse = (conf) => {
  134. if (!conf.since)
  135. return this.queryTimeline(conf);
  136. const count = conf.count;
  137. const maxID = conf.until;
  138. conf.count = undefined;
  139. const until = () => utils_1.BigNumOps.min(maxID, utils_1.BigNumOps.plus(conf.since, String(7 * 24 * 3600 * 1000 * Math.pow(2, 22))));
  140. conf.until = until();
  141. const promise = (tweets) => this.queryTimeline(conf).then(newTweets => {
  142. tweets = newTweets.concat(tweets);
  143. conf.since = conf.until;
  144. conf.until = until();
  145. if (tweets.length >= count ||
  146. utils_1.BigNumOps.compare(conf.since, conf.until) >= 0) {
  147. return tweets.slice(-count);
  148. }
  149. return promise(tweets);
  150. });
  151. return promise([]);
  152. };
  153. this.queryTimeline = ({ username, count, since, until, noreps, norts }) => {
  154. username = username.replace(/^@?(.*)$/, '@$1');
  155. return this.queryUser(username.slice(1)).then(userNameId => {
  156. const getMore = (lastTweets = []) => {
  157. logger.info(`querying timeline of ${username} with config: ${JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (count && { count })), (since && { since })), (until && { until })), (noreps && { noreps })), (norts && { norts })))}`);
  158. return this.get('userTimeline', userNameId.split(':')[1], Object.assign(Object.assign({ expansions: ['attachments.media_keys', 'author_id'], 'tweet.fields': ['created_at'], exclude: [
  159. ...(noreps !== null && noreps !== void 0 ? noreps : true) ? ['replies'] : [],
  160. ...(norts !== null && norts !== void 0 ? norts : false) ? ['retweets'] : [],
  161. ], max_results: Math.min(Math.max(count || 0, 20), 100) }, (since && { since_id: since })), (until && { until_id: until }))).then(newTweets => {
  162. logger.info(`timeline query of ${username} yielded ${newTweets.length} new tweets`);
  163. const tweets = lastTweets.concat(newTweets.filter(({ data }) => (data.attachments || {}).media_keys));
  164. if (tweets.length < count) {
  165. until = utils_1.BigNumOps.plus('-1', newTweets.slice(-1)[0].data.id);
  166. logger.info(`starting next query at offset ${until}...`);
  167. return getMore(tweets);
  168. }
  169. logger.info(`timeline query of ${username} finished successfully, ${tweets.length} media tweets have been fetched`);
  170. return tweets.slice(0, count);
  171. });
  172. };
  173. return getMore();
  174. });
  175. };
  176. this.workOnTweets = (tweets, sendTweets, refresh = false) => Promise.all(tweets.map(({ data, includes }) => ((this.redis && !refresh) ?
  177. this.redis.waitForProcess(`webshot/${data.id}`, this.webshotDelay * 4)
  178. .then(() => this.redis.getContent(`webshot/${data.id}`)) :
  179. Promise.reject())
  180. .then(content => {
  181. if (content === null)
  182. throw Error();
  183. logger.info(`retrieved cached webshot of tweet ${data.id} from redis database, message chain:`);
  184. const { msg, text, author } = JSON.parse(content);
  185. let cacheId = data.id;
  186. const retweetRef = (data.referenced_tweets || []).find(ref => ref.type === 'retweeted');
  187. if (retweetRef)
  188. cacheId += `,rt:${retweetRef.id}`;
  189. logger.info(JSON.stringify(koishi_1.Message.parseCQCode(msg)));
  190. sendTweets(cacheId, koishi_1.Message.parseCQCode(msg), text, author);
  191. return null;
  192. })
  193. .catch(() => {
  194. this.redis.startProcess(`webshot/${data.id}`);
  195. return { data, includes };
  196. }))).then(tweets => this.webshot(tweets.filter(t => t), (cacheId, msg, text, author) => {
  197. Promise.resolve()
  198. .then(() => {
  199. if (!this.redis)
  200. return;
  201. const [twid, rtid] = cacheId.split(',rt:');
  202. logger.info(`caching webshot of tweet ${twid} to redis database`);
  203. this.redis.cacheContent(`webshot/${twid}`, JSON.stringify({ msg: koishi_1.Message.toCQCode(msg), text, author, rtid })).then(() => this.redis.finishProcess(`webshot/${twid}`));
  204. })
  205. .then(() => sendTweets(cacheId, msg, text, author));
  206. }, this.webshotDelay));
  207. this.handleRetweet = (tweet) => {
  208. const retweetRef = (tweet.data.referenced_tweets || []).find(ref => ref.type === 'retweeted');
  209. if (retweetRef)
  210. return this.client.v2.singleTweet(retweetRef.id, v2SingleParams)
  211. .then(({ data: { referenced_tweets }, includes: { media } }) => (Object.assign(Object.assign({}, tweet), { data: Object.assign(Object.assign({}, tweet.data), { referenced_tweets: [retweetRef, ...(referenced_tweets || [])] }), includes: Object.assign(Object.assign({}, tweet.includes), { media }) })));
  212. return Promise.resolve(tweet);
  213. };
  214. this.getTweet = (id, sender, refresh = false) => ((this.redis && !refresh) ?
  215. this.redis.waitForProcess(`webshot/${id}`, this.webshotDelay * 4)
  216. .then(() => this.redis.getContent(`webshot/${id}`))
  217. .then(content => {
  218. if (content === null)
  219. throw Error();
  220. const { rtid } = JSON.parse(content);
  221. return { data: Object.assign({ id }, rtid && { referenced_tweets: [{ type: 'retweeted', id: rtid }] }) };
  222. }) :
  223. Promise.reject())
  224. .catch(() => this.client.v2.singleTweet(id, v2SingleParams))
  225. .then((tweet) => {
  226. if (tweet.data.text) {
  227. logger.debug(`api returned tweet ${JSON.stringify(tweet)} for query id=${id}`);
  228. return this.handleRetweet(tweet);
  229. }
  230. else {
  231. logger.debug(`skipped querying api as this tweet has been cached`);
  232. }
  233. return tweet;
  234. })
  235. .then((tweet) => this.workOnTweets([tweet], sender, refresh));
  236. this.sendTweets = (config = { reportOnSkip: false, force: false }, ...to) => (id, msg, text, author) => {
  237. to.forEach(subscriber => {
  238. const [twid, rtid] = id.split(',rt:');
  239. const { sourceInfo: source, reportOnSkip, force } = config;
  240. const targetStr = JSON.stringify(subscriber);
  241. const send = () => retryOnError(() => this.bot.sendTo(subscriber, msg), (_, count, terminate) => {
  242. if (count <= maxTrials) {
  243. logger.warn(`retry sending to ${subscriber.chatID} for the ${ordinal(count)} time...`);
  244. }
  245. else {
  246. logger.warn(`${count - 1} consecutive failures while sending message chain, trying plain text instead...`);
  247. terminate(this.bot.sendTo(subscriber, author + text, true));
  248. }
  249. }).then(() => {
  250. if (this.redis) {
  251. logger.info(`caching push status of tweet ${rtid ? `${rtid} (RTed as ${twid})` : twid} for ${targetStr}...`);
  252. return this.redis.cacheForChat(rtid || twid, subscriber);
  253. }
  254. });
  255. ((this.redis && !force) ? this.redis.isCachedForChat(rtid || twid, subscriber) : Promise.resolve(false))
  256. .then(isCached => {
  257. if (isCached) {
  258. logger.info(`skipped subscriber ${targetStr} as tweet ${rtid ? `${rtid} (or its RT)` : twid} has been sent already`);
  259. if (!reportOnSkip)
  260. return;
  261. text = `[最近发送过的推文:${rtid || twid}]`;
  262. msg = author + text;
  263. }
  264. logger.info(`pushing data${source ? ` of ${source}` : ''} to ${targetStr}`);
  265. return send();
  266. });
  267. });
  268. };
  269. this.get = (type, targetId, params) => {
  270. const { since_id, max_results } = params;
  271. const getMore = (res) => {
  272. if (res.errors && res.errors.length > 0) {
  273. const [err] = res.errors;
  274. if (!res.data)
  275. throw err;
  276. if (err.title === 'Authorization Error') {
  277. logger.warn(`non-fatal error while querying ${type} with id ${targetId}, error: ${err.detail}`);
  278. }
  279. }
  280. if (!res.meta.next_token ||
  281. utils_1.BigNumOps.compare(res.tweets.slice(-1)[0].id, since_id || '0') !== 1 ||
  282. !since_id && res.meta.result_count >= max_results)
  283. return res;
  284. return res.fetchNext().then(getMore);
  285. };
  286. if (type === 'listTweets')
  287. delete params.since_id;
  288. return this.client.v2[type](targetId, params).then(getMore)
  289. .then(({ includes, tweets }) => tweets.map((tweet) => ({
  290. data: tweet,
  291. includes: {
  292. media: includes.medias(tweet),
  293. users: [includes.author(tweet)]
  294. }
  295. })))
  296. .then(tweets => Promise.all(tweets.map(this.handleRetweet)));
  297. };
  298. this.work = () => {
  299. const lock = this.lock;
  300. if (this.workInterval < 1)
  301. this.workInterval = 1;
  302. if (lock.feed.length === 0) {
  303. setTimeout(() => {
  304. this.work();
  305. }, this.workInterval * 1000);
  306. return;
  307. }
  308. if (lock.workon >= lock.feed.length)
  309. lock.workon = 0;
  310. if (!lock.threads[lock.feed[lock.workon]] ||
  311. !lock.threads[lock.feed[lock.workon]].subscribers ||
  312. lock.threads[lock.feed[lock.workon]].subscribers.length === 0) {
  313. logger.warn(`nobody subscribes thread ${lock.feed[lock.workon]}, removing from feed`);
  314. delete lock.threads[lock.feed[lock.workon]];
  315. lock.feed.splice(lock.workon, 1);
  316. fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
  317. this.work();
  318. return;
  319. }
  320. const currentFeed = lock.feed[lock.workon];
  321. logger.debug(`pulling feed ${currentFeed}`);
  322. const promise = new Promise(resolve => {
  323. let job = Promise.resolve();
  324. let id = lock.threads[currentFeed].id;
  325. let endpoint;
  326. let match = /https:\/\/twitter.com\/([^\/]+)\/lists\/([^\/]+)/.exec(currentFeed);
  327. if (match) {
  328. endpoint = 'listTweets';
  329. if (match[1] === 'i') {
  330. id = match[2];
  331. }
  332. else if (id === undefined) {
  333. job = job.then(() => this.client.v1.list({
  334. owner_screen_name: match[1],
  335. slug: match[2],
  336. })).then(({ id_str }) => {
  337. lock.threads[currentFeed].id = id = id_str;
  338. });
  339. }
  340. }
  341. else {
  342. match = /https:\/\/twitter.com\/([^\/]+)/.exec(currentFeed);
  343. if (match) {
  344. endpoint = 'userTimeline';
  345. if (id === undefined) {
  346. job = job.then(() => this.queryUser(match[1].replace(/^@?(.*)$/, '$1'))).then(userNameId => {
  347. lock.threads[currentFeed].id = id = userNameId.split(':')[1];
  348. });
  349. }
  350. }
  351. }
  352. const offset = lock.threads[currentFeed].offset;
  353. job.then(() => this.get(endpoint, id, Object.assign(Object.assign(Object.assign(Object.assign({}, v2SingleParams), { max_results: 20, exclude: ['retweets'] }), (offset > 0) && { since_id: offset }), (offset < -1) && { until_id: offset.slice(1) }))).catch((err) => {
  354. if (err.title === 'Not Found Error') {
  355. logger.warn(`error on fetching tweets for ${currentFeed}: ${showApiError(err)}`);
  356. lock.threads[currentFeed].subscribers.forEach(subscriber => {
  357. logger.info(`sending notfound message of ${currentFeed} to ${JSON.stringify(subscriber)}`);
  358. this.bot.sendTo(subscriber, `链接 ${currentFeed} 指向的用户或列表不存在,请退订。`).catch();
  359. });
  360. }
  361. else {
  362. logger.error(`unhandled error on fetching tweets for ${currentFeed}: ${showApiError(err)}`);
  363. }
  364. return [];
  365. }).then(resolve);
  366. });
  367. promise.then((tweets) => {
  368. logger.debug(`api returned ${JSON.stringify(tweets)} for feed ${currentFeed}`);
  369. const currentThread = lock.threads[currentFeed];
  370. const setOffset = (offset) => currentThread.offset = offset;
  371. const updateDate = () => currentThread.updatedAt = new Date().toString();
  372. if (tweets.length === 0) {
  373. if (currentThread.offset < -1) {
  374. setOffset(utils_1.BigNumOps.plus('1', currentThread.offset));
  375. }
  376. updateDate();
  377. return;
  378. }
  379. const currentUser = tweets[0].includes.users.find(user => user.id === currentThread.id);
  380. if (currentUser.username !== (0, exports.parseLink)(currentFeed)[1]) {
  381. lock.feed[lock.workon] = (0, exports.linkBuilder)(currentUser.username);
  382. }
  383. const topOfFeed = tweets[0].data.id;
  384. logger.info(`current offset: ${currentThread.offset}, current top of feed: ${topOfFeed}`);
  385. const bottomOfFeed = tweets.slice(-1)[0].data.id;
  386. const updateOffset = () => setOffset(topOfFeed);
  387. tweets = tweets.filter(({ data }) => (data.attachments || {}).media_keys);
  388. logger.info(`found ${tweets.length} tweets with extended entities`);
  389. if (currentThread.offset === '-1') {
  390. updateOffset();
  391. return;
  392. }
  393. if (currentThread.offset <= 0) {
  394. if (tweets.length === 0) {
  395. setOffset(utils_1.BigNumOps.plus('1', '-' + bottomOfFeed));
  396. lock.workon--;
  397. return;
  398. }
  399. tweets.splice(1);
  400. }
  401. if (tweets.length === 0) {
  402. updateDate();
  403. updateOffset();
  404. return;
  405. }
  406. return this.workOnTweets(tweets, this.sendTweets({ sourceInfo: `thread ${currentFeed}` }, ...currentThread.subscribers))
  407. .then(updateDate).then(updateOffset);
  408. })
  409. .then(() => {
  410. lock.workon++;
  411. let timeout = this.workInterval * 1000 / lock.feed.length;
  412. if (timeout < 1000)
  413. timeout = 1000;
  414. fs.writeFileSync(path.resolve(this.lockfile), JSON.stringify(lock));
  415. setTimeout(() => {
  416. this.work();
  417. }, timeout);
  418. });
  419. };
  420. this.client = new Twitter.TwitterApi({
  421. appKey: opt.consumerKey,
  422. appSecret: opt.consumerSecret,
  423. }).readOnly;
  424. this.lockfile = opt.lockfile;
  425. this.lock = opt.lock;
  426. this.workInterval = opt.workInterval;
  427. this.bot = opt.bot;
  428. this.webshotDelay = opt.webshotDelay;
  429. this.mode = opt.mode;
  430. this.wsUrl = opt.wsUrl;
  431. if (opt.redis)
  432. this.redis = new redis_1.default(opt.redis);
  433. ScreenNameNormalizer._queryUser = this.queryUser;
  434. exports.sendTweet = (idOrQuery, receiver, forceRefresh) => {
  435. const match = /^last(|-\d+)@([^\/?#,]+)((?:,no.*?=[^,]*)*)$/.exec(idOrQuery);
  436. const query = () => this.queryTimeline({
  437. username: match[2],
  438. count: 1 - Number(match[1]),
  439. noreps: { on: true, off: false }[match[3].replace(/.*,noreps=([^,]*).*/, '$1')],
  440. norts: { on: true, off: false }[match[3].replace(/.*,norts=([^,]*).*/, '$1')],
  441. }).then(tweets => tweets.slice(-1)[0].data.id);
  442. (match ? query() : Promise.resolve(idOrQuery))
  443. .then((id) => this.getTweet(id, this.sendTweets({ sourceInfo: `tweet ${id}`, reportOnSkip: true, force: forceRefresh }, receiver), forceRefresh))
  444. .catch((err) => {
  445. if (err.title !== 'Not Found Error') {
  446. logger.warn(`error retrieving tweet: ${showApiError(err)}`);
  447. this.bot.sendTo(receiver, `获取推文时出现错误:${showApiError(err)}`);
  448. }
  449. if (err.resource_type === 'user') {
  450. return this.bot.sendTo(receiver, `找不到用户 ${match[2].replace(/^@?(.*)$/, '@$1')}。`);
  451. }
  452. this.bot.sendTo(receiver, '找不到请求的推文,它可能已被删除。');
  453. });
  454. };
  455. exports.sendTimeline = ({ username, count, since, until, noreps, norts }, receiver) => {
  456. const countNum = Number(count) || 10;
  457. (countNum > 0 ? this.queryTimeline : this.queryTimelineReverse)({
  458. username,
  459. count: Math.abs(countNum),
  460. since: utils_1.BigNumOps.parse(since) || snowflake(new Date(since).getTime()),
  461. until: utils_1.BigNumOps.parse(until) || snowflake(new Date(until).getTime()),
  462. noreps: { on: true, off: false }[noreps],
  463. norts: { on: true, off: false }[norts],
  464. })
  465. .then(tweets => (0, utils_1.chainPromises)(tweets.map(({ data }) => () => this.bot.sendTo(receiver, `\
  466. 编号:${data.id}
  467. 时间:${data.created_at}
  468. 媒体:${(data.attachments || {}).media_keys ? '有' : '无'}
  469. 正文:\n${data.text.replace(/^([\s\S\n]{50})[\s\S\n]+?( https:\/\/t.co\/.*)?$/, '$1…$2')}`))
  470. .concat(() => this.bot.sendTo(receiver, tweets.length ?
  471. '时间线查询完毕,使用 /twipic_view <编号> 查看媒体推文详细内容。' :
  472. '时间线查询完毕,没有找到符合条件的媒体推文。'))))
  473. .catch((err) => {
  474. if (err.title !== 'Not Found Error') {
  475. logger.warn(`error retrieving timeline: ${showApiError(err)}`);
  476. return this.bot.sendTo(receiver, `获取时间线时出现错误:${showApiError(err)}`);
  477. }
  478. this.bot.sendTo(receiver, `找不到用户 ${username.replace(/^@?(.*)$/, '@$1')}。`);
  479. });
  480. };
  481. }
  482. }
  483. exports.default = default_1;