Add twitter user label

This commit is contained in:
Dragon Fire
2024-04-26 17:45:23 -04:00
parent b403a9b077
commit d1b5202898
+9 -1
View File
@@ -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
}; };