mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-22 11:00:48 +03:00
Add /roomnick command
This commit is contained in:
parent
7de1fc62e8
commit
23e4408fa8
3 changed files with 26 additions and 0 deletions
|
@ -300,6 +300,29 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
|||
connect(text_input_, &TextInputWidget::sendBanRoomRequest, this, &ChatPage::banUser);
|
||||
connect(text_input_, &TextInputWidget::sendUnbanRoomRequest, this, &ChatPage::unbanUser);
|
||||
|
||||
connect(
|
||||
text_input_, &TextInputWidget::changeRoomNick, this, [this](const QString &displayName) {
|
||||
mtx::events::state::Member member;
|
||||
member.display_name = displayName.toStdString();
|
||||
member.avatar_url =
|
||||
cache::avatarUrl(currentRoom(),
|
||||
QString::fromStdString(http::client()->user_id().to_string()))
|
||||
.toStdString();
|
||||
member.membership = mtx::events::state::Membership::Join;
|
||||
|
||||
http::client()
|
||||
->send_state_event<mtx::events::state::Member,
|
||||
mtx::events::EventType::RoomMember>(
|
||||
currentRoom().toStdString(),
|
||||
http::client()->user_id().to_string(),
|
||||
member,
|
||||
[](mtx::responses::EventId, mtx::http::RequestErr err) {
|
||||
if (err)
|
||||
nhlog::net()->error("Failed to set room displayname: {}",
|
||||
err->matrix_error.error);
|
||||
});
|
||||
});
|
||||
|
||||
connect(
|
||||
text_input_,
|
||||
&TextInputWidget::uploadMedia,
|
||||
|
|
|
@ -576,6 +576,8 @@ TextInputWidget::command(QString command, QString args)
|
|||
sendBanRoomRequest(args.section(' ', 0, 0), args.section(' ', 1, -1));
|
||||
} else if (command == "unban") {
|
||||
sendUnbanRoomRequest(args.section(' ', 0, 0), args.section(' ', 1, -1));
|
||||
} else if (command == "roomnick") {
|
||||
changeRoomNick(args);
|
||||
} else if (command == "shrug") {
|
||||
sendTextMessage("¯\\_(ツ)_/¯");
|
||||
} else if (command == "fliptable") {
|
||||
|
|
|
@ -167,6 +167,7 @@ signals:
|
|||
void sendKickRoomRequest(const QString &userid, const QString &reason);
|
||||
void sendBanRoomRequest(const QString &userid, const QString &reason);
|
||||
void sendUnbanRoomRequest(const QString &userid, const QString &reason);
|
||||
void changeRoomNick(const QString &displayname);
|
||||
|
||||
void startedTyping();
|
||||
void stoppedTyping();
|
||||
|
|
Loading…
Reference in a new issue