mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-11 11:21:16 +02:00
Add twitter user label
This commit is contained in:
@@ -118,13 +118,18 @@ module.exports = class TweetCommand extends Command {
|
|||||||
ctx.font = this.client.fonts.get('ChirpBold.ttf').toCanvasString(18);
|
ctx.font = this.client.fonts.get('ChirpBold.ttf').toCanvasString(18);
|
||||||
ctx.fillStyle = 'white';
|
ctx.fillStyle = 'white';
|
||||||
ctx.fillText(userData.name, 80, 88);
|
ctx.fillText(userData.name, 80, 88);
|
||||||
|
const nameLen = ctx.measureText(userData.name).width;
|
||||||
if (userData.checkType) {
|
if (userData.checkType) {
|
||||||
const verified = await loadImage(
|
const verified = await loadImage(
|
||||||
path.join(__dirname, '..', '..', 'assets', 'images', 'tweet', `${userData.checkType}.png`)
|
path.join(__dirname, '..', '..', 'assets', 'images', 'tweet', `${userData.checkType}.png`)
|
||||||
);
|
);
|
||||||
const nameLen = ctx.measureText(userData.name).width;
|
|
||||||
ctx.drawImage(verified, 80 + nameLen + 3, 90, 20, 20);
|
ctx.drawImage(verified, 80 + nameLen + 3, 90, 20, 20);
|
||||||
}
|
}
|
||||||
|
if (userData.label) {
|
||||||
|
const labelData = await request.get(userData.label);
|
||||||
|
const labelImg = await loadImage(labelData.body);
|
||||||
|
ctx.drawImage(labelImg, 80 + nameLen + 3 + 20 + 3, 90, 20, 20);
|
||||||
|
}
|
||||||
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(17);
|
ctx.font = this.client.fonts.get('ChirpRegular.ttf').toCanvasString(17);
|
||||||
ctx.fillStyle = '#71767b';
|
ctx.fillStyle = '#71767b';
|
||||||
ctx.fillText(`@${userData.screenName}`, 80, 113);
|
ctx.fillText(`@${userData.screenName}`, 80, 113);
|
||||||
@@ -240,11 +245,13 @@ module.exports = class TweetCommand extends Command {
|
|||||||
if (body.verifiedType === 'Government') checkType = 'gov';
|
if (body.verifiedType === 'Government') checkType = 'gov';
|
||||||
else if (body.verifiedType === 'Business') checkType = 'business';
|
else if (body.verifiedType === 'Business') checkType = 'business';
|
||||||
else if (data.user.isBlueVerified) checkType = 'blue';
|
else if (data.user.isBlueVerified) checkType = 'blue';
|
||||||
|
const label = data.user.affiliatesHighlightedLabel.label?.badge?.url;
|
||||||
return {
|
return {
|
||||||
screenName: body.screenName,
|
screenName: body.screenName,
|
||||||
name: body.name,
|
name: body.name,
|
||||||
avatar: avatarRes.body,
|
avatar: avatarRes.body,
|
||||||
avatarShape: data.user.profileImageShape,
|
avatarShape: data.user.profileImageShape,
|
||||||
|
label,
|
||||||
checkType,
|
checkType,
|
||||||
followers: body.followersCount
|
followers: body.followersCount
|
||||||
};
|
};
|
||||||
@@ -256,6 +263,7 @@ module.exports = class TweetCommand extends Command {
|
|||||||
avatar: defaultPfp,
|
avatar: defaultPfp,
|
||||||
avatarShape: 'Circle',
|
avatarShape: 'Circle',
|
||||||
checkType: null,
|
checkType: null,
|
||||||
|
label: null,
|
||||||
followers: 5,
|
followers: 5,
|
||||||
err
|
err
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user