mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-04-28 17:15:57 +00:00
fix: username on phone details (#40)
This commit is contained in:
parent
ad5b3c3f48
commit
e252a97696
@ -193,14 +193,18 @@ function extractMetaData(meta, key) {
|
|||||||
return line ? line.split('"')[1] : "";
|
return line ? line.split('"')[1] : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getUsername(ctx){
|
||||||
|
let userName = String(ctx.from.first_name);
|
||||||
|
if(userName.includes("<") && userName.includes(">")) {
|
||||||
|
userName = userName.replaceAll("<", "").replaceAll(">", "");
|
||||||
|
}
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = (bot) => {
|
module.exports = (bot) => {
|
||||||
bot.command(['d', 'device'], spamwatchMiddleware, async (ctx) => {
|
bot.command(['d', 'device'], spamwatchMiddleware, async (ctx) => {
|
||||||
const userId = ctx.from.id;
|
const userId = ctx.from.id;
|
||||||
let userName = String(ctx.from.first_name);
|
const userName = getUsername(ctx);
|
||||||
|
|
||||||
if(userName.includes("<") && userName.includes(">")) {
|
|
||||||
userName = userName.replaceAll("<", "").replaceAll(">", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
const phone = ctx.message.text.split(" ").slice(1).join(" ");
|
const phone = ctx.message.text.split(" ").slice(1).join(" ");
|
||||||
if (!phone) {
|
if (!phone) {
|
||||||
@ -228,7 +232,7 @@ module.exports = (bot) => {
|
|||||||
bot.action(/details:(.+):(.+)/, async (ctx) => {
|
bot.action(/details:(.+):(.+)/, async (ctx) => {
|
||||||
const url = ctx.match[1];
|
const url = ctx.match[1];
|
||||||
const userId = parseInt(ctx.match[2]);
|
const userId = parseInt(ctx.match[2]);
|
||||||
const userName = ctx.from.first_name;
|
const userName = getUsername(ctx);
|
||||||
|
|
||||||
const callbackQueryUserId = ctx.update.callback_query.from.id;
|
const callbackQueryUserId = ctx.update.callback_query.from.id;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user