Commit Graph

152 Commits

Author SHA1 Message Date
Ske
2579683da9 Refactor interactive event handlers 2020-05-05 16:03:46 +02:00
Ske
f97ceac1fb Refactor Sentry scope enrichment 2020-05-02 16:00:43 +02:00
Ske
720755844f Rename BotHasPermission to a more descriptive name 2020-05-02 15:29:36 +02:00
Ske
ca57d10f7c Change formatting of shard number in status 2020-05-02 14:25:28 +02:00
Astrid
c551533313
Merge pull request #167 from acw0/master
Add current shard ID in status message
2020-05-02 14:22:03 +02:00
Ske
999ea5f0b5 Refactor and simplify the main bot classes 2020-05-02 01:52:52 +02:00
acw0
08077f6426 Add current shard ID in status message 2020-05-01 14:17:30 -04:00
Ske
48833639e2 Update shard status tracker for new library 2020-05-01 17:30:12 +02:00
Ske
7e43b75f97 Fix errors on eg. incoming link embed update events 2020-05-01 15:41:37 +02:00
Ske
546cb7f97a Remove webhook rate limit cache
The move to DSharpPlus makes it unnecessary, as D#+ can actually do webhook invocations on its own.
2020-05-01 00:00:33 +02:00
Ske
12aef1f61d Refactor periodic event loop 2020-04-29 01:14:49 +02:00
Fennel
66dd850504 Fix SocketErrored and Ready events 2020-04-28 22:30:11 +02:00
Fennel
2fd07c9ec9 Fix Periodic Methods 2020-04-28 22:30:11 +02:00
Fennel
949dae6561 Add Extension Methods 2020-04-28 22:30:11 +02:00
Ske
23cf06df4c Port some things, still does not compile 2020-04-17 23:10:01 +02:00
Ske
93bf7c6543 Add periodic garbage collection of webhook rate limit cache 2020-04-16 18:18:08 +02:00
Ske
4701f4b56c Add proper logging of startup errors 2020-03-27 00:02:56 +01:00
Ske
0eb2e8be6f Skip messages before current user ID is established 2020-03-08 11:10:05 +01:00
Ske
a95d12639d Handle send message/embed links permission erorrs gracefully 2020-02-24 09:57:16 +01:00
Ske
e9cc8ed424 Add logger bot cleanup support 2020-02-15 14:17:25 +01:00
Ske
dc10a8411a Disable autoproxy retriggering on edit 2020-02-12 17:44:24 +01:00
Ske
6d5004bf54 Large refactor and project restructuring 2020-02-12 15:16:19 +01:00
Ske
b68e221fc6 Track current shard in Sentry reports 2020-02-12 14:37:11 +01:00
Ske
1386e6743b Proxy edited messages if the message is the last one in the channel, and the edit introduces proxy tags where there were none previously 2020-02-12 14:21:48 +01:00
Ske
82dfe43d5a Rework caching
This does a *lot* of things. Essentially, it replaces the existing
individual proxy- and autoproxy caches on the bot end with a
global cache (in Core) that handles all the caching at once, and
automatically invalidates the cache once something changes in the
datastore.

