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:

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:

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.)

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
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

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.
Title: Re: Discord protocol
Post by: Ratha on 14 07 2019, 08:44:45
Im running an old build of Miranda 0.95.11 #21135, and ran a test earlier where i asked a friend to delete me from his contact list. When he removed me as a friend, it also removed him from my Miranda contact list, deleted all of our chat history, and removed all of my custom user notes that i had stored with TabSRMM. He re-added me after a few minutes and none of the missing chat history or notes were restored. I was also unable to find an option to re-import chat history stored on Discord.

Questions:
1: Was this automatically-deleted data also purged from the database, or is it still stored and now orphaned in there somewhere increasing database size / bloat?

2: Shouldnt the contact, any custom TabSRMM notes for them, and the history be stored locally by history++ in the Miranda database and thus not susceptible to remote deletion? There is an argument to be made that if a user has deleted you that you shouldnt have access to their chat anymore, however all of the things that you have written to them are also deleted as well. This makes using the Discord protocol in Miranda for storing important data, very unreliable.

3: Has the Discord plugin been updated in the last year in a way that would change this behavior? (It seems like we shouldnt lose the contact from our list, along with all custom notes, and all of the message history. (And without any kind of warning that a user has removed you, you might not even know who or what you lost or have any ability to save / restore that data from a backup.)
Title: Re: Discord protocol
Post by: Vulpix on 14 07 2019, 10:50:34
Unfortunately the answer to all of the above is that all of your contact data was lost.

https://github.com/miranda-ng/miranda-ng/issues/812 I logged this a long time ago because of the really unreasonable implementation in regard to my personal user data...

It's basically what you're talking about.

The "workaround" I use until 812 is implemented is - I have backups of my profile file every hour, and when I'm doing weekly backups, I notice there is a missing contact (because I do msgexport all -> compare to last week), and then I go back to when the contact disappeared, launch miranda in offline mode with that profile -> export all of my data -> go back to normal miranda -> create a dummy contact -> import all of the history and other data.

Terrible, but as you can see 812 has been logged a long time ago with no progress hehe.

Oh, there is an option to load server history by the way (at least in newer discord), by right-clicking the contact and doing "Load server history".
Title: Re: Discord protocol
Post by: Ratha on 14 07 2019, 11:55:14
This was something that I noticed a long time ago, but didnt intend on using discord enough for it to meaningfully matter at the time. Now that i use it more often its become a bit of a concern. I appreciate the heads up though and the info about being able to load server history. I want to say that it used to be an option, but perhaps it was disabled in my older build. (Constantly updating introduces various problems I've noticed, so once i find a good build of a program i stick with it until an update i need comes along usually.)

I have a few days worth of backups for the purpose of reloading if i should notice something has happened, but probably wouldnt notice some people removing me and thus would probably lose all that history before manually backing it up to cold storage. You say you use 'msgexport all' and compare to the prior week to check for missing contacts, is that a command line option for Miranda, a plugin, or some other program?

I would be interested in learning more about that method you're using, although my profile is pretty large at this point at around 135 megs, 200 contacts, and somewhere between 500k and a million messages stored. Not to mention a handful of often-hidden groups of people i dont talk to frequently. Im not sure if it would be feasible to do a comparison of contacts/messages frequently enough to proactively prevent loss of data. Though it does make me realize that i should probably increase the number of stored auto-backups, plus create manual ones on a much more frequent timetable.
Title: Re: Discord protocol
Post by: Vulpix on 14 07 2019, 14:27:28
I will write up my own "best practices for hazardous materials handling" aka miranda :D When I'm a bit less busy (currently crunch time on a crazy project so I'm pulling personal overtime even during the weekend)

My profile is currently 472 MB, which is 4 247 942 messages according to the HistoryStats plugin. The method I use makes it manageable and doesn't take longer than a few minutes every week (of course takes longer if you detect an issue this way, but even so that makes it manageable since a part of it is having backups).

The gist of it is, there is a plugin called MsgExport which exports any message of any contact into a file (the format is the json format that import plugin knows how to import).

The plugin has a button that lets you export all histories for all users in your db (and it also merges users based on their nick, or manual preferences).

That way you can easily tell if someone removed you, i.e. the filename will be gone, or the file contents will be vastly different compared to that of last week (which is a full export kept for reference). For this comparison I use synchronize mode of Total Commander in "ignore dates / compare by contents" mode. There is a bash script that is necessary first due to some flags, but this method will also discover database corruption and allow you to recover it (for example partial db corruption), which for example just db backups alone will not.

It is the only reason I've not lost any user data during these turbulent times.

I'll write it up in more detail but I think this will do for a rough overview.

My miranda is my life, and the data in it is precious.
Title: Re: Discord protocol
Post by: yo1999 on 20 09 2019, 15:57:05
I'm sorry if i'l seem stupid, but how do i login into discord with miranda. I look at at the available protocols and don't see it.
Title: Re: Discord protocol
Post by: Vulpix on 21 09 2019, 00:29:03
You need to download the protocol first - either via plugin/module downloader through miranda, or from the website. Then you should see it in the available protocols.
Title: Re: Discord protocol
Post by: Andys on 23 10 2019, 11:10:02
Is there a way to move or copy channel contact to other groups?
I want to keep few channels in immediate reach (root of contact list) and the big tree branch with other channels collapsed.

Unfortunately if I move channel contact it is moved back as soon as I go offline and back online.
Title: Re: Discord protocol
Post by: Vulpix on 23 10 2019, 11:17:30
That is strange. I have this set up myself - I have a group "DiscordChats" and then another group "ChatRooms". All of the discord chats initially land in chatrooms, from where I move the important/intersting ones to "DiscordChats" group. This setting persists through restart of miranda and relogin. Maybe the problem is with them having no group?
Title: Re: Discord protocol
Post by: Andys on 23 10 2019, 11:34:23
That is strange. I have this set up myself - I have a group "DiscordChats" and then another group "ChatRooms". All of the discord chats initially land in chatrooms, from where I move the important/intersting ones to "DiscordChats" group. This setting persists through restart of miranda and relogin. Maybe the problem is with them having no group?
Thanks! I found my mistake - when setting up the account I enabled 'use subgroups for channels', so it was resorting them each time the list was loaded from discord
Title: Re: Discord protocol
Post by: Andys on 30 10 2019, 13:24:49
Kind of DIY post.
What I wanted to do: get instant notification when something new was posted in few discord channels I regularly watch for game news from devs. Without installing any extra apps on my PC, just wanted to have it all in Miranda.

One problem I encountered on the way is that you cannot enable tray icon showing up for new messages in a single group chat (discord channel). You can only enable or disable them for all of them so if your main discord account joined a few servers you get a tray icon notification for any new message in any of their channels. Not mentioning that all these channels would flood your Group Chats group in contact list.

So the steps to make it possible:
1. create a new server using your main discord account and make a single text channel (may use #general)
2. create a 'bot' account on discord
3. invite this account to your server, join it, check that you see the text channel in it
4. in miranda set up discord account with this bot login and password
5. test it - login to discord with your main account and post something in your channel, check that miranda got this message and everything is working
6. enable tray icon for new messages in group chats (Options - Message sessions - Group chats - Icons to display in tray - messages
7. add channels you want to get notifications for by going to discord with your main account, and following the channel you like (link to your empty server and text channel)

Voila, it works now:
- my contact list isn't overflowing with thousands of channels from my primary discord account
- I get notified by tray icon every time someone posts to one of my followed channels
- I can easily add or remove channels to/from watch list while  using discord with my main account, no need to re-login as bot account

Of course if you use other group chats beside Discord this won't work for you (you don't want a tray icon every time someone posts some nonsense in one of them)
And darn, the follow option is only available for announcement channels, WTF with that...
Title: Re: Discord protocol
Post by: Thug on 23 02 2020, 10:18:47
Sometimes Miranda continuously fails to connect to Discord server, and somehow logging in on the website fixes this problem. I have made a netlog.
Title: Re: Discord protocol
Post by: ghazan on 23 02 2020, 19:46:29
Sometimes Miranda continuously fails to connect to Discord server, and somehow logging in on the website fixes this problem. I have made a netlog.
That's evident -
{"captcha_key": ["captcha-required"]}
Title: Re: Discord protocol
Post by: Thug on 24 02 2020, 00:52:48
ghazan, server glitch?
Title: Re: Discord protocol
Post by: ghazan on 24 02 2020, 09:29:46
Thug,
I wouldn't call that "a glitch", if server suspects that you're a bot, it verifies your connection using a captcha, so you need to enter a browser
Title: Re: Discord protocol
Post by: dartraiden on 25 02 2020, 18:38:02
Miranda does not support captcha and now redirects the user to the browser
https://github.com/miranda-ng/miranda-ng/commit/89dfd2db2ba84f1d2f6bb35a43256fc8183cb9b0
Title: Re: Discord protocol
Post by: phatmr on 15 07 2020, 21:57:55
Hello,

something happened to discord protocol last days?

Since 3 days i cant connect to discord via miranda anymore.
It seems to connect and disconnect a second later.
Thats what i found in discord log of miranda ng:

[23:37:16 04B0] [Discord_1.Gateway] (017671B8:1276) Data received
HTTP/1.1 404 Not Found
[23:37:16 04B0] [Discord_1.Gateway] Error establishing WebSocket connection to gateway.discord.gg/?encoding=json&v=6, status 404
[23:37:16 04B0] [Discord_1] Gateway connection failed, exiting

I'm using the actual 32bit dev build of miranda ng with discord 0.6.2.5 plugin.

If i connect via browser on official site it works.

Please someone could help in that?

regards
phatmr
Title: Re: Discord protocol
Post by: ghazan on 16 07 2020, 09:17:11
phatmr,
error 404 means that either your query was forged/denied by a proxy or you have DNS problems.
please check that gateway.discord.gg resolves to

Name:    gateway.discord.gg
Addresses:  162.159.130.234
          162.159.134.234
          162.159.133.234
          162.159.136.234
          162.159.135.234
Title: Re: Discord protocol
Post by: phatmr on 16 07 2020, 23:02:43
Hi ghazan,

Thank you for your answer.
I checked it.
gateway.discord.gg is resolved to IP 162.159.134.234
So it shouldn't be the DNS.
I haven't used a proxy for a long time.
Nothing has changed in my network setup.
Do you need more information or certain logs?

Greetings phatmr
Title: Re: Discord protocol
Post by: ghazan on 17 07 2020, 11:27:28
phatmr,
Do you need more information or certain logs?
yes, send me the full log (core + Discord) as a private message, please, it shall not be long
Title: Re: Discord protocol
Post by: phatmr on 17 07 2020, 22:19:55
PM sent.
Title: Re: Discord protocol
Post by: ghazan on 20 07 2020, 17:17:55
phatmr,
could you try to turn on group chats in Discord?
Title: Re: Discord protocol
Post by: phatmr on 21 07 2020, 09:00:11
Hi ghazan,

i tryed that. Same error ocured.

New PM sent ;)
Title: Re: Discord protocol
Post by: thosrtanner on 23 07 2020, 15:55:58
I get this too. It's intermittent. It worked for a bit this morning and then stopped working again later.
Title: Re: Discord protocol
Post by: TioDrakul on 23 07 2020, 22:57:07
Same here. You try to connect, the connection is made and then immediately afterwards the status goes back to offline. Sometimes you can stay online for a few minutes but then go offline again. I would venture to say that it may be some functionality of the Discord server that is testing whether the client is the official and when it does not receive the expected response then it disconnects immediately.
Title: Re: Discord protocol
Post by: ghazan on 25 07 2020, 18:33:45
Gentlemen,

I've made a nightly build with a small fix, it cured at least one user from problem 404.
Could you update & try? Any info is appreciated.
Title: Re: Discord protocol
Post by: TioDrakul on 27 07 2020, 12:16:42
I downloaded the nightly build today and looked more closely at the log (in normal operation I leave it off), and it seems that the error 404 problem is still here. Attached is the log section where the connection attempt occurs and the error that happens next
Title: Re: Discord protocol
Post by: ghazan on 27 07 2020, 13:37:32
TioDrakul,
could you try to lock gateway.discord.gg to 162.159.133.234 instead of 162.159.134.234 in /etc/hosts?
I seriously suspect that 162.159.134.234 is the root of our troubles
Title: Re: Discord protocol
Post by: TioDrakul on 27 07 2020, 13:50:23
Okay, i changed my hosts file to force the ip you suggested and Miranda then used that ip, but the problem persists (the same 404 error). It seems to me that the problem is something that happens after the initial connection was successful.
Title: Re: Discord protocol
Post by: ghazan on 27 07 2020, 15:13:13
TioDrakul,
thanks. my hypothesis was that one of the servers fails
now we know that it's not true ???
Title: Re: Discord protocol
Post by: phatmr on 28 07 2020, 08:05:22
Hi ghazan,

as TioDrakul said, the same error happens with the last nightly build.
As a precaution, I will send you a current log as a PM.
Maybe Discord now has changed the authentication check? (no rechapter needed on website)

regards
Title: Re: Discord protocol
Post by: ghazan on 28 07 2020, 09:48:56
TioDrakul, phatmr,
so the only question now is: does the stable version work or not for you? has it the same problem?
Title: Re: Discord protocol
Post by: phatmr on 29 07 2020, 10:41:24
Hi ghazan,

i have tested it.
The actual stable 32bit version has the same problem.
Title: Re: Discord protocol
Post by: ghazan on 29 07 2020, 10:47:59
phatmr,
excellent, thanks.
so I can make new stable regardless of this problem :) no degradation is present
Title: Re: Discord protocol
Post by: thosrtanner on 08 08 2020, 06:47:44
Still randomly working/not working.

