Skip to content

Commit ab2eb9d

Browse files
committed
fix: misc fixes
1 parent 097d9ec commit ab2eb9d

File tree

9 files changed

+25
-11
lines changed

9 files changed

+25
-11
lines changed

assets/locales/en/commands.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@
116116
"notPlaying": "🤨 You need to be listening to a track to interact with it."
117117
},
118118
"assembledLyrics": [
119-
"🎶 **{{artist}} - {{track}}**\n",
119+
"🎶 **{{artist}} - {{track}}**",
120120
"{{lyrics}}"
121121
],
122122
"lyrics": {
@@ -127,7 +127,7 @@
127127
"crown_one": "👑 {{position}}. **{{artistName}}** - *{{playCount}} scrobbles* ({{count}} roubo)",
128128
"crown_other": "👑 {{position}}. **{{artistName}}** - *{{playCount}} scrobbles* ({{count}} roubos)",
129129
"list": [
130-
"**{{displayName}}**'s crowns on **{{groupName}}**\n",
130+
"**{{displayName}}**'s crowns on **{{groupName}}**",
131131
"{{- crownsText}}"
132132
],
133133
"noCrowns": "You don't have any crowns in this group yet!"
@@ -171,7 +171,7 @@
171171
},
172172
"eval": [
173173
"**Code**: <pre><code class=\"language-javascript\">{{code}}</code></pre>",
174-
"**Output**: <pre><code class=\"language-javascript\">{{output}}</code></pre>\n",
174+
"**Output**: <pre><code class=\"language-javascript\">{{output}}</code></pre>",
175175
"⏱️ **Time taken**: {{time}}ms"
176176
]
177177
}

src/commandEngine/commands/targeted+registered/mealbum.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default async (ctx: Context) => {
55
const data = await getNowPlaying(ctx, 'album', false, true)
66

77
ctx.reply(`commands:mealbum`, {
8-
user: ctx.targetedUser?.name,
8+
user: ctx.registeredUser?.name,
99
artist: data.artist,
1010
album: data.album,
1111
playCount: data.playCount,

src/commandEngine/commands/targeted+registered/meartist.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default async (ctx: Context) => {
55
const data = await getNowPlaying(ctx, 'artist', false, true)
66

77
ctx.reply(`commands:meartist`, {
8-
user: ctx.targetedUser?.name,
8+
user: ctx.registeredUser?.name,
99
artist: data.artist,
1010
playCount: data.playCount,
1111
tags: ctx.registeredUserData.sendTags ? `\n*${data.tags.map(a => `#${a}`).join(' ')}*` : '',

src/commandEngine/commands/targeted+registered/metrack.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export default async (ctx: Context) => {
55
const data = await getNowPlaying(ctx, 'track', false, true)
66

77
ctx.reply(`commands:youtrack`, {
8-
user: ctx.targetedUser?.name,
8+
user: ctx.registeredUser?.name,
99
track: data.name,
1010
artist: data.artist,
1111
album: data.album,

src/multiplatformEngine/common/context.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ interface ReplyOptions {
2424
alertText?: string
2525
warning?: boolean
2626
sendImageAsPhoto?: boolean
27+
replyingToOriginal?: boolean
2728
}
2829

2930
export class MinimalContext {
@@ -105,7 +106,7 @@ export class MinimalContext {
105106
}
106107

107108
reply (translationKey: string, data: Record<string, any> = {}, options: ReplyOptions = {}) {
108-
this.replyWith = options.noTranslation ? translationKey : this.t(translationKey, data)
109+
this.replyWith = options.noTranslation ? translationKey : this.t(translationKey, data).trim()
109110

110111
// detect markdown
111112
let hasMarkdown = (this.replyWith as string).includes('*') || (this.replyWith as string).includes('`') || (this.replyWith as string).includes('[')

src/multiplatformEngine/common/message.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface Message extends Base {
88
isAnonymous: boolean
99
replyingTo?: Message
1010
replyingToUser?: User
11+
mustReply?: boolean
1112
}
1213

1314
export const buildFromTelegramMessage = (message: Record<string, any>): Message => {
@@ -17,8 +18,9 @@ export const buildFromTelegramMessage = (message: Record<string, any>): Message
1718
sentAt: message.date,
1819
isAnonymous: !!message.sender_chat,
1920
platform: 'telegram',
20-
replyingTo: message.reply_to_message ? buildFromTelegramMessage(message.reply_to_message) : undefined,
21-
replyingToUser: message.reply_to_message ? buildFromTelegramUser(message.reply_to_message.from) : undefined
21+
replyingTo: message.reply_to_message && message.reply_to_message.from.id !== 777000 ? buildFromTelegramMessage(message.reply_to_message) : undefined,
22+
replyingToUser: message.reply_to_message && message.reply_to_message.from.id !== 777000 ? buildFromTelegramUser(message.reply_to_message.from) : undefined,
23+
mustReply: message.reply_to_message?.from?.id === 777000
2224
}
2325
}
2426

src/multiplatformEngine/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class PlatformManager {
2727
}
2828
}
2929

30-
export const loadedPlatforms = await loadPlatforms()
30+
export const loadedPlatforms: Platform[] = await loadPlatforms()
3131
export let platformManager: PlatformManager | undefined
3232

3333
export const start = () => {

src/multiplatformEngine/platforms/telegram.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,9 @@ export default class Telegram extends Platform {
116116

117117
deliverMessage (ctx: Context) {
118118
const id = ctx.channel?.id || ctx.author.id
119-
const replyTo = ctx.message.replyingTo ? ctx.message.id : undefined
119+
const basedReply = (ctx.replyOptions?.replyingToOriginal || ctx.message.mustReply) ? ctx.message.id : undefined
120+
const replyTo = ctx.message.replyingTo ? ctx.message.id : basedReply
121+
120122
if (ctx.replyOptions?.sendImageAsPhoto) {
121123
return this.sendPhoto(id, { url: ctx.replyOptions!.imageURL!, caption: ctx.replyWith!.toString() }, {
122124
replyTo,

src/multiplatformEngine/utilities/telegram.ts

+9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import { commandRunner } from '../../commandEngine/index.js'
22
import { Context } from '../common/context.js'
33

4+
const trashBotEasterEgg = async (data: Record<string, any>) => {
5+
const ctx = Context.fromTelegramMessage(data, [], commandRunner)
6+
ctx.reply('🤮 yeah that bot is trash', {}, { noTranslation: true, replyingToOriginal: true })
7+
return ctx
8+
}
9+
410
export const handleTelegramMessage = async (botUser: string, data: Record<string, any>): Promise<Context | undefined> => {
11+
if (data.text.toLowerCase().includes('lastfmplusbot')) return trashBotEasterEgg(data)
12+
// if the text is "st" or "now", use Math.random() and if its smaller than 15%, run the easter egg
13+
if (['st', 'now'].includes(data.text.toLowerCase()) && Math.random() < 0.1) return trashBotEasterEgg(data)
514
if (!data.text.startsWith('/')) return
615
const [name, ...args] = data.text.replace('/', '').replace(`@${botUser}`, '').split(' ')
716
if (!commandRunner.hasCommand(name)) return

0 commit comments

Comments
 (0)