Replace newlines with a space instead of just removing it, since most of the
text pasted doesn't have trailing spaces and it looks weird after removing
newlines.
Instead of logging in every time cache auth token and try to reuse it on login,
falling back to normal authentication only if this fails. Discord sometimes
drops connection and with MFA enabled it is quite annoying to relogin every
time.
Add GUILD_INTEGRATIONS_UPDATE and GUILD_EMOJIS_UPDATE to ignored events list as
those seem to be quite frequent and useless for beecord at the same time.
BitlBee's random_bytes() function uses /dev/urandom instead of glib's
mersenne twister, and while the websocket mask isn't really meant for
actual security, this also helps because random_bytes() has a more
convenient interface, working on char arrays.
The signature of discord_ws_mask() had to be changed to take a 4 byte
char array instead of a guint32, but that also removes an awkward cast.
Discord-bitlbee wouldn't properly logout when received websocket close packet,
but instead would just stop updating leaving the account in a "hung" state.
There is a case when bitlbee-discord could receive websocket disconnect packet
before keepalive_loop is started, so we should check if it was started before
trying to remove it.
This commit introduces own simple libwebsockets implementation removing
libwebsockets dependency. While this can introduce new bugs they should be
easier to hunt down. libwebsockets dependency proved to be very hard to
maintain due to library being in active development and not widely available.
Previously bitlbee-discord would not add a user to server userlist if a user
with this name is already added to current bitlbee account. This patch fixes
this and makes sure we also won't delete a user from bitlbee unless he quits
all "servers" we are in.
Discord now encodes '/me' messages as '_msg_' instead of '*msg*'. Both still
just italize the whole string, so this commit changes the outgoing translation
to '_' and incoming msg '/me' detection now works for both '*' and '_'.
When set to 'opportunistic' mode, otr suffixes messages with a bunch of spaces
and tabs, JSON does not allow tabs/line feeds/carriage returns within any
tokens, so we need to encode tabs as \t.
Leaving cariage returns and line feeds as is for now in dumb hope that noone
will ever use those(you wish).
/me command in discord's web client just italizes the whole string by
prefixing/suffixing it with *, we are now mimicking this behavior when sending
messages and do reverse when receiving them.
Code that handled channel removal freed channel data, but didn't actually
removed it from the internal channel lists causing all sorts of trouble. This
commit fixes the issue.
Escape backslashes when sending messages. Fun fact: discord actually eats
backslashes in front of nonalphanumeric characters, so you can't send \?
without manually escaping it (i.e. typing \\?).
Some of the nicks have casing that is a pain to type without
tabcompletion(can happen when user is offline), this commits adds a
"mention_ignorecase" option that can be enabled to ignore case when looking for
mentions.
When sending private messages to a person you never spoke before from
bitlbee-discord bitlbee would previously silently fail because it couldn't find
a "channel" to send message to. We now create a new private channel if needed
before sending a message.
Previously creation of private channels was handled only on connect, basically
ignoring CHANNEL_CREATE events for private channels. Moved all of the private
channel manipulation code to discord_handle_channel() where it actually
belongs.
Another, related issue, was a NULL dereference when trying to fetch
last_message_id for completely new channel that have this set to NULL.