Getting a 404 when connecting to  gateway.discord.gg

Interestingly relogging in multiple times didn't work, but when I restarted miranda I logged in fine.
Title: Re: Discord protocol
Post by: ultramage on 25 09 2020, 11:54:24
Hi, I have some feedback on the current version, after trying it out for a bit. I wouldn't mind helping to test things further since the official discord clients are too cpu/ram intensive to run.

The module on startup seems to download a portion of the messages in every chatroom on every server, as fast as cloudflare's throttling will permit. This can take 1 minute or more. I think that's a huge red flag and should not be done. Or at least, I assume the official client doesn't do this, and just gets a quick overview of which rooms/servers to highlight.

When I change messaging options and hit apply, I believe all chat windows are emptied and the module proceeds to re-download everything from scratch. Might not be ideal.

If the protocol loses connection, the list of chatroom users is emptied. When it then reconnects, the list does not come back until the tab is closed and re-opened.

I assume I'm supposed to use the Ignore functionality to prune out chatrooms that I'm not interested in seeing.

Everything appears as a group tree under a top-level Discord node. However, 'Chat rooms' also gets filled with the individual servers. I assume this is due to a limitation of the UI and is there to allow joining/leaving servers. Might be more convenient to have it all under the Discord node.

The protocol uses odd terminology, 'Join Guild' and 'Leave Guild'. Took me a moment to realize what this was. Discord calls them 'servers', unless I'm mistaken. Might be better to use the official naming?

