Commit Graph

275 Commits

Author SHA1 Message Date
Artem Savkov bc580b915d Update chat_list_finish function name.
Bitlbee renamed bee_chat_list_finish() to imcb_chat_list_finish() for
consistency, updating the code accordingly.
2016-10-16 10:18:54 +02:00
Artem Savkov 4630b40752 Play backlog on channel join.
Play backlog when user actually joins a channel, not on connect.
2016-10-05 14:02:33 +02:00
Artem Savkov 9238062d82 List chats functionality.
Do not autojoin every channel that is advertised. Instead use "chat list"
command to add/join them one by one.
2016-10-05 14:02:33 +02:00
Artem Savkov f6d5ef72b5 Fix message acknowledgements.
Message acks now required to be valid application/json even if blank.
2016-10-05 13:52:34 +02:00
Artem Savkov c4f3426a3d Replace newlines with a space.
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.
2016-08-18 16:09:06 +02:00
Artem Savkov 2d27e5eddc Strip out newlines in discord_escape_string.
Strip out \r and \n characters in discord_escape_string as those break json.
2016-08-16 12:49:56 +02:00
Artem Savkov c03eb5e02b Fix canonized username memleak on user deletion.
When user to delete couldn't be found canonized username is was never freed.
2016-08-16 12:48:12 +02:00
Artem Savkov fe52515595 Merge pull request #41 from seschwar/master
Use HTTPS instead of HTTP
2016-08-08 10:20:55 +02:00
Artem Savkov 899b048e86 Cache auth token.
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.
2016-08-08 09:42:59 +02:00
Sebastian Schwarz 91445f674d Use HTTPS
- no plaintext login credentials sent
- no extra round trip, as discordapp.com redirects to HTTPS anyways
- avoids unexpected 411 error after redirect
2016-08-07 14:58:40 +02:00
Artem Savkov d7fb6b141c Update ignored events list.
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.
2016-08-03 16:50:32 +02:00
Artem Savkov d085abfe6c Escape passwords on login.
Passwords were not escaped so a password containing '"' would result in
incorrect json.
2016-08-01 09:55:05 +02:00
Artem Savkov 7fdfd18221 Fix login error reporing.
Discord changed the data it returns on failed login, so that bitlbee-discord
couldn't parse it and just hang till timeout.
2016-08-01 09:52:36 +02:00
Artem Savkov 4697fef8e9 Two-factor authentication support.
Add support for TOTP two-factor authentication as done by webclient.
2016-07-28 10:40:58 +02:00
Artem Savkov 34d1c85709 Merge pull request #37 from dequis/websocket-fixes
Couple of minor fixes in discord-websockets
2016-06-19 09:16:06 +02:00
dequis 14ad64eb70 websockets: use random_bytes() and char arrays instead of guint32
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.
2016-06-18 14:04:57 -03:00
dequis c3951f1ccd websockets: Allocate len + 1 to leave a null terminator if needed
Unlikely to be an issue in practice, but who knows.
2016-06-18 13:47:58 -03:00
Artem Savkov 0e1fb79c71 Merge pull request #33 from digitalcircuit/fix-plugininfo
Fix minor typos in plugin info, README
2016-05-28 10:13:36 +02:00
Shane Synan 857b519f72 Fix typos in plugin info, README
In discord.c plugin info, 'bitlbee-discrod' -> 'bitlbee-discord'.

