diff options
-rw-r--r-- | protocols/Discord/src/dispatch.cpp | 6 | ||||
-rw-r--r-- | protocols/Discord/src/groupchat.cpp | 18 |
2 files changed, 22 insertions, 2 deletions
diff --git a/protocols/Discord/src/dispatch.cpp b/protocols/Discord/src/dispatch.cpp index 69e3879c45..aad6c1f478 100644 --- a/protocols/Discord/src/dispatch.cpp +++ b/protocols/Discord/src/dispatch.cpp @@ -132,6 +132,12 @@ void CDiscordProto::OnCommandChannelUpdated(const JSONNode &pRoot) if (pGuild == nullptr) return; + CMStringW wszName = pRoot["name"].as_mstring(); + if (!wszName.IsEmpty()) { + CMStringW wszNewName = pGuild->wszName + L"#" + wszName; + Chat_ChangeSessionName(m_szModuleName, pUser->wszUsername, wszNewName); + } + CMStringW wszTopic = pRoot["topic"].as_mstring(); Chat_SetStatusbarText(m_szModuleName, pUser->wszUsername, wszTopic); diff --git a/protocols/Discord/src/groupchat.cpp b/protocols/Discord/src/groupchat.cpp index f6f1a43e35..7f9459de50 100644 --- a/protocols/Discord/src/groupchat.cpp +++ b/protocols/Discord/src/groupchat.cpp @@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. enum { IDM_CANCEL, - IDM_CHANGENICK, IDM_CHANGETOPIC, IDM_INVITE, IDM_DESTROY + IDM_CHANGENICK, IDM_CHANGETOPIC, IDM_INVITE, IDM_RENAME, IDM_DESTROY }; ///////////////////////////////////////////////////////////////////////////////////////// @@ -40,8 +40,9 @@ static gc_item sttLogListItems[] = { LPGENW("Change &nickname"), IDM_CHANGENICK, MENU_ITEM }, { LPGENW("Channel control"), FALSE, MENU_NEWPOPUP }, { LPGENW("Change &topic"), IDM_CHANGETOPIC, MENU_POPUPITEM }, + { LPGENW("&Rename channel"), IDM_RENAME, MENU_POPUPITEM }, { nullptr, 0, MENU_POPUPSEPARATOR }, - { LPGENW("Destroy channel"), IDM_DESTROY, MENU_POPUPITEM }, + { LPGENW("&Destroy channel"), IDM_DESTROY, MENU_POPUPITEM }, { nullptr, 100, MENU_SEPARATOR, FALSE }, { LPGENW("&Invite a user"), IDM_INVITE, MENU_ITEM }, }; @@ -109,6 +110,19 @@ void CDiscordProto::Chat_ProcessLogMenu(GCHOOK *gch) } break; + case IDM_RENAME: + es.caption = TranslateT("Enter new channel name:"); + es.type = ESF_COMBO; + es.szModuleName = m_szModuleName; + es.szDataPrefix = "chat_rename"; + if (EnterString(&es)) { + JSONNode root; root << WCHAR_PARAM("name", es.ptszResult); + CMStringA szUrl(FORMAT, "/channels/%S", pUser->wszUsername); + Push(new AsyncHttpRequest(this, REQUEST_PATCH, szUrl, nullptr, &root)); + mir_free(es.ptszResult); + } + break; + case IDM_CHANGETOPIC: es.caption = TranslateT("Enter new topic:"); es.type = ESF_RICHEDIT; |