Miranda NG Official Community Forum

Forum for English speaking Miranda NG users => Development => Topic started by: Vulpix on 31 01 2017, 19:01:07

Title: Discord protocol
Post by: Vulpix on 31 01 2017, 19:01:07
This topic is dedicated to Discord protocol development and alpha-testing.

Current state can be seen @ first post on github: https://github.com/miranda-ng/miranda-ng/issues/629
Title: Re: Discord protocol
Post by: Vulpix on 01 02 2017, 11:01:01
What should work:
- 1on1 chats including message history syncing and offline messages (both sending and receiving)
- changing avatar + viewing other people's avatars
- chatting in guild (group) chats you are already a part of
- adding a new friend
- accepting a friend request
- changing status (Offline, Online, NA=idle, DND)
- websocket gateway

What doesn't work but can likely be made to work
- 2FA
- File transfers
- Joining new guilds/leaving guilds (groupchats) - you have to do it from within the discord program or website and relog to discord
- Joining/leaving channels
- Miranda doesn't reflect status change made in different endpoint (i.e. if you change your status in browser discord, miranda will not reflect that)
- likely none of the nitro features

File transfers are being worked on. I believe.

Please test and see for yourself.


See first post!

Please be aware that miranda attempts to sync all of your histories when you start it and if you have a long history with direct messaging with someone, it may take a while.
Title: Re: Discord protocol
Post by: mnguser on 03 02 2017, 09:27:14
I would like to give it a try, but i can't load x64 development version of the plugin with the latest dev build of Miranda on Windows 10 x64.
Code: [Select]
The ordinal 397 could not be located in the dynamic link library <Miranda Root>\Plugins\Discord.dll.I tried scouting the plugin with Dependency Walker, but i can't spot anything unusual. Does it require some additional MSVC++ libraries? I've got all ordinary MSVC++ redistributables installed.
Title: Re: Discord protocol
Post by: ghazan on 03 02 2017, 10:26:15
I would like to give it a try, but i can't load x64 development version of the plugin with the latest dev build of Miranda on Windows 10 x64.
you're using the stable version right now, you cannot load just one new plugin and try to launch it under this version.
go to Options - Services - Plugin updater, switch to the Development version (with or without symbols) and update everything first
Title: Re: Discord protocol
Post by: mnguser on 03 02 2017, 10:40:40
My bad, it seems, I've left silent update mode enabled. Surprisingly, i tried skypeweb alpha about a year ago the same way and it never complained about compile options mismatch. :)
Title: Re: Discord protocol
Post by: mnguser on 03 02 2017, 18:24:31
Impressive. I briefly compared running standalone client next to a plugin.

First of all, amazing job. Discord standalone client consumes more than a 100mb of RAM, while miranda is under 10mb for many protocols at once. That's a major debloating for something as basic as text IM when voice chat is not required.

Online status seems to work fine, however, client sees itself as online in group chats lists even when invisible, but it's probably an intended behavior.

Most of the unimplemented stuff, unsurprisingly, goes under group chats.

