rettiwt-api 5.0.0-alpha.0 → 5.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -3
- package/.github/workflows/documentation.yml +1 -1
- package/.github/workflows/publish-alpha.yml +1 -1
- package/.github/workflows/publish.yml +1 -1
- package/.prettierignore +1 -1
- package/.tool-versions +1 -1
- package/README.md +100 -100
- package/dist/Rettiwt.d.ts +1 -1
- package/dist/Rettiwt.js +15 -8
- package/dist/Rettiwt.js.map +1 -1
- package/dist/cli.js +8 -11
- package/dist/cli.js.map +1 -1
- package/dist/collections/Extractors.d.ts +1 -0
- package/dist/collections/Extractors.js +38 -69
- package/dist/collections/Extractors.js.map +1 -1
- package/dist/collections/Groups.js +2 -1
- package/dist/collections/Groups.js.map +1 -1
- package/dist/collections/Requests.d.ts +3 -3
- package/dist/collections/Requests.js +36 -35
- package/dist/collections/Requests.js.map +1 -1
- package/dist/commands/List.js +21 -78
- package/dist/commands/List.js.map +1 -1
- package/dist/commands/Tweet.js +185 -370
- package/dist/commands/Tweet.js.map +1 -1
- package/dist/commands/User.js +129 -306
- package/dist/commands/User.js.map +1 -1
- package/dist/enums/Authentication.d.ts +18 -0
- package/dist/enums/Authentication.js +24 -0
- package/dist/enums/Authentication.js.map +1 -0
- package/dist/enums/Data.d.ts +12 -0
- package/dist/enums/Data.js +14 -1
- package/dist/enums/Data.js.map +1 -1
- package/dist/enums/Resource.d.ts +1 -0
- package/dist/enums/Resource.js +1 -0
- package/dist/enums/Resource.js.map +1 -1
- package/dist/helper/CliUtils.js +1 -2
- package/dist/helper/CliUtils.js.map +1 -1
- package/dist/helper/JsonUtils.js +6 -11
- package/dist/helper/JsonUtils.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/models/args/FetchArgs.d.ts +4 -133
- package/dist/models/args/FetchArgs.js +12 -416
- package/dist/models/args/FetchArgs.js.map +1 -1
- package/dist/models/args/PostArgs.d.ts +16 -101
- package/dist/models/args/PostArgs.js +26 -258
- package/dist/models/args/PostArgs.js.map +1 -1
- package/dist/models/auth/AccountCredential.d.ts +13 -0
- package/dist/models/auth/AccountCredential.js +21 -0
- package/dist/models/auth/AccountCredential.js.map +1 -0
- package/dist/models/auth/AuthCookie.d.ts +19 -0
- package/dist/models/auth/AuthCookie.js +53 -0
- package/dist/models/auth/AuthCookie.js.map +1 -0
- package/dist/models/auth/AuthCredential.d.ts +28 -0
- package/dist/models/auth/AuthCredential.js +76 -0
- package/dist/models/auth/AuthCredential.js.map +1 -0
- package/dist/models/data/CursoredData.d.ts +3 -4
- package/dist/models/data/CursoredData.js +19 -19
- package/dist/models/data/CursoredData.js.map +1 -1
- package/dist/models/data/List.d.ts +2 -8
- package/dist/models/data/List.js +10 -4
- package/dist/models/data/List.js.map +1 -1
- package/dist/models/data/Notification.d.ts +5 -21
- package/dist/models/data/Notification.js +24 -33
- package/dist/models/data/Notification.js.map +1 -1
- package/dist/models/data/Tweet.d.ts +6 -23
- package/dist/models/data/Tweet.js +93 -97
- package/dist/models/data/Tweet.js.map +1 -1
- package/dist/models/data/User.d.ts +2 -15
- package/dist/models/data/User.js +33 -23
- package/dist/models/data/User.js.map +1 -1
- package/dist/models/errors/ApiError.js +8 -24
- package/dist/models/errors/ApiError.js.map +1 -1
- package/dist/models/errors/HttpError.js +8 -24
- package/dist/models/errors/HttpError.js.map +1 -1
- package/dist/models/errors/RettiwtError.js +5 -23
- package/dist/models/errors/RettiwtError.js.map +1 -1
- package/dist/models/errors/TimeoutError.js +5 -22
- package/dist/models/errors/TimeoutError.js.map +1 -1
- package/dist/services/{public → internal}/AuthService.d.ts +5 -34
- package/dist/services/internal/AuthService.js +109 -0
- package/dist/services/internal/AuthService.js.map +1 -0
- package/dist/services/internal/ErrorService.js +38 -40
- package/dist/services/internal/ErrorService.js.map +1 -1
- package/dist/services/internal/LogService.d.ts +0 -6
- package/dist/services/internal/LogService.js +12 -32
- package/dist/services/internal/LogService.js.map +1 -1
- package/dist/services/public/FetcherService.d.ts +5 -3
- package/dist/services/public/FetcherService.js +96 -141
- package/dist/services/public/FetcherService.js.map +1 -1
- package/dist/services/public/ListService.js +31 -100
- package/dist/services/public/ListService.js.map +1 -1
- package/dist/services/public/TweetService.d.ts +29 -4
- package/dist/services/public/TweetService.js +208 -386
- package/dist/services/public/TweetService.js.map +1 -1
- package/dist/services/public/UserService.js +186 -385
- package/dist/services/public/UserService.js.map +1 -1
- package/dist/types/RettiwtConfig.d.ts +8 -0
- package/dist/types/args/FetchArgs.d.ts +59 -0
- package/dist/types/args/FetchArgs.js +3 -0
- package/dist/types/args/FetchArgs.js.map +1 -0
- package/dist/types/args/PostArgs.d.ts +56 -0
- package/dist/types/args/PostArgs.js +3 -0
- package/dist/types/args/PostArgs.js.map +1 -0
- package/dist/types/auth/AccountCredential.d.ts +11 -0
- package/dist/types/auth/AccountCredential.js +3 -0
- package/dist/types/auth/AccountCredential.js.map +1 -0
- package/dist/types/auth/AuthCookie.d.ts +13 -0
- package/dist/types/auth/AuthCookie.js +3 -0
- package/dist/types/auth/AuthCookie.js.map +1 -0
- package/dist/types/auth/AuthCredential.d.ts +21 -0
- package/dist/types/auth/AuthCredential.js +3 -0
- package/dist/types/auth/AuthCredential.js.map +1 -0
- package/dist/types/data/CursoredData.d.ts +25 -0
- package/dist/types/data/CursoredData.js +3 -0
- package/dist/types/data/CursoredData.js.map +1 -0
- package/dist/types/data/List.d.ts +21 -0
- package/dist/types/data/List.js +3 -0
- package/dist/types/data/List.js.map +1 -0
- package/dist/types/data/Notification.d.ts +20 -0
- package/dist/types/data/Notification.js +3 -0
- package/dist/types/data/Notification.js.map +1 -0
- package/dist/types/data/Tweet.d.ts +71 -0
- package/dist/types/data/Tweet.js +3 -0
- package/dist/types/data/Tweet.js.map +1 -0
- package/dist/types/data/User.d.ts +35 -0
- package/dist/types/data/User.js +3 -0
- package/dist/types/data/User.js.map +1 -0
- package/eslint.config.mjs +17 -0
- package/package.json +22 -19
- package/src/Rettiwt.ts +1 -1
- package/src/cli.ts +0 -2
- package/src/collections/Extractors.ts +2 -0
- package/src/collections/Groups.ts +1 -0
- package/src/collections/Requests.ts +37 -36
- package/src/enums/Authentication.ts +19 -0
- package/src/enums/Data.ts +13 -0
- package/src/enums/Resource.ts +1 -0
- package/src/helper/JsonUtils.ts +1 -1
- package/src/index.ts +1 -2
- package/src/models/args/FetchArgs.ts +4 -470
- package/src/models/args/PostArgs.ts +20 -285
- package/src/models/auth/AccountCredential.ts +19 -0
- package/src/models/auth/AuthCookie.ts +56 -0
- package/src/models/auth/AuthCredential.ts +83 -0
- package/src/models/data/CursoredData.ts +12 -9
- package/src/models/data/List.ts +3 -14
- package/src/models/data/Notification.ts +6 -28
- package/src/models/data/Tweet.ts +28 -70
- package/src/models/data/User.ts +5 -31
- package/src/services/{public → internal}/AuthService.ts +28 -55
- package/src/services/internal/LogService.ts +4 -19
- package/src/services/public/FetcherService.ts +18 -8
- package/src/services/public/TweetService.ts +44 -4
- package/src/services/public/UserService.ts +2 -2
- package/src/types/RettiwtConfig.ts +7 -0
- package/src/types/args/FetchArgs.ts +64 -0
- package/src/types/args/PostArgs.ts +62 -0
- package/src/types/auth/AccountCredential.ts +13 -0
- package/src/types/auth/AuthCookie.ts +20 -0
- package/src/types/auth/AuthCredential.ts +26 -0
- package/src/types/data/CursoredData.ts +28 -0
- package/src/types/data/List.ts +27 -0
- package/src/types/data/Notification.ts +26 -0
- package/src/types/data/Tweet.ts +96 -0
- package/src/types/data/User.ts +48 -0
- package/tsconfig.json +7 -5
- package/.eslintignore +0 -3
- package/dist/commands/Auth.d.ts +0 -10
- package/dist/commands/Auth.js +0 -101
- package/dist/commands/Auth.js.map +0 -1
- package/dist/models/errors/DataValidationError.d.ts +0 -30
- package/dist/models/errors/DataValidationError.js +0 -34
- package/dist/models/errors/DataValidationError.js.map +0 -1
- package/dist/services/public/AuthService.js +0 -205
- package/dist/services/public/AuthService.js.map +0 -1
- package/src/commands/Auth.ts +0 -46
- package/src/models/errors/DataValidationError.ts +0 -44
package/dist/commands/Tweet.js
CHANGED
|
@@ -1,51 +1,8 @@
|
|
|
1
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
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
39
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
40
|
-
var m = o[Symbol.asyncIterator], i;
|
|
41
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
42
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
43
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
44
|
-
};
|
|
45
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
3
|
+
const commander_1 = require("commander");
|
|
4
|
+
const rettiwt_core_1 = require("rettiwt-core");
|
|
5
|
+
const CliUtils_1 = require("../helper/CliUtils");
|
|
49
6
|
/**
|
|
50
7
|
* Creates a new 'tweet' command which uses the given Rettiwt instance.
|
|
51
8
|
*
|
|
@@ -53,57 +10,36 @@ var CliUtils_1 = require("../helper/CliUtils");
|
|
|
53
10
|
* @returns The created 'tweet' command.
|
|
54
11
|
*/
|
|
55
12
|
function createTweetCommand(rettiwt) {
|
|
56
|
-
var _this = this;
|
|
57
13
|
// Creating the 'tweet' command
|
|
58
|
-
|
|
14
|
+
const tweet = (0, commander_1.createCommand)('tweet').description('Access resources releated to tweets');
|
|
59
15
|
// Details
|
|
60
16
|
tweet
|
|
61
17
|
.command('details')
|
|
62
18
|
.description('Fetch the details of tweet with the given id')
|
|
63
19
|
.argument('<id>', 'The id of the tweet whose details are to be fetched')
|
|
64
|
-
.action(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
(0, CliUtils_1.output)(details);
|
|
74
|
-
return [3 /*break*/, 3];
|
|
75
|
-
case 2:
|
|
76
|
-
error_1 = _a.sent();
|
|
77
|
-
(0, CliUtils_1.output)(error_1);
|
|
78
|
-
return [3 /*break*/, 3];
|
|
79
|
-
case 3: return [2 /*return*/];
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}); });
|
|
20
|
+
.action(async (id) => {
|
|
21
|
+
try {
|
|
22
|
+
const details = await rettiwt.tweet.details(id);
|
|
23
|
+
(0, CliUtils_1.output)(details);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
(0, CliUtils_1.output)(error);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
83
29
|
// Like
|
|
84
30
|
tweet
|
|
85
31
|
.command('like')
|
|
86
32
|
.description('Like a tweet')
|
|
87
33
|
.argument('<id>', 'The tweet to like')
|
|
88
|
-
.action(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
(0, CliUtils_1.output)(result);
|
|
98
|
-
return [3 /*break*/, 3];
|
|
99
|
-
case 2:
|
|
100
|
-
error_2 = _a.sent();
|
|
101
|
-
(0, CliUtils_1.output)(error_2);
|
|
102
|
-
return [3 /*break*/, 3];
|
|
103
|
-
case 3: return [2 /*return*/];
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
}); });
|
|
34
|
+
.action(async (id) => {
|
|
35
|
+
try {
|
|
36
|
+
const result = await rettiwt.tweet.like(id);
|
|
37
|
+
(0, CliUtils_1.output)(result);
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
(0, CliUtils_1.output)(error);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
107
43
|
// List
|
|
108
44
|
tweet
|
|
109
45
|
.command('list')
|
|
@@ -111,25 +47,15 @@ function createTweetCommand(rettiwt) {
|
|
|
111
47
|
.argument('<id>', 'The id of the tweet list')
|
|
112
48
|
.argument('[count]', 'The number of tweets to fetch')
|
|
113
49
|
.argument('[cursor]', 'The cursor to the batch of tweets to fetch')
|
|
114
|
-
.action(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
(0, CliUtils_1.output)(tweets);
|
|
124
|
-
return [3 /*break*/, 3];
|
|
125
|
-
case 2:
|
|
126
|
-
error_3 = _a.sent();
|
|
127
|
-
(0, CliUtils_1.output)(error_3);
|
|
128
|
-
return [3 /*break*/, 3];
|
|
129
|
-
case 3: return [2 /*return*/];
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
}); });
|
|
50
|
+
.action(async (id, count, cursor) => {
|
|
51
|
+
try {
|
|
52
|
+
const tweets = await rettiwt.tweet.list(id, count ? parseInt(count) : undefined, cursor);
|
|
53
|
+
(0, CliUtils_1.output)(tweets);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
(0, CliUtils_1.output)(error);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
133
59
|
// Post
|
|
134
60
|
tweet
|
|
135
61
|
.command('post')
|
|
@@ -138,54 +64,34 @@ function createTweetCommand(rettiwt) {
|
|
|
138
64
|
.option('-m, --media [string]', 'Comma-separated list of ids of the media item(s) to be posted')
|
|
139
65
|
.option('-q, --quote [string]', 'The id of the tweet to quote in the tweet to be posted')
|
|
140
66
|
.option('-r, --reply [string]', 'The id of the tweet to which the reply is to be made, if the tweet is to be a reply')
|
|
141
|
-
.action(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
(0, CliUtils_1.output)(result);
|
|
156
|
-
return [3 /*break*/, 3];
|
|
157
|
-
case 2:
|
|
158
|
-
error_4 = _a.sent();
|
|
159
|
-
(0, CliUtils_1.output)(error_4);
|
|
160
|
-
return [3 /*break*/, 3];
|
|
161
|
-
case 3: return [2 /*return*/];
|
|
162
|
-
}
|
|
163
|
-
});
|
|
164
|
-
}); });
|
|
67
|
+
.action(async (text, options) => {
|
|
68
|
+
try {
|
|
69
|
+
const result = await rettiwt.tweet.post({
|
|
70
|
+
text: text,
|
|
71
|
+
media: options?.media ? options?.media.split(',').map((item) => ({ id: item })) : undefined,
|
|
72
|
+
quote: options?.quote,
|
|
73
|
+
replyTo: options?.reply,
|
|
74
|
+
});
|
|
75
|
+
(0, CliUtils_1.output)(result);
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
(0, CliUtils_1.output)(error);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
165
81
|
// Retweet
|
|
166
82
|
tweet
|
|
167
83
|
.command('retweet')
|
|
168
84
|
.description('Retweet a tweet')
|
|
169
85
|
.argument('<id>', 'The tweet to retweet')
|
|
170
|
-
.action(
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
(0, CliUtils_1.output)(result);
|
|
180
|
-
return [3 /*break*/, 3];
|
|
181
|
-
case 2:
|
|
182
|
-
error_5 = _a.sent();
|
|
183
|
-
(0, CliUtils_1.output)(error_5);
|
|
184
|
-
return [3 /*break*/, 3];
|
|
185
|
-
case 3: return [2 /*return*/];
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
}); });
|
|
86
|
+
.action(async (id) => {
|
|
87
|
+
try {
|
|
88
|
+
const result = await rettiwt.tweet.retweet(id);
|
|
89
|
+
(0, CliUtils_1.output)(result);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
(0, CliUtils_1.output)(error);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
189
95
|
// Retweeters
|
|
190
96
|
tweet
|
|
191
97
|
.command('retweeters')
|
|
@@ -193,25 +99,15 @@ function createTweetCommand(rettiwt) {
|
|
|
193
99
|
.argument('<id>', 'The id of the tweet')
|
|
194
100
|
.argument('[count]', 'The number of retweeters to fetch')
|
|
195
101
|
.argument('[cursor]', 'The cursor to the batch of retweeters to fetch')
|
|
196
|
-
.action(
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
(0, CliUtils_1.output)(tweets);
|
|
206
|
-
return [3 /*break*/, 3];
|
|
207
|
-
case 2:
|
|
208
|
-
error_6 = _a.sent();
|
|
209
|
-
(0, CliUtils_1.output)(error_6);
|
|
210
|
-
return [3 /*break*/, 3];
|
|
211
|
-
case 3: return [2 /*return*/];
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
|
-
}); });
|
|
102
|
+
.action(async (id, count, cursor) => {
|
|
103
|
+
try {
|
|
104
|
+
const tweets = await rettiwt.tweet.retweeters(id, count ? parseInt(count) : undefined, cursor);
|
|
105
|
+
(0, CliUtils_1.output)(tweets);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
(0, CliUtils_1.output)(error);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
215
111
|
// Schedule
|
|
216
112
|
tweet
|
|
217
113
|
.command('schedule')
|
|
@@ -221,31 +117,21 @@ function createTweetCommand(rettiwt) {
|
|
|
221
117
|
.option('-m, --media [string]', 'Comma-separated list of ids of the media item(s) to be posted')
|
|
222
118
|
.option('-q, --quote [string]', 'The id of the tweet to quote in the tweet to be posted')
|
|
223
119
|
.option('-r, --reply [string]', 'The id of the tweet to which the reply is to be made, if the tweet is to be a reply')
|
|
224
|
-
.action(
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
(0, CliUtils_1.output)(result);
|
|
240
|
-
return [3 /*break*/, 3];
|
|
241
|
-
case 2:
|
|
242
|
-
error_7 = _a.sent();
|
|
243
|
-
(0, CliUtils_1.output)(error_7);
|
|
244
|
-
return [3 /*break*/, 3];
|
|
245
|
-
case 3: return [2 /*return*/];
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
}); });
|
|
120
|
+
.action(async (text, time, options) => {
|
|
121
|
+
try {
|
|
122
|
+
const result = await rettiwt.tweet.schedule({
|
|
123
|
+
text: text,
|
|
124
|
+
media: options?.media ? options?.media.split(',').map((item) => ({ id: item })) : undefined,
|
|
125
|
+
quote: options?.quote,
|
|
126
|
+
replyTo: options?.reply,
|
|
127
|
+
scheduleFor: new Date(time),
|
|
128
|
+
});
|
|
129
|
+
(0, CliUtils_1.output)(result);
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
(0, CliUtils_1.output)(error);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
249
135
|
// Search
|
|
250
136
|
tweet
|
|
251
137
|
.command('search')
|
|
@@ -272,182 +158,94 @@ function createTweetCommand(rettiwt) {
|
|
|
272
158
|
.option('--top', 'Matches top tweets instead of latest')
|
|
273
159
|
.option('--stream', 'Stream the filtered tweets in pseudo-realtime')
|
|
274
160
|
.option('-i, --interval <number>', 'The polling interval (in ms) to use for streaming. Default is 60000')
|
|
275
|
-
.action(
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
if (!(options === null || options === void 0 ? void 0 : options.stream)) return [3 /*break*/, 13];
|
|
283
|
-
_g.label = 1;
|
|
284
|
-
case 1:
|
|
285
|
-
_g.trys.push([1, 6, 7, 12]);
|
|
286
|
-
_a = true, _b = __asyncValues(rettiwt.tweet.stream(new TweetSearchOptions(options).toTweetFilter(), options === null || options === void 0 ? void 0 : options.interval));
|
|
287
|
-
_g.label = 2;
|
|
288
|
-
case 2: return [4 /*yield*/, _b.next()];
|
|
289
|
-
case 3:
|
|
290
|
-
if (!(_c = _g.sent(), _d = _c.done, !_d)) return [3 /*break*/, 5];
|
|
291
|
-
_f = _c.value;
|
|
292
|
-
_a = false;
|
|
293
|
-
tweet_1 = _f;
|
|
294
|
-
(0, CliUtils_1.output)(tweet_1);
|
|
295
|
-
_g.label = 4;
|
|
296
|
-
case 4:
|
|
297
|
-
_a = true;
|
|
298
|
-
return [3 /*break*/, 2];
|
|
299
|
-
case 5: return [3 /*break*/, 12];
|
|
300
|
-
case 6:
|
|
301
|
-
e_1_1 = _g.sent();
|
|
302
|
-
e_1 = { error: e_1_1 };
|
|
303
|
-
return [3 /*break*/, 12];
|
|
304
|
-
case 7:
|
|
305
|
-
_g.trys.push([7, , 10, 11]);
|
|
306
|
-
if (!(!_a && !_d && (_e = _b.return))) return [3 /*break*/, 9];
|
|
307
|
-
return [4 /*yield*/, _e.call(_b)];
|
|
308
|
-
case 8:
|
|
309
|
-
_g.sent();
|
|
310
|
-
_g.label = 9;
|
|
311
|
-
case 9: return [3 /*break*/, 11];
|
|
312
|
-
case 10:
|
|
313
|
-
if (e_1) throw e_1.error;
|
|
314
|
-
return [7 /*endfinally*/];
|
|
315
|
-
case 11: return [7 /*endfinally*/];
|
|
316
|
-
case 12: return [3 /*break*/, 15];
|
|
317
|
-
case 13: return [4 /*yield*/, rettiwt.tweet.search(new TweetSearchOptions(options).toTweetFilter(), count ? parseInt(count) : undefined, cursor)];
|
|
318
|
-
case 14:
|
|
319
|
-
tweets = _g.sent();
|
|
320
|
-
(0, CliUtils_1.output)(tweets);
|
|
321
|
-
_g.label = 15;
|
|
322
|
-
case 15: return [3 /*break*/, 17];
|
|
323
|
-
case 16:
|
|
324
|
-
error_8 = _g.sent();
|
|
325
|
-
(0, CliUtils_1.output)(error_8);
|
|
326
|
-
return [3 /*break*/, 17];
|
|
327
|
-
case 17: return [2 /*return*/];
|
|
161
|
+
.action(async (count, cursor, options) => {
|
|
162
|
+
try {
|
|
163
|
+
// If search results are to be streamed
|
|
164
|
+
if (options?.stream) {
|
|
165
|
+
for await (const tweet of rettiwt.tweet.stream(new TweetSearchOptions(options).toTweetFilter(), options?.interval)) {
|
|
166
|
+
(0, CliUtils_1.output)(tweet);
|
|
167
|
+
}
|
|
328
168
|
}
|
|
329
|
-
|
|
330
|
-
|
|
169
|
+
// If a normal search is to be done
|
|
170
|
+
else {
|
|
171
|
+
const tweets = await rettiwt.tweet.search(new TweetSearchOptions(options).toTweetFilter(), count ? parseInt(count) : undefined, cursor);
|
|
172
|
+
(0, CliUtils_1.output)(tweets);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
(0, CliUtils_1.output)(error);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
331
179
|
// Unlike
|
|
332
180
|
tweet
|
|
333
181
|
.command('unlike')
|
|
334
182
|
.description('Unlike a tweet')
|
|
335
183
|
.argument('<id>', 'The id of the tweet')
|
|
336
|
-
.action(
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
(0, CliUtils_1.output)(result);
|
|
346
|
-
return [3 /*break*/, 3];
|
|
347
|
-
case 2:
|
|
348
|
-
error_9 = _a.sent();
|
|
349
|
-
(0, CliUtils_1.output)(error_9);
|
|
350
|
-
return [3 /*break*/, 3];
|
|
351
|
-
case 3: return [2 /*return*/];
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
}); });
|
|
184
|
+
.action(async (id) => {
|
|
185
|
+
try {
|
|
186
|
+
const result = await rettiwt.tweet.unlike(id);
|
|
187
|
+
(0, CliUtils_1.output)(result);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
(0, CliUtils_1.output)(error);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
355
193
|
// Unpost
|
|
356
194
|
tweet
|
|
357
195
|
.command('unpost')
|
|
358
196
|
.description('Unpost a tweet')
|
|
359
197
|
.argument('<id>', 'The id of the tweet')
|
|
360
|
-
.action(
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
(0, CliUtils_1.output)(result);
|
|
370
|
-
return [3 /*break*/, 3];
|
|
371
|
-
case 2:
|
|
372
|
-
error_10 = _a.sent();
|
|
373
|
-
(0, CliUtils_1.output)(error_10);
|
|
374
|
-
return [3 /*break*/, 3];
|
|
375
|
-
case 3: return [2 /*return*/];
|
|
376
|
-
}
|
|
377
|
-
});
|
|
378
|
-
}); });
|
|
198
|
+
.action(async (id) => {
|
|
199
|
+
try {
|
|
200
|
+
const result = await rettiwt.tweet.unpost(id);
|
|
201
|
+
(0, CliUtils_1.output)(result);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
(0, CliUtils_1.output)(error);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
379
207
|
// Unretweet
|
|
380
208
|
tweet
|
|
381
209
|
.command('unretweet')
|
|
382
210
|
.description('Unretweet a tweet')
|
|
383
211
|
.argument('<id>', 'The id of the tweet')
|
|
384
|
-
.action(
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
(0, CliUtils_1.output)(result);
|
|
394
|
-
return [3 /*break*/, 3];
|
|
395
|
-
case 2:
|
|
396
|
-
error_11 = _a.sent();
|
|
397
|
-
(0, CliUtils_1.output)(error_11);
|
|
398
|
-
return [3 /*break*/, 3];
|
|
399
|
-
case 3: return [2 /*return*/];
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
}); });
|
|
212
|
+
.action(async (id) => {
|
|
213
|
+
try {
|
|
214
|
+
const result = await rettiwt.tweet.unretweet(id);
|
|
215
|
+
(0, CliUtils_1.output)(result);
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
(0, CliUtils_1.output)(error);
|
|
219
|
+
}
|
|
220
|
+
});
|
|
403
221
|
// Unschedule
|
|
404
222
|
tweet
|
|
405
223
|
.command('unschedule')
|
|
406
224
|
.description('Unschedule a tweet')
|
|
407
225
|
.argument('<id>', 'The id of the tweet')
|
|
408
|
-
.action(
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
(0, CliUtils_1.output)(result);
|
|
418
|
-
return [3 /*break*/, 3];
|
|
419
|
-
case 2:
|
|
420
|
-
error_12 = _a.sent();
|
|
421
|
-
(0, CliUtils_1.output)(error_12);
|
|
422
|
-
return [3 /*break*/, 3];
|
|
423
|
-
case 3: return [2 /*return*/];
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
}); });
|
|
226
|
+
.action(async (id) => {
|
|
227
|
+
try {
|
|
228
|
+
const result = await rettiwt.tweet.unschedule(id);
|
|
229
|
+
(0, CliUtils_1.output)(result);
|
|
230
|
+
}
|
|
231
|
+
catch (error) {
|
|
232
|
+
(0, CliUtils_1.output)(error);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
427
235
|
// Upload
|
|
428
236
|
tweet
|
|
429
237
|
.command('upload')
|
|
430
238
|
.description('Upload a media file and returns the alloted id (valid for 24 hrs)')
|
|
431
239
|
.argument('<path>', 'The path to the media to upload')
|
|
432
|
-
.action(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
(0, CliUtils_1.output)(id);
|
|
442
|
-
return [3 /*break*/, 3];
|
|
443
|
-
case 2:
|
|
444
|
-
error_13 = _a.sent();
|
|
445
|
-
(0, CliUtils_1.output)(error_13);
|
|
446
|
-
return [3 /*break*/, 3];
|
|
447
|
-
case 3: return [2 /*return*/];
|
|
448
|
-
}
|
|
449
|
-
});
|
|
450
|
-
}); });
|
|
240
|
+
.action(async (path) => {
|
|
241
|
+
try {
|
|
242
|
+
const id = await rettiwt.tweet.upload(path);
|
|
243
|
+
(0, CliUtils_1.output)(id);
|
|
244
|
+
}
|
|
245
|
+
catch (error) {
|
|
246
|
+
(0, CliUtils_1.output)(error);
|
|
247
|
+
}
|
|
248
|
+
});
|
|
451
249
|
return tweet;
|
|
452
250
|
}
|
|
453
251
|
/**
|
|
@@ -455,42 +253,60 @@ function createTweetCommand(rettiwt) {
|
|
|
455
253
|
*
|
|
456
254
|
* @remarks The search options are implementations of the ones offered by {@link TweetFilter}
|
|
457
255
|
*/
|
|
458
|
-
|
|
256
|
+
class TweetSearchOptions {
|
|
257
|
+
end;
|
|
258
|
+
excludeLinks = false;
|
|
259
|
+
excludeReplies = false;
|
|
260
|
+
excludeWords;
|
|
261
|
+
from;
|
|
262
|
+
hashtags;
|
|
263
|
+
interval;
|
|
264
|
+
list;
|
|
265
|
+
mentions;
|
|
266
|
+
minLikes;
|
|
267
|
+
minReplies;
|
|
268
|
+
minRetweets;
|
|
269
|
+
optionalWords;
|
|
270
|
+
phrase;
|
|
271
|
+
quoted;
|
|
272
|
+
start;
|
|
273
|
+
stream;
|
|
274
|
+
to;
|
|
275
|
+
top;
|
|
276
|
+
words;
|
|
459
277
|
/**
|
|
460
278
|
* Initializes a new object from the given options.
|
|
461
279
|
*
|
|
462
280
|
* @param options - The search options.
|
|
463
281
|
*/
|
|
464
|
-
|
|
465
|
-
this.
|
|
466
|
-
this.
|
|
467
|
-
this.
|
|
468
|
-
this.
|
|
469
|
-
this.
|
|
470
|
-
this.
|
|
471
|
-
this.
|
|
472
|
-
this.
|
|
473
|
-
this.
|
|
474
|
-
this.
|
|
475
|
-
this.
|
|
476
|
-
this.
|
|
477
|
-
this.
|
|
478
|
-
this.
|
|
479
|
-
this.
|
|
480
|
-
this.
|
|
481
|
-
this.
|
|
482
|
-
this.
|
|
483
|
-
this.
|
|
484
|
-
this.
|
|
485
|
-
this.interval = options === null || options === void 0 ? void 0 : options.interval;
|
|
486
|
-
this.top = options === null || options === void 0 ? void 0 : options.top;
|
|
282
|
+
constructor(options) {
|
|
283
|
+
this.from = options?.from;
|
|
284
|
+
this.to = options?.to;
|
|
285
|
+
this.words = options?.words;
|
|
286
|
+
this.phrase = options?.phrase;
|
|
287
|
+
this.optionalWords = options?.optionalWords;
|
|
288
|
+
this.excludeWords = options?.excludeWords;
|
|
289
|
+
this.hashtags = options?.hashtags;
|
|
290
|
+
this.list = options?.list;
|
|
291
|
+
this.mentions = options?.mentions;
|
|
292
|
+
this.minReplies = options?.minReplies;
|
|
293
|
+
this.minLikes = options?.minLikes;
|
|
294
|
+
this.minRetweets = options?.minRetweets;
|
|
295
|
+
this.quoted = options?.quoted;
|
|
296
|
+
this.excludeLinks = options?.excludeLinks;
|
|
297
|
+
this.excludeReplies = options?.excludeReplies;
|
|
298
|
+
this.start = options?.start;
|
|
299
|
+
this.end = options?.end;
|
|
300
|
+
this.stream = options?.stream;
|
|
301
|
+
this.interval = options?.interval;
|
|
302
|
+
this.top = options?.top;
|
|
487
303
|
}
|
|
488
304
|
/**
|
|
489
305
|
* Converts the filter options to a format recognizable by rettiwt-api.
|
|
490
306
|
*
|
|
491
307
|
* @returns The '{@link TweetFilter}' representation of filter options.
|
|
492
308
|
*/
|
|
493
|
-
|
|
309
|
+
toTweetFilter() {
|
|
494
310
|
return new rettiwt_core_1.TweetFilter({
|
|
495
311
|
fromUsers: this.from ? this.from.split(',') : undefined,
|
|
496
312
|
toUsers: this.to ? this.to.split(',') : undefined,
|
|
@@ -511,8 +327,7 @@ var TweetSearchOptions = /** @class */ (function () {
|
|
|
511
327
|
top: this.top,
|
|
512
328
|
endDate: this.end ? new Date(this.end) : undefined,
|
|
513
329
|
});
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
}());
|
|
330
|
+
}
|
|
331
|
+
}
|
|
517
332
|
exports.default = createTweetCommand;
|
|
518
333
|
//# sourceMappingURL=Tweet.js.map
|