-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.ts
203 lines (192 loc) · 5.94 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
// @ts-nocheck
import pgk from "./package.json"
import defaults from "./src/defaults";
import { config } from "./src/types";
import consts from "./src/consts";
import request from "./src/request";
class Yiff {
private config: config
private useragent: string
private killswitch: { enabled: boolean, instance: string }
constructor(config?: config) {
this.config = config
this.useragent = this.config?.useragent ? `${defaults.useragent} ${this.config.useragent}` : defaults.useragent
// console.log(config)
this.killswitch = {
enabled: config?.killswitch?.enabled ?? true,
instance: config?.killswitch?.instance || defaults.killswitch
}
}
/**
* Request random posts from e621
* @param tags The Tags your want to use for your Search
* @param limit the amount of posts you want back
* @param page the page you want to request
* @returns A Unfiltered e621 Response
*/
async e621(tags: string | string[], limit?: number, page?: number) {
try {
let res = await request({
site: "e621",
limit, tags, page,
useragent: this.useragent,
killswitch: this.killswitch,
apikey: this.config?.apikey?.e621
})
return res
} catch (error) {
console.error(error)
}
}
/**
* Request random posts from gelbooru
* @param tags The Tags your want to use for your Search
* @param limit the amount of posts you want back
* @returns A Unfiltered e621 Response
*/
async gelbooru(tags: string | string[], limit?: number) {
try {
let res = await request({
site: "gelbooru",
limit, tags,
useragent: this.useragent,
killswitch: this.killswitch,
})
return res
} catch (error) {
console.error(error)
}
}
/**
* Request random posts from e926
* @param tags The Tags your want to use for your Search
* @param limit the amount of posts you want back
* @param page the page you want to request
* @returns A Unfiltered e926 Response
*/
async e926(tags: string | string[], limit?: number, page?: number) {
try {
let res = await request({
site: "e926",
limit, tags, page,
useragent: this.useragent,
killswitch: this.killswitch,
apikey: this.config?.apikey?.e926
})
return res
} catch (error) {
console.error(error)
}
}
/**
* Request an Image from yiff.rest
* @param category the category you want an image from
* @param endpoint a valid endpoint of the category you want an image from
* @returns Unfiltered yiff.rest Response
*/
async yiffy(category: string, endpoint: string) {
try {
let res = await request({
site: "yiffrest",
category, endpoint,
useragent: this.useragent,
killswitch: this.killswitch,
apikey: this.config?.apikey?.yiffrest
})
return res
} catch (error) {
console.error(error)
}
}
/**
* Request an Image from the Sheri.Bot API *(most endpoints require a API Key)*
* @param endpoint a valid endpoint you want an image from
* @returns Unfiltered sheri.bot Response
*/
async sheri(endpoint: string) {
try {
let res = await request({
site: "sheri",
endpoint,
useragent: this.useragent,
killswitch: this.killswitch,
apikey: this.config?.apikey?.sheri
})
return res
} catch (error) {
console.error(error)
}
}
/**
* Request a random Image from api.floofy.dev (ALL NSFW)
* @returns Unfiltered api.floofy.dev Response
*/
async floofy() {
try {
let res = await request({
site: "floofy",
useragent: this.useragent,
killswitch: this.killswitch,
})
return res
} catch (error) {
console.error(error)
}
}
/**
* Request a random Image from shibe.online
* @param animal the animal you want an image of
* @param limit the amount of images you want back
* @returns Unfiltered shibe.online Response
*/
async shibe(animal: string, limit: number) {
try {
let res = await request({
site: "shibe",
animal, limit,
useragent: this.useragent,
killswitch: this.killswitch,
})
return res
} catch (error) {
console.error(error)
}
}
/**
* Get a random fox from randomfox.ca
* @returns Unfiltered randomfox.ca Response
*/
async fox() {
try {
let res = await request({
site: "fox",
useragent: this.useragent,
killswitch: this.killswitch,
})
return res
} catch (error) {
console.error(error)
}
}
/**
* Request an Image from Thaldr.in's API *(Endpoints require an API Key)*
* @param endpoint a valid endpoint you want an image from
* @returns Unfiltered thaldr.in/api Response
*/
async thaldrin(endpoint: string) {
try {
let res = await request({
site: "thaldrin",
endpoint,
useragent: this.useragent,
killswitch: this.killswitch,
apikey: this.config?.apikey?.thaldrin
})
return res
} catch (error) {
console.error(error)
}
}
}
Yiff.default = Yiff;
export = Yiff;