When viewing chatrooms as tabbed group chats (tabsrmm I think?), if I try to rearrange them, the tabs do not respond to the drag&drop gesture. I also don't see any way to reorder them, there's only "save tab position", which I assume allows irssi-style binding.

If I accidentally doubleclick on a tab while switching chatrooms, the gesture is interpreted as a 'close tab' command. I really don't want this. I looked really hard, but couldn't find any option that could disable this behavior.

When I doubleclicked on a person to quote them, it prepared a classic irc-style highlight (user: ) instead of discord-style (@user). I sent a message like that just for the heck of it, and saw that my message echoed back as "user: : text". The double colon worries me. I have not tried using a second client to view how others saw my message, but I assume it didn't come out right.

One possible improvement to make the chat look closer to how Discord looks would be to apply color-coding based on serverside role configuration, and showing display names instead of the internal names in the chat.

The github ticket for discord mentions that message editing is implemented (followed by a question mark). How is it done?

Is there a way to affect scrollback? Discord allows scrolling up to load more chat history from the server.
Title: Re: Discord protocol
Post by: dartraiden on 25 09 2020, 21:24:43
The github ticket for discord mentions that message editing is implemented (followed by a question mark). How is it done?
Miranda can receive edited messages.

No one chat log plugin (embedded logs, IEView, H++) cannot edit messages, but this is not protocol problem.
Title: Re: Discord protocol
Post by: ultramage on 26 09 2020, 08:33:43
Another oddity: when I open a discord chatroom, clear log and then right-click on the room and do 'Load server history', and I use the setting "Message session -> Message log -> Load history events -> Load number of previous events: 100", it loads the first (oldest) 100 events in the chatroom's history. If it's supposed to that, that sort of feature has very limited utility.

Also, it doesn't seem like I can refresh the chatroom contents once I 'clear log'. Even closing the tab and re-opening it doesn't help, the chat is empty.

Message deletion is not indicated in the chat log.

Highlighting/mentioning a person really doesn't work right:
"User#id: text" comes out as "User : text", correctly highlighted and parsed, but there's a stray colon there.
"User#id text" comes out as "User#id text", not highlighted or parsed.
"@User#id text" comes out as "@User#id text", not highlighted or parsed.
Title: Re: Discord protocol
Post by: ultramage on 28 09 2020, 06:26:18
Following up on that "Load number of previous events: 100" thing, in addition to not being able to manually load a room's history properly: when my network disconnects and I re-join discord, room content is not updated with the messages I missed while I was offline - neither for already open tabs nor for new rooms.

Should I start submitting all these observations as individual github tickets? Some of these are quite major and interfere with even basic usage.
Title: Re: Discord protocol
Post by: ghazan on 28 09 2020, 08:17:22
ultramage,
in addition to not being able to manually load a room's history properly
yes, in Miranda group chats do not store the history in a database, so you can't manage histories properly
Title: Re: Discord protocol
Post by: dartraiden on 28 09 2020, 15:38:56
The protocol uses odd terminology, 'Join Guild' and 'Leave Guild'. Took me a moment to realize what this was. Discord calls them 'servers', unless I'm mistaken. Might be better to use the official naming?
@ghazan hates "servers" :D

