-
Notifications
You must be signed in to change notification settings - Fork 42
/
keyboards.ts
213 lines (195 loc) · 4.47 KB
/
keyboards.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
204
205
206
207
208
209
210
211
212
213
import { QueryParams } from '../lexicon/types/app/bsky/feed/getFeedSkeleton'
import { AppContext } from '../config'
import { AlgoManager } from '../addn/algoManager'
import dotenv from 'dotenv'
import { Post } from '../db/schema'
import dbClient from '../db/dbClient'
dotenv.config()
// max 15 chars
export const shortname = 'keyboards'
export const handler = async (ctx: AppContext, params: QueryParams) => {
const builder = await dbClient.getLatestPostsForTag({
tag: shortname,
limit: params.limit,
cursor: params.cursor,
})
let feed = builder.map((row) => ({
post: row.uri,
}))
let cursor: string | undefined
const last = builder.at(-1)
if (last) {
cursor = `${new Date(last.indexedAt).getTime()}::${last.cid}`
}
return {
cursor,
feed,
}
}
export class manager extends AlgoManager {
public name: string = shortname
public matchTerms: string[] = [
'ajazz',
// 'akko',
'alexotos',
'alice layout',
'alu plate',
'arisu layout',
// 'alps',
'beamspring',
'boba u4',
'box jade',
'box navy',
'brown switch',
'buckling spring',
'bysellfwrdd',
'cepstrum',
'cf plate',
'(cherry|mx) black',
'(cherry|mx) blue',
'(cherry|mx) brown',
'cherry mx',
'(cherry|mx) reds',
'choc switch',
// 'clacky',
'clickbar',
'clicky switch',
'colemak dh',
'colemak',
'dcx',
'deskthority',
'dolch',
'dolice',
'domikey',
'durock',
'epomaker',
'(ergo|ergonomic) (kb|keyboard)',
'ferris (bling|compact|high|mini|sweep)',
'foam mod',
'fysellfwrdd',
'gasket mod',
'gasket mount',
'gateron',
'gazzew',
'geekhack',
'geon',
'gmk',
'gmmk',
'group buy',
'haimu',
'hall effect switch',
'hand wired (kb|keyboard)',
'hhkb',
'hipyo',
'holee mod',
'holy panda',
'ibm model f',
'ibm model m',
'kaihua',
'kailh',
'kbdfans',
'keeb',
'keycaps',
'keychron',
'keycult',
'keykobo',
'keymap',
'lemokey',
'linear switch',
'(mech|mechanical) keyboard',
'melgeek',
'microsoft natural key',
'model f',
'model m',
'monokei',
'monsgeek',
'mt3',
'mtnu',
'mysellfwrdd',
'mx switch',
'näppäimistö',
// 'nixie',
'nixies',
'norbauer',
'novelkeys',
'olkb',
'ortholinear (kb|keyboard)',
'ortho (kb|keyboard)',
'outemu',
'pbtfans',
'pom plate',
'QMK',
'QWERTY layout',
'red switch',
'sofle',
'solderless',
'split (kb|keyboard)',
'split staggered',
'staggered layout',
'switch film',
'switch lube',
'switch mod',
'switch opener',
'switch pads',
// 'switch plate',
'tactile switch',
'taeha',
'tape mod',
'tangentbord',
'tenkeyless',
'tent(ing)? angle',
'tgr 910',
'tgr jane',
'theremingoat',
// 'thock(y)?',
'tkl',
'topre',
'unicomp',
'WKL',
'zealpc',
'zfrontier',
'ZMK',
]
public re = new RegExp(
`^(?!.*\\b((swiss|french|italian|austrian) alps|mountain(s)?|dice)\\b).*\\b(${this.matchTerms.join(
'|',
)})(es|s)?\\b.*$`,
'ims',
)
public async periodicTask() {
await this.db.removeTagFromOldPosts(
this.name,
new Date().getTime() - 7 * 24 * 60 * 60 * 1000,
)
}
public async filter_post(post: Post): Promise<Boolean> {
if (post.author === 'did:plc:mcb6n67plnrlx4lg35natk2b') return false // sorry nowbreezing.ntw.app
if (post.replyRoot !== null) return false
if (this.agent === null) {
await this.start()
}
if (this.agent === null) return false
let match = false
let matchString = ''
if (post.embed?.images) {
const imagesArr = post.embed.images
imagesArr.forEach((image) => {
matchString = `${matchString} ${image.alt}`.replace('\n', ' ')
})
}
if (post.embed?.alt) {
matchString = `${matchString} ${post.embed.alt}`.replace('\n', ' ')
}
if (post.embed?.media?.alt) {
matchString = `${matchString} ${post.embed?.media?.alt}`.replace(
'\n',
' ',
)
}
matchString = `${post.text} ${matchString}`.replace('\n', ' ')
if (matchString.match(this.re) !== null) {
match = true
}
return match
}
}