From c1460eb93a3e651d4209c32112c0938fcd94a16d Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 3 Jan 2025 02:31:54 +0100 Subject: [PATCH] less logging, safer logging, !meow --- CHANGELOG.md | 2 ++ bin/jana.dart | 17 +++++++++++++++-- pubspec.yaml | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d72fe0..7b33e68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,9 @@ - Remove `!vids` (it requires custom youtube logic and wasn't used) - Poll for videos on the side channels - Optimize the sleeping intervals to poll less, and more when needed +- Remove some in-discord logging that wasn't needed - `lints` 5 +- Add `!meow` ## 1.5.3 diff --git a/bin/jana.dart b/bin/jana.dart index a394bd7..d4a6db7 100644 --- a/bin/jana.dart +++ b/bin/jana.dart @@ -80,13 +80,21 @@ void main(List argv) async { var lastLogMsg = ''; var lastLogCount = 1; Logger.root.onRecord.listen((rec) => logMutex.protect(() async { - // TODO: if > 3900 dont send? + if (rec.level <= Level.INFO && + rec.loggerName.startsWith('Nyxx.Shards')) { + return; + } final ping = rec.level >= Level.WARNING ? ' <@&$admins>' : ''; var msg = '[${rec.level.name}] [${rec.loggerName}] ${rec.message}$ping'; - if (rec.error != null) msg += '\nError: ${rec.error}'; + if (rec.error != null) { + msg += '\nError: ${rec.error}'; + } if (rec.stackTrace != null) { msg += '\nStack trace:\n```${rec.stackTrace}```'; } + if (msg.length > 3950) { + msg = '${msg.substring(0, 3950)} ... (see logs for full message)'; + } if (lastLogMsg == msg) { lastLog ?.edit(MessageUpdateBuilder(content: '$msg x${++lastLogCount}')); @@ -121,6 +129,11 @@ void main(List argv) async { (v) => channel.sendJson(json.encode(videoToJson(v)), '$id.json')); } }, + '!meow': () { + if (!member.roleIds.any(priv.contains)) throw 'Not authorized'; + log.info(Iterable.generate(4 * 420).map((_) => 'meow').join(' ')); + channel.sendMessage(MessageBuilder(content: 'Meow!')); + }, if (lavalink != null) '!play': () async { if (!member.roleIds.any(priv.contains)) throw 'Not authorized'; diff --git a/pubspec.yaml b/pubspec.yaml index 1333438..97e18c0 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: jana description: A Discord bot -version: 2.0.0-beta.5 +version: 2.0.0-beta.6 homepage: https://github.com/chrissxMedia/jana environment: