Commit Graph

275 Commits

Author SHA1 Message Date
Artem Savkov c09d403952 Do not try to fetch messages for nonexistan channels.
For some reason discord leaves read_state data about channels that no longer
exist in initial datastructure you get on connect. Trying to fetch backlog
messages from those channels resulted in a segfault, now those are ignored.
2016-01-14 12:05:46 +01:00
Artem Savkov ae894c5af0 Add support for "@nick" mentions.
Unlike suffix mentions, where a user can change the trigger character, prefix
character is immutable and is hardcoded to "@", this is to mimic discords
behaviour.
2016-01-13 10:18:44 +01:00
Artem Savkov 8b410390f9 Define PKG_CHECK_VAR for old pkg-config (<0.28) 2016-01-12 20:25:40 +01:00
Artem Savkov 3a25fd26c6 Create m4 dir before calling autoreconf 2016-01-12 18:21:45 +01:00
Artem Savkov 20c0f1be3d Do not overwrite topics with "".
If channel topic is "", do not overwrite default bitlbee's topic which has
namehint in it (currently in "Server/channel" format, and might help
distinguish between channels with similar names.
2016-01-12 17:15:18 +01:00
Artem Savkov 2cc66576af Better support for non-canonical names.
Instead of relying on bitlbee to do this bitlbee-discord will now canonize (or
try to) nicknames itself. This fixes outgoing mentions for nicknames with
spaces.
2016-01-12 16:35:08 +01:00
Artem Savkov 1b0847ee28 Properly parse gateway websocket url.
Previously I just assumed that the path in gateway url will always be "/" and
that it will always use secure connection. Latest discord changes proved me
wrong. Properly parsing the url now.
2016-01-12 13:57:05 +01:00
Artem Savkov 32c412e230 Add outgoing mentions support.
This commit adds automatic conversion of outgoing messages from irc-style
highlighting (e.g. "nick:") to discord's "<@id>" format.  New "mention_suffix"
option is added.
Outgoing mentions currently won't work with names containing spaces.

Fixes: issue #9.
2016-01-12 10:38:43 +01:00
Artem Savkov 9d9eb5df04 Switch to autotools.
Finally define specific versions in dependencies and switch to autotools
buildsystem. Hopefully this will give us better portability and won't induce
major headaches.
2016-01-04 22:13:42 +01:00
Artem Savkov f18239d9cb Switch back to lws_context instead of lws_protocols.
Use undocumented lws_get_context to get context and thus struct im_connection
instead of less reliable lws_protocols.
2016-01-04 14:23:55 +01:00
Artem Savkov de68da47ef Rename disable_acks option to send_acks.
Invert the logic and rename "disable_acks" option to "send_acks"
2016-01-01 22:48:15 +01:00
Artem Savkov 303c777e63 Add disable_acks per-account option.
Add an option that will allow users to disable message acks, might be useful
when using bitlbee as a backup solution.
2016-01-01 19:52:34 +01:00
Artem Savkov 1bca664ee4 Fix install command.
Some of the versions of install do not recognize "=" and fail with
install: invalid mode=755

Reported by: @Kays in issue #5.
2016-01-01 15:42:20 +01:00
Artem Savkov ff72659fe8 Fix outgoing non-ascii messages.
Commit 4ab2b5a broke outgoing non-ascii messages by escaping every utf8 char.
So far we only needed to escape '"' char, so switch to regex approach instead
of using g_strescape().
2016-01-01 15:30:06 +01:00
Artem Savkov 2d12954732 Update to lws 1.6.0
libwebsockets broke API yet again, updating to latest.
2016-01-01 14:18:19 +01:00
Artem Savkov edffe8cd59 Fix build error in discord-handlers.h
We should include bitlbee/json.h implicitly in discord-handlers.h since we now
export discord_handle_message.
2016-01-01 12:05:08 +01:00
Artem Savkov 5a5627e491 Ack backlog messages.
Send an ack after receiving backlog messages so that they won't be repeated if
we relog without any new messages.
2015-12-28 12:09:20 +01:00
Artem Savkov 91af88e8d6 Fix login error messages.
Fix a refactoring artifact masking real login errors.
2015-12-28 11:59:43 +01:00
Artem Savkov 1aa89dec6a Add backlog support.
Add support for backlog messages that arrived while you weren't on discord.
This commit also adds "max_backlog" option.
2015-12-28 11:52:21 +01:00
Artem Savkov 802118aead Add ack support.
Send acks for every message received so that you won't have '99 unread
messages' next time you login using webapp.
2015-12-28 10:28:00 +01:00
Artem Savkov 2dcc18dd4f Add support for url expansion.
Discord provides additional info about posted urls such as title and
description. Print this info into channel through a special handle that can be
adjusted via urlinfo_handle per-acc option.
2015-12-27 18:41:48 +01:00
Artem Savkov 8d4360c77f Add support for edited messages.
Display message updates for edited messages. This commit also introduces
"edit_prefix" per-acc option that enables the user to customise the string that
will be prefixed to the edited message.
2015-12-27 17:43:04 +01:00
Artem Savkov 4ab2b5a2a5 Escape specific characters before sending message.
Use g_strescape to add '\' before some characters such as '"' to send messages
containing those without failing.
2015-12-27 14:03:47 +01:00
Artem Savkov 9990487e54 Add license info 2015-12-16 11:25:16 +01:00
Artem Savkov 61aaaccae4 Remove noise when voice_status_notify is on.
Do not send notifications if user is self or when channel is not actually
changed (discord sends updates on (un)mute/deafen).
2015-12-12 13:05:51 +01:00
Artem Savkov 47d1f2e838 Add glib2 to dependencies list in README. 2015-12-12 12:55:26 +01:00
Artem Savkov 8433d12f05 Add voice_status_notify per-account option.
This option enables text notifications about voice channel status changes.
2015-12-12 12:43:44 +01:00
Artem Savkov 7c2f735eee Track users across voice channels.
Add voice_channel field to user info to track if user is on a voice channel and
which one if yes.
2015-12-12 12:19:46 +01:00
Artem Savkov 432767279a Get user/channel info through functions from discrod-util.
Do not traverse the lists by hand, use get_*_by_id functions from discord-util.
This adds get_user_by_id and changes get_channel_by_id to traverse all servers
in case no server is specified.
2015-12-12 12:02:02 +01:00
Artem Savkov 978e3de1e4 Keep track of voice channels as well.
Get info and keep it in server_info channel list about voice channels. This
might later be used to somehow (imcb_log or nick changes) indicate buddies
being in voice channels (specific or in general).
2015-12-08 23:07:47 +01:00
Artem Savkov b899973bca Update lws_pollargs struct name.
libwebsockets recently changed one of the structure's names from
libwebsockets_pollargs to lws_pollargs. Updating so that bitlbee-discord builds
with libwebsockets version from git.

This fixes issue #3 from github.
2015-12-06 09:34:20 +01:00
Artem Savkov 19da06c348 Refactor all the things.
Split this huge prototyping mess in a single lump into separate files. Better
do this early then never.
2015-12-05 18:28:53 +01:00
Artem Savkov 6bb5a8b840 Replace ids with nicknames in mentions.
When someone is mentioned discords replaces user's nickname with "<@[id]>" in
'content' part of the message, it also adds all of the user info into
'mentions' array, so we have to reverse this process to provide human-readable
names in messages.

This fixes issue#2 from github.
2015-12-04 17:06:51 +01:00
Artem Savkov 609546d864 Add README. 2015-12-04 14:54:52 +01:00
Artem Savkov 03b17c1608 Change install dir: lib64->lib.
Changing install dir to lib from lib64 because default plugindir in bitlbee is
defined as '$prefix/lib/bitlbee' regardless of arch.
2015-12-04 14:21:45 +01:00
Artem Savkov a5335e1898 Do not call imc_logout from ws protocol callback.
Calling imc_logout inside protocol callback results in ws context being
released which confuses libwebsockets which is still inside service routine and
leads to a segfault. Fix this by adding yet another state just to move
imc_logout call to lws_service_loop func.
2015-12-03 23:49:48 +01:00
Artem Savkov 4ac13e071c Add CHANGE_MODE_POLL_FD handling.
Change events we are monitoring on websocket fd the way libws tells us, this
reduces the number of lws_service_loop drastically.
2015-12-03 23:43:24 +01:00
Artem Savkov c5bd425a02 Move keepalive handling to a different eventloop.
Add a separate timeout-based eventloop for keep-alive messages.
2015-12-03 23:37:45 +01:00
Artem Savkov d69e14526d Check libwebsocketcontext before trying to destroy it.
Apparently libwebsocket doesn't check for NULL in libwebsocket_cancel_service,
so we should.
2015-12-03 19:30:06 +01:00
Artem Savkov 718e31bc8c Keep trying to reconnect on libwebsocket errors 2015-11-30 13:18:52 +01:00
Artem Savkov b86a4da693 Remove debug prints 2015-11-29 11:24:46 +01:00
Artem Savkov c3a24f7dcd Add server handling.
Add handler for GUILD_{CREATE,DELETE} events.
2015-11-29 10:45:42 +01:00
Artem Savkov e708f43638 Fix a couple of memleaks 2015-11-29 10:07:18 +01:00
Artem Savkov fa9c9f2a27 Add user handling.
Add handler for USER_{CREATE,DELETE} events.
2015-11-29 09:55:09 +01:00
Artem Savkov ac70f22827 Add channel handling.
Add handler for CHANNEL_{CREATE,DELETE,UPDATE} messages.
2015-11-29 09:06:34 +01:00
Artem Savkov 1785f1eb7f Revert "Make sure socket is writable before sending keepalive."
This reverts commit 19a8c336c7.
2015-11-28 17:13:21 +01:00
Artem Savkov 816bf932b0 Add presence handling.
Actually handle presences. Users will now only show up in channels if they are
actually online.

This commit also contains an accidental retab which renders it completely
unreadable, welp.
2015-11-28 12:53:08 +01:00
Artem Savkov 19a8c336c7 Make sure socket is writable before sending keepalive.
When it is time to send keepalive ask for "writable" callback instead of just
writing to socket.
2015-11-28 10:30:50 +01:00
Artem Savkov 5bfa7a4520 Switch to fd-based events.
Use fd-based events instead of a timer to speed up event processing.
2015-11-28 10:18:22 +01:00
Artem Savkov cddec66a7e Swith to websockets.
Use websocket api the way it was intended. This adds a dependency on
libwebsockets (not sure about specific version yet, but old ones do not work).
2015-11-27 20:54:02 +01:00