Skip to content

Commit

Permalink
less logging, safer logging, !meow
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelcmtd committed Jan 3, 2025
1 parent ef7a933 commit c1460eb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 15 additions & 2 deletions bin/jana.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,21 @@ void main(List<String> 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}'));
Expand Down Expand Up @@ -121,6 +129,11 @@ void main(List<String> 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';
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit c1460eb

Please sign in to comment.