-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable self messages #103
Enable self messages #103
Conversation
|
I tested this on channels, it allows messages sent by myself from another discord client to appear as self messages on IRC (https://wiki.bitlbee.org/SelfMessages) |
Nevermind the flag does do something, confused it with something else. It's not strictly correct to apply it to all messages, but I guess it doesn't hurt either. |
Yes, I noticed that, I'm trying to improve it now since I'm not actually sure it doesn't hurt having it unconditionally. I'd also like it to work with private messages! |
The patch I had for this was a bit more complicated. The problem I had with this is described in #7: this results in echoed messages when sending from bitlbee which I see as the main usecase. |
I see what this is trying to do but it seems to have a race conditon between the HTTP post response and the echo from the gateway (in the debug log, the gateway echo appears first). I see there is a Perhaps we could do even simpler, setting the nonce to a fixed value per connection so we can ignore all self messages that we generated ourselves without having to keep track of them. |
Yeah, that was written a while ago, things probably have changed.
Oh so they did add something we can use for this, nice. Haven't looked at discord's API in a while. I think that at this point we don't even need the nonce string to be unique per-session, it can just be hardcoded as "bitblee" or something like that. It could be later changed to random ids if it is decided to use this field for it's original purpose. |
Messages sent from another discord client will now appear as if you sent them from Bitlbee. See https://wiki.bitlbee.org/SelfMessages for more information about this feature.
7ff11b0
to
0271566
Compare
PR updated with some inspiration from @sm00th's patch
Edit: actually, this was my mistake, it seems to work flawlessly now ! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than that one comment I am pretty happy with this code.
src/discord-handlers.c
Outdated
@@ -494,8 +509,8 @@ static gboolean discord_prepare_message(struct im_connection *ic, | |||
} | |||
|
|||
if (cinfo->type == CHANNEL_PRIVATE) { | |||
if (g_strcmp0(author, cinfo->to.handle.name) == 0) { | |||
posted = discord_post_message(cinfo, cinfo->to.handle.name, msg); | |||
if (is_self || g_strcmp0(author, cinfo->to.handle.name) == 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this check is not needed anymore. It is originally here to mute selfmessages, but now one of the conditions will always be true (unless I'm missing something) so we can just drop it and always call discord_post_message()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. I fixed this, let me know if you'd rather have my squash my commits
Messages sent from another discord client will now appear as if you sent
them from Bitlbee.
See https://wiki.bitlbee.org/SelfMessages for more information about
this feature.