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

2
src/lib/langPack.ts

@ -24,4 +24,6 @@ export const langPack: {[actionType: string]: string} = {
"messageActionPhoneCall.out_ok": "Outgoing Call", "messageActionPhoneCall.out_ok": "Outgoing Call",
"messageActionPhoneCall.in_missed": "Missed Call", "messageActionPhoneCall.in_missed": "Missed Call",
"messageActionPhoneCall.out_missed": "Cancelled 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 {
return wrapRichText(text, {entities}); 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)) { if(!url.match(/^https?:\/\//i)) {
url = 'https://' + url; url = 'https://' + url;
} }

10
src/scss/partials/_chatBubble.scss

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

Loading…
Cancel
Save