Browse Source

Implement messageActionBotAllowed

master
morethanwords 4 years ago
parent
commit
add128017f
  1. 28
      src/lib/appManagers/appMessagesManager.ts
  2. 2
      src/lib/langPack.ts
  3. 2
      src/lib/richtextprocessor.ts
  4. 10
      src/scss/partials/_chatBubble.scss

28
src/lib/appManagers/appMessagesManager.ts

@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
import ProgressivePreloader from "../../components/preloader";
import { CancellablePromise, deferredPromise } from "../../helpers/cancellablePromise";
import { randomLong } from "../../helpers/random";
import { Dialog as MTDialog, DialogFilter, DialogPeer, DocumentAttribute, InputMessage, Message, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, PhotoSize, SendMessageAction, Update } from "../../layer";
import { Dialog as MTDialog, DialogFilter, DialogPeer, DocumentAttribute, InputMessage, Message, MessageAction, MessagesDialogs, MessagesFilter, MessagesMessages, MessagesPeerDialogs, MethodDeclMap, PhotoSize, SendMessageAction, Update } from "../../layer";
import { InvokeApiOptions, Modify } from "../../types";
import { langPack } from "../langPack";
import { logger, LogLevels } from "../logger";
@ -2506,11 +2506,11 @@ export class AppMessagesManager { @@ -2506,11 +2506,11 @@ export class AppMessagesManager {
}
public wrapMessageActionText(message: any) {
const action = message.action;
const action = message.action as MessageAction;
let str = '';
if(action.message) {
str = RichTextProcessor.wrapRichText(action.message, {noLinebreaks: true});
if((action as MessageAction.messageActionCustomAction).message) {
str = RichTextProcessor.wrapRichText((action as MessageAction.messageActionCustomAction).message, {noLinebreaks: true});
} else {
let _ = action._;
let suffix = '';
@ -2521,9 +2521,9 @@ export class AppMessagesManager { @@ -2521,9 +2521,9 @@ export class AppMessagesManager {
return title ? `<div class="name inline" data-peer-i-d="${peerID}">${title}</div> ` : '';
};
switch(_) {
switch(action._) {
case "messageActionPhoneCall": {
_ += '.' + action.type;
_ += '.' + (action as any).type;
const duration = action.duration;
if(duration) {
@ -2539,14 +2539,28 @@ export class AppMessagesManager { @@ -2539,14 +2539,28 @@ export class AppMessagesManager {
}
case 'messageActionChatDeleteUser':
// @ts-ignore
case 'messageActionChatAddUsers':
case 'messageActionChatAddUser': {
let users: number[] = action.users || [action.user_id];
const users: number[] = (action as MessageAction.messageActionChatAddUser).users || [(action as MessageAction.messageActionChatDeleteUser).user_id];
l = langPack[_].replace('{}', users.map((userID: number) => getNameDivHTML(userID)).join(', '));
break;
}
case 'messageActionBotAllowed': {
const anchorHTML = RichTextProcessor.wrapRichText(action.domain, {
entities: [{
_: 'messageEntityUrl',
length: action.domain.length,
offset: 0
}]
});
l = langPack[_].replace('{}', anchorHTML);
break;
}
default:
str = langPack[_] || `[${action._}]`;
break;

2
src/lib/langPack.ts

@ -24,4 +24,6 @@ export const langPack: {[actionType: string]: string} = { @@ -24,4 +24,6 @@ export const langPack: {[actionType: string]: string} = {
"messageActionPhoneCall.out_ok": "Outgoing Call",
"messageActionPhoneCall.in_missed": "Missed Call",
"messageActionPhoneCall.out_missed": "Cancelled Call",
"messageActionBotAllowed": "You allowed this bot to message you when logged in {}"
};

2
src/lib/richtextprocessor.ts

@ -743,7 +743,7 @@ namespace RichTextProcessor { @@ -743,7 +743,7 @@ namespace RichTextProcessor {
return wrapRichText(text, {entities});
}
export function wrapUrl(url: string, unsafe: number | boolean): string {
export function wrapUrl(url: string, unsafe?: number | boolean): string {
if(!url.match(/^https?:\/\//i)) {
url = 'https://' + url;
}

10
src/scss/partials/_chatBubble.scss

@ -1187,6 +1187,16 @@ $bubble-margin: .25rem; @@ -1187,6 +1187,16 @@ $bubble-margin: .25rem;
font-style: normal;
}
a {
color: #fff;
}
a, .name {
&:hover {
text-decoration: underline;
}
}
.name {
cursor: pointer;
//margin-right: 5px;

Loading…
Cancel
Save