Everything appears as a group tree under a top-level Discord node. However, 'Chat rooms' also gets filled with the individual servers. I assume this is due to a limitation of the UI and is there to allow joining/leaving servers. Might be more convenient to have it all under the Discord node.
This is standard Miranda behavior, IRC protocol do the same.

When I change messaging options and hit apply, I believe all chat windows are emptied and the module proceeds to re-download everything from scratch. Might not be ideal.
Not possible until we implement database chat history storing.

If the protocol loses connection, the list of chatroom users is emptied. When it then reconnects, the list does not come back until the tab is closed and re-opened.
Ticket created
https://github.com/miranda-ng/miranda-ng/issues/2577

When viewing chatrooms as tabbed group chats (tabsrmm I think?), if I try to rearrange them, the tabs do not respond to the drag&drop gesture. I also don't see any way to reorder them, there's only "save tab position", which I assume allows irssi-style binding.
All message plugins (StdMsg, TabSRMM, Scriver) supports tabbed interface, look at your Version Info
Not a Discord problem.

If I accidentally doubleclick on a tab while switching chatrooms, the gesture is interpreted as a 'close tab' command. I really don't want this. I looked really hard, but couldn't find any option that could disable this behavior.
Also not a Discord problem. You should tweak message plugin setting.

When I doubleclicked on a person to quote them, it prepared a classic irc-style highlight (user: ) instead of discord-style (@user). I sent a message like that just for the heck of it, and saw that my message echoed back as "user: : text". The double colon worries me. I have not tried using a second client to view how others saw my message, but I assume it didn't come out right.
Message plugins cannot use different types of quotes for different protocols
See our wiki for Discord user mentioning
https://wiki.miranda-ng.org/index.php?title=Plugin:Discord/en

Another oddity: when I open a discord chatroom, clear log and then right-click on the room and do 'Load server history', and I use the setting "Message session -> Message log -> Load history events -> Load number of previous events: 100", it loads the first (oldest) 100 events in the chatroom's history. If it's supposed to that, that sort of feature has very limited utility.
This has not been intended for group chats, only for privates

Message deletion is not indicated in the chat log.
https://github.com/miranda-ng/miranda-ng/issues/2578