In README, fix a few minor typos.
2016-05-28 03:00:32 -04:00
Artem Savkov 418a7c78c8 Add server_prefix_len option.
Add an option to control server prefixes for channels.
2016-05-26 17:36:57 +02:00
Artem Savkov aa7bd22c24 Add plugin info.
Bitlbee now has a way to import plugin info and track ABI version of plugins,
adding the required data. For more info see: https://github.com/bitlbee/bitlbee/pull/76
2016-05-26 09:34:49 +02:00
Artem Savkov a35d7bbf25 Properly logout when receiving ws close.
Discord-bitlbee wouldn't properly logout when received websocket close packet,
but instead would just stop updating leaving the account in a "hung" state.
2016-05-18 09:41:39 +02:00
Artem Savkov 0e43e67029 Fix keepalive loop removal bug.
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.
2016-05-12 15:40:34 +02:00
Artem Savkov d00ef51efa Switch to own websocket implementation.
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.
2016-05-12 10:54:21 +02:00
Artem Savkov dd7b8621b2 Merge pull request #32 from mumixam/master
fix for error when displaying username of a renamed user
2016-05-06 08:37:02 +02:00
mumixam df3cda4fee fix for error when display username of a renamed user 2016-05-05 19:06:03 -05:00
Artem Savkov 56aea37e6b Add "never_offline" option.
Add an option to mark contacts as "away" instead of "offline". See issue #29 on
github for context.
2016-05-05 14:39:29 +02:00
Artem Savkov c71bc109e5 "Multiserver" user support.
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.
2016-04-26 19:06:23 +02:00
Artem Savkov bae729a009 Escape away strings as well.
Previously only outgoing messages were escaped, leaving characters like '"'
unusable in away messages.
2016-04-18 18:35:48 +02:00
Artem Savkov 0fc96b6a0a Do /me translations in private message as well.
Move the code doing /me translations to the common part that affects both
private and channel messages.
2016-04-11 08:51:55 +02:00
Artem Savkov f9b0ec3566 Add support for away state/status messages.
Add support for setting away state along with away message and status messages
(help set status).
2016-04-10 22:50:36 +02:00
Artem Savkov 710d3f90e7 Switch /me translation characters from '*' to '_'.
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 '_'.
2016-04-10 20:34:40 +02:00
Artem Savkov bd1fcd0065 Translate tab to \t in sent massages.
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).
2016-04-10 20:05:22 +02:00
Artem Savkov 83167e3183 Set gateway path to "/" in case it is NULL.
libwebsockets doesn't seem to enjoy it when you provide null path argument, so
set it to "/" in case there is none.
2016-04-06 13:18:39 +02:00
Artem Savkov cc03532b02 Use port 80 for nonssl websocket connections.
Previously we always used port 443 for websocket connections. That worked
because discord always uses wss.
2016-03-17 12:19:33 +01:00
Artem Savkov ce161bda89 Disable keepalive loop on ws_cleanup.
Before this patch there was a possibility of keepalive handler being called
after discrod_data has been freed resulting in a segfault.
2016-02-09 22:15:13 +01:00
Artem Savkov a1a4a530c3 Add incoming_me_translation option.
Add an option to control whether bitlbee-discord will do incoming /me message
translation or not.
2016-01-18 15:50:21 +01:00
Artem Savkov 6d881c97df Add /me translations.
/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.
2016-01-17 12:29:12 +01:00
Artem Savkov 2618d456c0 Fix channel removal.
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.
2016-01-17 11:42:29 +01:00
Artem Savkov 4f49418f24 Add support for attachments.
Traverse attachments array in msg structure and print urls for each of them.
2016-01-15 20:47:38 +01:00
Artem Savkov af442af9b8 Add support for outgoing #channel links.
Works the same way as @nick mentions, and is affected by mention_ignorecase
option.
2016-01-15 20:23:39 +01:00
Artem Savkov e4b4adb5c8 Handle @name mentions even if mention_suffix is disabled.
These are native to discord and should be expected to work regardles of user
settings.
2016-01-15 19:15:36 +01:00
Artem Savkov 3a8e091138 Properly handle incoming #channel links.
Translate #channel links from discord's <#id> format to human-readable
 #servername/channelname format.
2016-01-15 17:53:31 +01:00
Artem Savkov 7bfbbf8132 Simplify special chars escape code.
We don't need all this craziness with position and counting number of matches,
just always append to result.
2016-01-15 17:02:00 +01:00
Artem Savkov b81d94ec1b Escape backslashes.
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 \\?).
2016-01-15 16:46:30 +01:00
Artem Savkov 9f9951c20a Add an option to ignore case when matching outgoing mentions.
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.
2016-01-15 16:27:59 +01:00
Artem Savkov 5406414dab Create private chat if it doesn't exist yet.
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.
2016-01-14 22:13:41 +01:00
Artem Savkov c4bcb79438 Fix a couple of memleaks. 2016-01-14 21:28:54 +01:00
Artem Savkov 4dc5bce89b Fix multiple issues with new private channels creation.
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.
2016-01-14 19:23:03 +01:00
Artem Savkov a4f09ac2e3 Add bitlbee-discord server to README.
Added a test server to README so that there is a place for people to
demonstrate/test bugs.
2016-01-14 12:55:25 +01:00