This allows us to do proxying and autoproxying with *zero database
queries* (best-case).
2020-02-01 14:40:57 +01:00
Ske
1ea0526ef8 Migrate DI container to Autofac 2020-01-26 01:27:45 +01:00
Ske
83cfb3eb46 Add autoproxy functionality 2020-01-24 20:28:48 +01:00
Ske
57bc576de6 Add autoproxy management commands 2020-01-23 21:20:22 +01:00
Ske
98613c4287 Add system and member privacy support 2020-01-11 16:51:13 +01:00
Grey Himmel
da83f72582 Update Bot.cs
- Add note telling users to describe what happened when reporting errors
2020-01-08 20:40:32 +01:00
Ske
4a30e56298 Add basic database schema migration system 2019-12-26 21:43:05 +01:00
Ske
1c184825e3 Use fork of D.NET to potentially resolve issues 2019-12-23 18:36:56 +01:00
Ske
5448f734d4 Try logging *literally everything* 2019-12-23 14:44:20 +01:00
Ske
5ff32ea6b4 Re-enable proxy attachments 2019-12-23 13:55:43 +01:00
Ske
3fdfaeab01 Disable message attachments as a temporary fix 2019-12-23 01:53:01 +01:00
Ske
265184f4f6 Couple tweaks to potentially improve performance 2019-12-23 01:49:21 +01:00
Ske
bbbbb5a046 Fix error on empty message 2019-12-23 01:49:00 +01:00
Ske
4a8dd7e8e3 Oops 2019-12-23 00:31:31 +01:00
Ske
05282fd167 Reuse a singleton HttpClient for proxying 2019-12-23 00:29:04 +01:00
Ske
c70556f5f9 Increase minimum thread pool size 2019-12-23 00:28:19 +01:00
Ske
b6597c79d6 Add temporary ThreadPool trace logging 2019-12-22 23:27:11 +01:00
Ske
b81eda47aa Expand pk;stats functionality 2019-12-22 12:50:47 +01:00
Ske
93a52ff95a Add exception logging for dropped connections 2019-12-22 12:08:52 +01:00
Ske
6a55555e48 Attempt a few memory/connection optimizations 2019-12-22 01:08:14 +01:00
Ske
378cba09e5 Add channel blacklists for logging and proxying
Necessary database migrations for this commit:
    alter table servers add column log_blacklist bigint[] not null default array[]::bigint[];
    alter table servers add column blacklist bigint[] not null default array[]::bigint[];
2019-11-03 19:15:50 +01:00
Ske
8d003da091 Remove chunk of commented-out outdated code 2019-11-03 13:37:48 +01:00
Ske
0f48c6879b Attempt to fix slow/timeout-y bot startup
I've noticed the bot's CPU spiking for a few minutes as it's
just connecting, and a lot of shard connections are timing out.