Group chat nicknames are not working (everyone is displayed as accountname#nnnn, including own name). I assume, this is because discord user can have unique nickname on per-group basis and it's not supported yet.
Group chat motd/channel title is not displayed in group chat window.
Group chat direct highlights don't work yet (@nickname as seen in Discord becomes <@nnnnnnnnnnnnnnnnn> in Miranda).
Group chat channel highlights are not decyphered (<#nnnnnnnnnnnnnnnnnnn> instead of #channel in Discord).
Group chat log is named after internal channel id (nnnnnnnnnnnnnnnnnnn.log) instead of group#channel.log.
Users with group chat moderation rights are not marked or highlighted via color in the channel chat window in any way.

The biggest disadvantage compared to native discord is probably the lack of discord group chat history sync (i.e. listing messages sent per channel while offline). Is this supported in miranda globally? I've noticed this is most likely the case with skypeweb and other group chats, excluding third-party assisted (IRC BNC services).

Thanks for keeping desktop instant messaging alive.
Title: Re: Discord protocol
Post by: Vulpix on 03 02 2017, 21:58:36
Yeah, group chats were somewhat "out of scope" (or rather the message syncing) when I posted bounty on the discord support ( https://github.com/miranda-ng/miranda-ng/issues/629#issuecomment-268559665 )

Ghazan has done an amazing job implementing it because for better or worse, the actual messaging is not documented in the API.

At any rate, miranda isn't all that great for group chat history and syncing right now; we don't save history (we can log it into a text file) and in general group chats are handled differently than regular 1on1 conversations.

But I'm sure ghazan could make it work eventually :p hehe.
Title: Odp: Discord protocol
Post by: Vulpix on 05 02 2017, 23:54:08
Experienced a random crash today after messaging someone:

Quote (selected)
Miranda Crash Report from 6 Feb 2017 0:50:42. Crash Dumper v.0.0.5.2

Likely cause of the crash plugin: Discord protocol

Exception: Access Violation at address 6E550A21. Writing to address 00000064.

Stack Trace:
---------------------------------------------------------------
6E550A21 (MSVCR100 6E540000): (filename not available) (0): unlock
100083A9 (Discord 10000000): w:\miranda-ng\protocols\discord\src\gateway.cpp (237): CDiscordProto::GatewayThreadWorker
100085FB (Discord 10000000): w:\miranda-ng\protocols\discord\src\gateway.cpp (133): CDiscordProto::GatewayThread
1232CFBD (mir_core 12320000): c:\sources\miranda_ng_compilation\src\mir_core\src\threads.cpp (159): forkthreadex_r
768762C4 (KERNEL32 76860000): (filename not available) (0): BaseThreadInitThunk
77E60FD9 (ntdll 77E00000): (filename not available) (0): RtlSubscribeWnfStateChangeNotification
77E60FA4 (ntdll 77E00000): (filename not available) (0): RtlSubscribeWnfStateChangeNotification
1232CF94 (mir_core 12320000): c:\sources\miranda_ng_compilation\src\mir_core\src\threads.cpp (284): Thread_Wait
0966FE38 ((module-name not available) 00000000): (filename not available) (0): (function-name not available)

Another one after just logging in:

Quote (selected)
Miranda Crash Report from 6 Feb 2017 3:07:58. Crash Dumper v.0.0.5.2

Likely cause of the crash plugin: Discord protocol

Exception: Access Violation at address 118484AA. Reading from address 1DD208E0.

Stack Trace:
---------------------------------------------------------------
118484AA (Discord 11840000): w:\miranda-ng\protocols\discord\src\gateway.cpp (265): CDiscordProto::GatewayThreadWorker
118485FB (Discord 11840000): w:\miranda-ng\protocols\discord\src\gateway.cpp (133): CDiscordProto::GatewayThread
1232CFBD (mir_core 12320000): c:\sources\miranda_ng_compilation\src\mir_core\src\threads.cpp (159): forkthreadex_r
768762C4 (KERNEL32 76860000): (filename not available) (0): BaseThreadInitThunk
77E60FD9 (ntdll 77E00000): (filename not available) (0): RtlSubscribeWnfStateChangeNotification
77E60FA4 (ntdll 77E00000): (filename not available) (0): RtlSubscribeWnfStateChangeNotification
1232CF94 (mir_core 12320000): c:\sources\miranda_ng_compilation\src\mir_core\src\threads.cpp (284): Thread_Wait
22F3FE8C ((module-name not available) 00000000): (filename not available) (0): (function-name not available)
Title: Re: Discord protocol
Post by: ghazan on 06 02 2017, 13:56:30
Impressive. I briefly compared running standalone client next to a plugin.
Well, the "standalone client" is nothing but a Chromium, that executes tons of js :) So it's not so hard to outperform it considering RAM usage, though Miranda always was (and forever will be) very concerned about memory footprint :-)

First of all, amazing job. Discord standalone client consumes more than a 100mb of RAM, while miranda is under 10mb for many protocols at once. That's a major debloating for something as basic as text IM when voice chat is not required.
Thanks for the flattering review, the fact is that this plugin is in the very beginning, so your opinions and remarks are greatly appreciated. I'll implement them when I have spare time.
Title: Re: Discord protocol
Post by: ghazan on 07 02 2017, 19:50:49
Group chat nicknames are not working (everyone is displayed as accountname#nnnn, including own name). I assume, this is because discord user can have unique nickname on per-group basis and it's not supported yet.
done. also I implemented joining / leaving guilds on the fly
Title: Re: Discord protocol
Post by: ghazan on 08 02 2017, 19:25:54
now we can change our own nickname in chats
Title: Re: Discord protocol
Post by: Vulpix on 08 02 2017, 21:22:47
now we can change our own nickname in chats

Already more advanced than Skype where you cannot change your nickname.. :D
Title: Re: Discord protocol
Post by: Vulpix on 09 02 2017, 12:38:44
Crash after today's update while logging in:

Spoiler
Miranda Crash Report from 9 Feb 2017 13:37:37. Crash Dumper v.0.0.5.2

Likely cause of the crash plugin: Discord protocol

Exception: Access Violation at address 14BC8CCC. Reading from address 0DF507E2.

Stack Trace:
---------------------------------------------------------------
14BC8CCC (Discord 14BC0000): c:\sources\miranda_ng_compilation\protocols\discord\src\gateway.cpp (265): CDiscordProto::GatewayThreadWorker
14BC8E1D (Discord 14BC0000): c:\sources\miranda_ng_compilation\protocols\discord\src\gateway.cpp (133): CDiscordProto::GatewayThread
1232CFBD (mir_core 12320000): c:\sources\miranda_ng_compilation\src\mir_core\src\threads.cpp (159): forkthreadex_r
749662C4 (KERNEL32 74950000): (filename not available) (0): BaseThreadInitThunk
77E50FD9 (ntdll 77DF0000): (filename not available) (0): RtlSubscribeWnfStateChangeNotification
77E50FA4 (ntdll 77DF0000): (filename not available) (0): RtlSubscribeWnfStateChangeNotification
1232CF94 (mir_core 12320000): c:\sources\miranda_ng_compilation\src\mir_core\src\threads.cpp (284): Thread_Wait
09A7FE38 ((module-name not available) 00000000): (filename not available) (0): (function-name not available)

I actually had to roll back to previous discord because today's one wouldn't let me log in :o It'd always disconnect me silently ~1-2 seconds after login.
Title: Re: Discord protocol
Post by: mnguser on 09 02 2017, 17:09:29
I've noticed group leaving messages showing up and some of the names in the chat list are now displayed without numeric index (#nnnn). Good job!
Aslo noticed, that picture attachments in group chats are displayed as clickable links and don't require auth to view from browser, so at least this doesn't require additional hassle to make it work, as opposed to skype.
Title: Re: Discord protocol
Post by: ghazan on 11 02 2017, 20:36:33
topic is now retrieved/set
Title: Re: Discord protocol
Post by: Vulpix on 11 02 2017, 22:46:56
Nice!

My friend also edited his first post here so it should be easier to track:

https://github.com/miranda-ng/miranda-ng/issues/629
Title: Re: Discord protocol
Post by: ghazan on 12 02 2017, 17:54:58
highlighting implemented

Group chat log is named after internal channel id (nnnnnnnnnnnnnnnnnnn.log) instead of group#channel.log.
@mnguser what did you mean by that? replacing the unformatted number with a channel nick?
Title: Re: Discord protocol
Post by: mnguser on 13 02 2017, 18:06:30
For example the group chat log for IRC is named "#channel - Server.log" , while logs for discord channels are named by it's id instead of names. Is this intentional naming? I suppose, this is made so because group chat channel id is static and channel can be renamed without changing it's numeric id? Not a big deal then. I thought, that having discord group chat log named in the same manner as IRC log "#channel - Group.log" would look better. The difference is that IRC channel on the server name is unique and it's name won't ever change, while it's probably not the case with Discord.
Title: Re: Discord protocol
Post by: ghazan on 13 02 2017, 20:15:46
roles in chats supported
Title: Re: Discord protocol
Post by: mnguser on 17 02 2017, 23:18:17
Thanks! Name highlights seem to be working aswell. Very solid protocol plugin, as far as Miranda's limitations considered.
Title: Re: Discord protocol
Post by: Vulpix on 26 02 2017, 14:47:36
Most major bugs fixed (no longer crashing on login).

History retrieved for chat logs as well! (Thanks ghazan!). I recommend enabling text logs for tabsrmm groupchats to take advantage of it the best, but it's fine without that as well.

Not much remains to be done, other than tagging users and sending files to groupchats.
Title: Re: Discord protocol
Post by: mistafist on 16 03 2017, 14:35:29
How's it going.  When I attempt to use this plugin, 32 bit, it connects then immediately disconnects.  Keepstatus reconnects, but same thing happens over and over.  Some information is received, for example a message will come through upon reconnection.  My log shows this right before disconnecting.

Code: [Select]
[10:31:46 2104] [Discord_1] Got packet: buffer = 2048, opcode = 4, headerSize = 2, final = 0, masked = 0
[10:31:46 2104] [Discord_1] Got packet: buffer = 2048, opcode = 6, headerSize = 2, final = 0, masked = 0
[10:31:46 2104] [Discord_1] Got packet: buffer = 2048, opcode = 12, headerSize = 2, final = 0, masked = 0
[10:31:46 2104] [Discord_1] Got packet: buffer = 2048, opcode = 8, headerSize = 2, final = 0, masked = 0
[10:31:46 2104] [Discord_1] server required to exit
[10:31:46 2104] [Discord_1.Gateway] (05690648:2244) Connection closed internal
[10:31:46 2104] [Discord_1.Gateway] (05690648:4294967295) Connection closed
[10:31:46 2104] [Discord_1] CDiscordProto::ShutdownSession
[10:31:46 2104] [Discord_1] CDiscordProto::OnLoggedOut
[10:31:47 1624] [Discord_1] (0568EBF0:2188) Connection closed internal
[10:31:47 1624] [Discord_1] (0568EBF0:4294967295) Connection closed
[10:31:47 1624] [Discord_1] CDiscordProto::WorkerThread: leaving
Title: Re: Discord protocol
Post by: Vulpix on 16 03 2017, 20:18:45
It's kinda akin to this:

https://github.com/miranda-ng/miranda-ng/issues/755

It just happens for some reason. Maybe Ghazan will look into it :)
Title: Re: Discord protocol
Post by: Targaff on 03 05 2017, 23:33:47
I'm not especially familiar with the protocol so I'm not sure whether this is feasible, but is there any possibility of being able to select which channels to show in a guild?  For example, I joined a guild/server that has 45 text channels set up, all of which are listed, but I'm only interested in maybe 5 of them.  I was thinking something along the lines of contact menu item for the server that lists the chat rooms and you can choose them from the list.  Alternatively, how about an option to specify a group for Discord chat rooms *other* than the one specified by the messaging plugin?  That would make it easier to clean things up.

No problems with the plugin otherwise, it's great!  Thanks.
Title: Re: Discord protocol
Post by: Ratha on 17 05 2018, 17:55:47
Is it possible to change/rename the default contact group and "chat rooms" folders to be nested within subfolders? If so whats the syntax for that? "Folder 1\Sub Folder\Actual Folder"?
Title: Re: Discord protocol
Post by: Ratha on 18 05 2018, 05:48:29
When I send or receive links using Miranda, it logs a whole bunch of extra embedded data for discord a few seconds after sending the message. Is it possible to stop the Discord plugin from displaying and or logging the embedded stuff? It really makes a mess of conversations when the extra info is larger than your original message. (Original message is 2 lines, embed adds an additional 6+ lines minimum and often significantly more text than the original post. Additionally instead of having just one link to click on in the history, theres the original plus the embed copy, plus a preview link too.)

Quote (selected)
11:11:34 PM Ratha I think to fix it showing you as online when you're not, you have to clear the sessions list here:
https://icq.com/session/list/en

11:11:37 PM Ratha
-----------------
Embed: https://icq.com/session/list/en
    link
   Download ICQ on your PC and start using high quality video chat, free messaging and free calls to any country
Preview: https://c.icq.com/images/tint/common/share/share_560.png

VersionInfo
Quote (selected)
CPU: Intel(R) Core(TM) i5-4670K CPU @ 3.40GHz [Intel64 Family 6 Model 60 Stepping 3] [DEP Enabled] [4 CPUs]
Installed RAM: 24521 MBytes
Microsoft Windows 7 Ultimate Edition, 64-bit Service Pack 1 (build 7601)
Internet Explorer: 9.11.9600.18665 (build 99600)
Administrator privileges: Yes
OS Languages: (UI | Locale (User/System)) : English/English | English/English
Free disk space on Miranda partition: 112835 MBytes

Miranda NG Version: 0.95.8 alpha build #19890 (5d651e838c) [running inside WOW64]
Build time: 26 Apr 2018 2:01:02
Profile: C:\Program Files (x86)\Miranda NG\Profiles\Ratha\Ratha.dat (MDBX database driver)
Profile size: 117440512 Bytes
Profile creation date: 29 Dec 2017 16:51:49
Language pack: No language pack installed
Service Mode: No

Active Plugins (18):
¤ AVS.dll v.0.98.1.1 [26 Apr 2018 2:01:06] - Avatar service
¤ CrashDumper.dll v.0.1.0.1 [26 Apr 2018 2:01:34] - Crash dumper
¤ DbEditorPP.dll v.4.0.1.2 [26 Apr 2018 2:01:34] - Database editor++
¤ Dbx_mdbx.dll v.0.95.8.7 [26 Apr 2018 2:02:26] - Miranda NG MDBX database driver
¤ Dbx_mmap.dll v.0.95.8.1 [26 Apr 2018 2:01:14] - Miranda NG mmap database driver
¤ Discord.dll v.0.5.1.2 [26 Apr 2018 2:02:26] - Discord protocol
¤ historypp.dll v.1.5.1.5 [18 Apr 2018 22:19:56] - History++
¤ ICQ.dll v.0.95.8.1 [26 Apr 2018 2:01:10] - IcqOscarJ protocol
¤ ImportTXT.dll v.0.0.1.12 [26 Apr 2018 2:02:46] - Import TXT
¤ PluginUpdater.dll v.0.1.2.5 [26 Apr 2018 2:01:40] - Plugin updater
¤ SeenPlugin.dll v.5.0.5.3 [26 Apr 2018 2:01:22] - Last seen
¤ SkypeWeb.dll v.0.12.2.5 [26 Apr 2018 2:02:20] - Skype protocol (Web)
¤ SpellChecker.dll v.0.2.6.6 [26 Apr 2018 2:02:02] - Spell checker
¤ StatusManager.dll v.1.1.0.4 [2 May 2018 2:01:46] - Status manager
¤ Steam.dll v.0.11.6.3 [26 Apr 2018 2:02:16] - Steam protocol
¤ TabSRMM.dll v.3.5.0.9 [26 Apr 2018 2:01:12] - TabSRMM
¤ Tipper.dll v.2.1.0.7 [26 Apr 2018 2:01:22] - Tipper
¤ YAMN.dll v.0.1.2.6 [26 Apr 2018 2:01:42] - Mail Notifier

Protocols and Accounts:
-------------------------------------------------------------------------------
Discord                  1 - Enabled 0 - Disabled  Loaded
ICQ                      1 - Enabled 1 - Disabled  Loaded
SKYPE                    1 - Enabled 0 - Disabled  Loaded
STEAM                    1 - Enabled 0 - Disabled  Loaded
MetaContacts             1 - Enabled 0 - Disabled  Not Loaded
YAMN                     1 - Enabled 0 - Disabled  Loaded

Icon Packs:
-------------------------------------------------------------------------------
 Flags_icons.dll [26 Apr 2018 2:02:42]
 HistoryPP_icons.dll [26 Apr 2018 2:02:44]
 Proto_Discord.dll [26 Apr 2018 2:02:44]
 Proto_ICQ.dll [26 Apr 2018 2:02:42]
 Proto_MetaContacts.dll [26 Apr 2018 2:02:44]
 Proto_Skype.dll [26 Apr 2018 2:02:44]
 Proto_Steam.dll [26 Apr 2018 2:02:44]
 Proto_Yahoo.dll [13 Feb 2016 22:01:38]
 Proto_YAMN.dll [26 Apr 2018 2:02:44]
 TabSRMM_icons.dll [26 Apr 2018 2:02:44]
 xStatus_ICQ.dll [26 Apr 2018 2:02:44]
Title: Re: Discord protocol
Post by: Vulpix on 18 05 2018, 09:35:52
The embeds arrive as message modifications; and for now message modifications are generally presented as a new message (though this could now change thanks to the new db format!). I don't particularly mind this happening; my current pet peeves with this method is that in case discord servers are too busy and you type another message before the modified message arrives, the modification is attributed to the person you are talking to. This is because due to how previous DB worked, we could only store one "last message ID" value in the database, and so if the last message was not the one the modification was for, it was incorrectly assumed to not be a message sent by me.

I like how miranda keeps the old message when a message modification occurs, so I see what changed; but I also agree in the case of media embeds and/or links, this is unnecessary. In this case the embed could simply merge nicely. I suppose if you're skilled in Ieview template creation, you could make it behave like discord, in which case the media "update" info modification could serve as a way to get the metadata + preview rendered, much like the discord web client does.

Anyway it is not necessarily a bug, but maybe a not-exactly-properly implemented feature. I suppose you could log a feature request and propose a way to deal with this - on Github :)
Title: Re: Discord protocol
Post by: truefriend-cz on 07 09 2018, 23:54:34
I find new problem.
If incoming message to group chat no open new container.

Czech:
Našel jsem problém.
Po přijetí zprávy do skupiny se neotevře kontejner v novém okně.
Title: Re: Discord protocol
Post by: thosrtanner on 09 02 2019, 19:11:51
I seem to have got into a very confused state. Under my discord I have two friends listed. A third sent me an invite which I accepted but they are not listed as a friend (though they are listed as such on the discord website).

I am also in a group chat with those 3 people and the chat IMs are coming up as if they were from one of member of the chat (so if the chat members are A, B, and C I get all the chat messages as if they were directly from A)
Title: Re: Discord protocol
Post by: johndoe on 20 02 2019, 20:04:59
I seem to have got into a very confused state. Under my discord I have two friends listed. A third sent me an invite which I accepted but they are not listed as a friend (though they are listed as such on the discord website).

I am also in a group chat with those 3 people and the chat IMs are coming up as if they were from one of member of the chat (so if the chat members are A, B, and C I get all the chat messages as if they were directly from A)

I find new problem.
If incoming message to group chat no open new container.

Czech:
Našel jsem problém.
Po přijetí zprávy do skupiny se neotevře kontejner v novém okně.

I also mentioned this in the support forum along with another small problem I was having and it was somewhat ignored so I logged in today to bump it again and saw your post; so this is a widespread issue // or a missing feature right ? not something on our end because it seems like last 3 posts in this topic are about the same issue.

https://forum.miranda-ng.org/index.php?topic=5726.0

Quote (selected)
edit1:also another problem I am having is one of my friends invited me to a private group chat ( not a channel ) just a group chat with some other friends
and ever since that day any message that is posted in the group chat comes as if it was a private msg from him ( even when its other people writing it )
and I can not message him directly either any msg I send to him via miranda goes to that group chat


edit4: well apparently it's on the bugtracker and they are working on it i never check github for changes
Title: Re: Discord protocol
Post by: snow on 25 02 2019, 11:03:43
I was wondering if there's a technical reason that group chats display user names with the discriminator (#1234)?

When using discord through a web browser, group chats there only display the plain user names, which I find looks a bit nicer.

As a quick test I removed the discrimator (when assigning wszNick in OnCommandGuildMemberUpdated and ParseGuildContents) and it appears to still work. Perhaps it could be an option?
Title: Re: Discord protocol
Post by: Vulpix on 25 02 2019, 17:49:21
There are many things wrong with the way group chats work - like how you can't easily @person, you can't send media to group chat etc. This part with the IDs could be an easy toggle option (show/not show). I like seeing both because I have some chats where a person is present with the same name but different ID.