Version 0.7.1
This commit is contained in:
parent
dcd6778c19
commit
1a2ec10b04
4 changed files with 14 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "aslobot-matrix",
|
"name": "aslobot-matrix",
|
||||||
"version": "0.7.0",
|
"version": "0.7.1",
|
||||||
"description": "",
|
"description": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"author": "",
|
"author": "",
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,9 @@ const getUserName = (user: IUser): string => {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return match.replaceAll("@", "");
|
let username = match.replaceAll("@", "");
|
||||||
|
username = username.charAt(0).toUpperCase() + username.slice(1);
|
||||||
|
return username;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUserFromMention = (mention: string | undefined): IUser | undefined => {
|
const getUserFromMention = (mention: string | undefined): IUser | undefined => {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import type { ICallbackStore } from "../types.js";
|
||||||
import { config } from "../../config.js";
|
import { config } from "../../config.js";
|
||||||
import { load, save, state } from "../../store/store.js";
|
import { load, save, state } from "../../store/store.js";
|
||||||
import type { TRole } from "../../store/types.js";
|
import type { TRole } from "../../store/types.js";
|
||||||
import { getUserFromMention } from "../../helpers.js";
|
import { getUserFromMention, getUserName } from "../../helpers.js";
|
||||||
|
|
||||||
let client: MatrixClient;
|
let client: MatrixClient;
|
||||||
|
|
||||||
|
|
@ -46,8 +46,12 @@ const onSetRole = async (text: string, roomId: string) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
user.role = role;
|
user.role = role;
|
||||||
|
const username = getUserName(user);
|
||||||
|
|
||||||
client.sendTextMessage(roomId, `Role for ${user} has been set to ${role}`);
|
client.sendTextMessage(
|
||||||
|
roomId,
|
||||||
|
`Role for ${username} has been set to ${role}`,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onShutdown = async (text: string, roomId: string) => {
|
const onShutdown = async (text: string, roomId: string) => {
|
||||||
|
|
|
||||||
|
|
@ -54,11 +54,9 @@ const onMe = (text: string, roomId: string, sender: string) => {
|
||||||
const onLeaderboard = (_text: string, roomId: string) => {
|
const onLeaderboard = (_text: string, roomId: string) => {
|
||||||
const mapUsersToLeaderboard = (user: IUser): string => {
|
const mapUsersToLeaderboard = (user: IUser): string => {
|
||||||
const level = getLevel(user.experience);
|
const level = getLevel(user.experience);
|
||||||
const userName = getUserName(user);
|
const username = getUserName(user);
|
||||||
const userNameMod =
|
|
||||||
userName.charAt(0).toUpperCase() + userName.slice(1);
|
|
||||||
|
|
||||||
return `<li>${userNameMod}: level <b>${level.level}</b> (${level.experienceInLevel}/${level.expToNextLevel}xp)</li>`;
|
return `<li>${username}: level <b>${level.level}</b> (${level.experienceInLevel}/${level.expToNextLevel}xp)</li>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const users = state.users.sort(
|
const users = state.users.sort(
|
||||||
|
|
@ -78,11 +76,9 @@ const onLeaderboard = (_text: string, roomId: string) => {
|
||||||
const onAILeaderboard = (_text: string, roomId: string) => {
|
const onAILeaderboard = (_text: string, roomId: string) => {
|
||||||
const mapUsersToLeaderboard = (user: IUser): string => {
|
const mapUsersToLeaderboard = (user: IUser): string => {
|
||||||
const cost = user.aiCost;
|
const cost = user.aiCost;
|
||||||
const userName = getUserName(user);
|
const username = getUserName(user);
|
||||||
const userNameMod =
|
|
||||||
userName.charAt(0).toUpperCase() + userName.slice(1);
|
|
||||||
|
|
||||||
return `<li>${userNameMod}: cost <b>${cost.toFixed(2)}$</b></li>`;
|
return `<li>${username}: cost <b>${cost.toFixed(2)}$</b></li>`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const users = state.users.sort(
|
const users = state.users.sort(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue