update system messages
This commit is contained in:
21
app/providers/SystemAccountsProvider/useSendSystemMessage.ts
Normal file
21
app/providers/SystemAccountsProvider/useSendSystemMessage.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useContext } from "react";
|
||||
import { SystemAccountContext } from "./SystemAccountsProvider";
|
||||
|
||||
/**
|
||||
* Возвращает функцию для отправки системного сообщения от имени указанного системного аккаунта
|
||||
*
|
||||
* ВАЖНО! Данный хук отправляет сообщение в текущий залогиненный аккаунт.
|
||||
* @param accountUsername имя системного аккаунта от которого необходимо отправить сообщение
|
||||
* @returns
|
||||
*/
|
||||
export function useSendSystemMessage(accountUsername : string) {
|
||||
const context = useContext(SystemAccountContext);
|
||||
if(!context){
|
||||
throw new Error("useSystemSend must be used within a SystemAccountProvider");
|
||||
}
|
||||
const send = (message: string) => {
|
||||
return context.sendMessageFromSystemAccount(accountUsername, message);
|
||||
}
|
||||
|
||||
return send;
|
||||
}
|
||||
Reference in New Issue
Block a user