I suspect it might be the overload of messages as the shards
connect and Discord sends it the entire backlog at once. So,
as an interim solution, I'm making it simply discard every
message before the socket is fully connected. Hopefully this
should help reduce the pressure.
2019-10-31 17:21:12 +01:00
Ske
545e8df6a7 Reduce the log level of various common events 2019-10-27 23:44:27 +01:00
Ske
fbb5dbbf5d Don't embed support server link in error message 2019-10-27 23:01:38 +01:00
Ske
7f55fca625 Make prefix matching case-insensitive 2019-10-27 15:08:33 +01:00
Ske
aed38f37f7 Allow starting bot before all shards are up 2019-10-27 13:01:33 +01:00
Ske
6a73b3bdd6 Refactor data stores, merging the Store classes 2019-10-26 19:45:44 +02:00
Ske
53ae0e3d70 Improve error handling and reporting after command rewrite 2019-10-22 19:31:40 +02:00
Ske
1988b29fbc Refactor command system 2019-10-05 07:41:00 +02:00
Ske
86d0b24758 Include event ID in Sentry dump 2019-09-02 20:37:24 +02:00
Ske
74e0508065 Increase webhook name limit to 80 2019-08-14 07:16:48 +02:00
Ske
5f79aaf960 Fix API service injection 2019-08-12 06:54:28 +02:00
Ske
a48940476c Eagerly discard messages before shard init 2019-08-12 06:10:55 +02:00
Ske
7945603cdb Include invite link in error message 2019-08-12 06:03:20 +02:00
Ske
d3f821a266 Send a request ID on error 2019-08-12 05:56:05 +02:00
Ske
145ecb91ad Refactor proxy service 2019-08-12 05:47:55 +02:00
Ske
fda98bc25f Lower message cache size 2019-08-12 05:03:18 +02:00
Ske
c68ce1bdd3 Log gateway latency to console 2019-08-12 04:05:22 +02:00
Ske
aa04d2055e Avoid deleting messages from the store if they're not webhooks 2019-08-12 03:51:54 +02:00
Ske
423d23faf7 Cache account lookup in memory when proxying 2019-08-12 03:48:08 +02:00
Ske
99ec3cd355 Instrument and log database queries 2019-08-12 02:05:30 +02:00
Ske
ea476d4051 Yield event handlers to task queue before handling 2019-08-12 01:15:55 +02:00
Ske
a689d61788 Collect webhook response time and shard latency 2019-08-12 00:57:23 +02:00
Ske
b593c32950 Add more extensive debug-level logging
- Logging of event IDs
- Logging of command invocations (at DEBUG)
2019-08-12 00:07:29 +02:00
Ske
942022d408 Track database handles over metrics 2019-08-11 22:56:20 +02:00
Ske
3f6a260fac Properly associate trigger events with Sentry errors 2019-08-09 12:47:46 +02:00
Ske
11eabe2e3d Update D.NET version and add bulk deletion support 2019-07-21 17:16:04 +02:00
Ske
4fe80749c4 Fix compiler warnings CS1998 and CS4014 2019-07-21 16:43:28 +02:00
Ske
4f33ed84ac Disable message caching
This will potentially fix the memory leaking issues.
2019-07-20 23:10:26 +02:00
Ske
b85c79c57b Expand logging capability 2019-07-19 02:29:08 +02:00
Ske
0b4335ccaa Add logger to API service setup 2019-07-18 17:26:06 +02:00
Ske
961bfe9094 Add basic logging framework 2019-07-18 17:13:42 +02:00
Ske
a188c64a0e Clean up unused imports 2019-07-17 13:38:23 +02:00
Ske
02b41413b3 Add basic InfluxDB reporter 2019-07-16 23:34:22 +02:00
Ske
2d58705e85 Add basic WIP metrics system 2019-07-16 21:59:06 +02:00
Ske
51b9afddea Properly format Sentry message breadcrumbs 2019-07-16 01:32:08 +02:00
Ske
2aae92406a Remove Sentry scope setup for now 2019-07-16 01:28:55 +02:00
Ske
d47e7e7a06 Don't process messages until we're fully connected to shard zero 2019-07-15 21:29:45 +02:00
Ske
18e4d7c9ac Add preliminary Sentry support 2019-07-15 21:02:50 +02:00
Ske
7475980bd3 Fix sharding issue hopefully for good 2019-07-15 17:23:27 +02:00
Ske
1f3b0c6de6 Properly initialize a sharded client 2019-07-15 17:16:14 +02:00
Ske
ebc311ecc3 Remove message query reaction AND open DB connection when obtaining one 2019-07-14 05:23:27 +02:00
Ske
c6905f4ca1 Allow single quotes in command arguments 2019-07-11 22:34:38 +02:00
Ske
d829630a35 Fix database connection pool contention (maybe)
Instead of acquiring a connection per service per request, we
acquire connections more often but at a more granular level, meaning
they're also disposed of more quickly instead of staying for a long time
in case of long-running commands or leaks.
2019-07-11 21:25:23 +02:00
Ske
ca56fd419b Fix various issues with proxying and webhook caching 2019-07-10 23:16:17 +02:00
Ske
9b488d1ab5 Add more lenient prefix parsing 2019-07-10 10:01:06 +02:00
Ske
4874879979 Add basic API, only with system endpoints 2019-07-09 20:39:29 +02:00
Ske
b5c9793578 Add config file loading 2019-07-01 00:55:41 +02:00
Ske
7eeaea39fe Proxy messages with a mention before tags 2019-06-27 10:38:45 +02:00
Ske
652afffb8c Add importing and exporting function 2019-06-14 22:48:19 +02:00
Ske
7e9b7dcc98 Add switch commands for adding and moving 2019-06-13 16:53:04 +02:00
Ske
4c6790432b Add system linking commands 2019-05-21 23:40:26 +02:00
Ske
8b8ec80944 Move database/mapper setup code to Core 2019-05-19 22:03:45 +02:00
Ske
08afa2543b Add member avatar edit command
This also refactors a large portion of the DI toolchain, since
I discovered that you shouldn't be reusing IDbConnection objects.

Instead, most services and stores are now declared transient, and
the webhook cache has been moved to a database-independent storage
singleton by itself.
2019-05-17 01:23:09 +02:00
Ske
62dc2ce78e bot: add birthday command 2019-05-13 22:44:49 +02:00