summaryrefslogtreecommitdiff
path: root/protocols/Discord
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-02-22 20:32:09 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-02-22 20:32:09 +0300
commitaffa00fc0e6eb69d36b6bdb66bbef468f9ed236a (patch)
tree95c32bcfff2c75774a864ac0e8e1f234525a1bdb /protocols/Discord
parent833690b17bdf2393d41bf2f08334a7983eefab82 (diff)
channel renaming support
Diffstat (limited to 'protocols/Discord')
-rw-r--r--protocols/Discord/src/dispatch.cpp6
-rw-r--r--protocols/Discord/src/groupchat.cpp18
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;