everything else has almost no chance of being realized
Title: Re: Discord protocol
Post by: dartraiden on 28 09 2020, 15:53:47
Should I start submitting all these observations as individual github tickets?
Yes, because otherwise I have to do it :D
Title: Re: Discord protocol
Post by: ultramage on 27 10 2020, 03:44:30
I am noticing that a bunch of chatrooms across all the Discord servers I'm on are locally renamed, prefixed with the server's name. So instead of #room, it's Server#room. On one server, almost every room is affected. On another, it's only one or two. And I believe this happens over time, maybe when on a bad network with frequent reconnects? I first noticed this on 4.10. when one of my always-open tabs suddenly had its title changed like that.
Title: Re: Discord protocol
Post by: ghazan on 27 10 2020, 15:44:28
ultramage,
It depends on an option "Use subgroups for server's channels". If this option is disabled, Miranda has to append the server's name to a channels to avoid dups
Title: Re: Discord protocol
Post by: ultramage on 27 10 2020, 23:23:59
The setting is enabled, and always was.
For one server, almost every room (but not all of them) is prefixed like this, even though the names are definitely unique to this server. Also, I just restarted Miranda and everything looks correct again (I'll try to keep an eye out for how long it'll last). I suspect a disconnect/reconnect glitch caused these rooms to conflict with themselves, or something.
Title: Re: Discord protocol
Post by: ghazan on 28 10 2020, 10:54:28
ultramage,
dunno, as for me, my group chats were never prefixed, according to that option
(https://i.imgur.com/K7KQMGy.png)
Title: Re: Discord protocol
Post by: ultramage on 28 10 2020, 16:16:55
Mine returned back to normal after restarting Miranda as well. That's why I think it's some sort of bug that manifests after some uptime and/or connection dropouts. I'm keeping an eye out for it, but it might take some time.
Title: Re: Discord protocol
Post by: ultramage on 15 11 2020, 09:23:00
I saw it happen again. It was on a newly created server, which overnight added muliple new rooms and room groups. I checked everything else, and the other servers seem to be fine. So based on this single data point, my first guess is that when the server admin makes any change to their layout, it makes the discord plugin malfunction somehow. Just a guess though. The servers I'm on already have a stupid amount of rooms and I don't pay attention to the structure, so it's hard to spot these changes as they happen.
Title: Re: Discord protocol
Post by: yo1999 on 28 02 2021, 15:18:12
I still have problem with Discord pluggin unable to stay online for more than a second. Is there any so;ution on the horizon?
P.S. how do i view logs?
Title: Re: Discord protocol
Post by: ghazan on 28 02 2021, 15:19:54
yo1999,
it was fixed last night in the development build, at least it happens now not so often
Title: Re: Discord protocol
Post by: dartraiden on 28 02 2021, 16:37:41
how do i view logs?
netlog (https://wiki.miranda-ng.org/index.php?title=Network_log)
Title: Re: Discord protocol
Post by: SpinalBlood on 01 05 2021, 19:08:02
Is it possible to have an option to have an account with only the contacts for private messaging, and completely ignoring the channels/guilds/servers?
Title: Re: Discord protocol
Post by: ghazan on 02 05 2021, 14:09:44
SpinalBlood,
yes, just disable group chats in Options
Title: Re: Discord protocol
Post by: SpinalBlood on 03 05 2021, 19:44:43
I tried disabling it before the very first login, but the channels are still created:

(https://abload.de/thumb/643ae0ecbaqhj59.png) (https://abload.de/image.php?img=643ae0ecbaqhj59.png)

I would like something like having only the private message contacts / private channels (so in the pic it would be no chat rooms and no subchannels other than the "discord 6/32" section), if possible

Also: like skype, a single history seems locked at 100 messages, at the moment
Title: Re: Discord protocol
Post by: ghazan on 04 05 2021, 13:54:01
SpinalBlood,
to do that we need to rename the "Disable group chats" option to "Disable guilds" and stop processing guilds at all.
I mean, that the behavior of existing option should be changed
Title: Re: Discord protocol
Post by: SpinalBlood on 04 05 2021, 18:09:43
Not sure if other users wants the status quo with the current option, it can be discussed in this topic I guess

But it shouldn't change too much if it's still possible to recreate a new discord account with the option enabled by default, and never disabling it. The channels will be recreated, it's not like we are able to do many edits with them to begin with (unless I'm wrong, please post otherwise :) )