Skip to content

Commit

Permalink
fix: via bot usernames cannot show
Browse files Browse the repository at this point in the history
  • Loading branch information
omg-xtao committed Apr 13, 2024
1 parent ab03cac commit b021565
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1811,7 +1811,7 @@ private boolean checkNameMotionEvent(MotionEvent event) {
if (currentViaBotUser != null && currentViaBotUser.bot_inline_placeholder == null) {
delegate.didPressViaBotNotInline(this, currentViaBotUser != null ? currentViaBotUser.id : 0);
} else {
delegate.didPressViaBot(this, currentViaBotUser != null ? currentViaBotUser.username : currentMessageObject.messageOwner.via_bot_name);
delegate.didPressViaBot(this, currentViaBotUser != null ? UserObject.getPublicUsername(currentViaBotUser) : currentMessageObject.messageOwner.via_bot_name);
}
} else if (currentUser != null) {
delegate.didPressUserAvatar(this, currentUser, event.getX(), event.getY());
Expand Down Expand Up @@ -3880,7 +3880,7 @@ public boolean onTouchEvent(MotionEvent event) {
if (currentViaBotUser != null && currentViaBotUser.bot_inline_placeholder == null) {
delegate.didPressViaBotNotInline(this, currentViaBotUser != null ? currentViaBotUser.id : 0);
} else {
delegate.didPressViaBot(this, currentViaBotUser != null ? currentViaBotUser.username : currentMessageObject.messageOwner.via_bot_name);
delegate.didPressViaBot(this, currentViaBotUser != null ? UserObject.getPublicUsername(currentViaBotUser) : currentMessageObject.messageOwner.via_bot_name);
}
}
} else if (event.getAction() == MotionEvent.ACTION_CANCEL) {
Expand Down Expand Up @@ -14854,8 +14854,9 @@ private void setMessageObjectInternal(MessageObject messageObject) {
CharSequence viaString = null;
if (messageObject.messageOwner.via_bot_id != 0) {
TLRPC.User botUser = MessagesController.getInstance(currentAccount).getUser(messageObject.messageOwner.via_bot_id);
if (botUser != null && !TextUtils.isEmpty(botUser.username)) {
viaUsername = "@" + botUser.username;
// na: fix via bot usernames
if (botUser != null && UserObject.getPublicUsername(botUser) != null) {
viaUsername = "@" + UserObject.getPublicUsername(botUser);
viaString = AndroidUtilities.replaceTags(String.format(" %s <b>%s</b>", LocaleController.getString("ViaBot", R.string.ViaBot), viaUsername));
viaWidth = (int) Math.ceil(Theme.chat_replyNamePaint.measureText(viaString, 0, viaString.length()));
currentViaBotUser = botUser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22675,7 +22675,7 @@ public boolean processSwitchButton(TLRPC.TL_keyboardButtonSwitchInline button) {
if (inlineReturn == 0 || button.same_peer || parentLayout == null) {
return false;
}
String query = "@" + currentUser.username + " " + button.query;
String query = "@" + UserObject.getPublicUsername(currentUser) + " " + button.query;
if (inlineReturn == dialog_id) {
inlineReturn = 0;
chatActivityEnterView.setFieldText(query);
Expand Down

0 comments on commit b021565

Please sign in to comment.