busty icon indicating copy to clipboard operation
busty copied to clipboard

Add a command to count # of messages in a channel

Open Cephian opened this issue 2 years ago • 2 comments

To ease our worries about people messaging and going over cap. Add a command !count with optional parameter #channel which prints the number of messages in a channel, or "{MAXIMUM_MESSAGES_TO_SCAN}+" if the amount is more than MAXIMUM_MESSAGES_TO_SCAN

Cephian avatar Mar 30 '22 21:03 Cephian

Hmm, I feel that if we have the ability to count the number of messages in a channel, we also have the ability to just pass that number to channel.history?

...I've also just read the documentation on history() and realised we can just set limit=None to scan the entire channel.

Alternatively, we could just set the limit to something improbably high, but not infinity. So that in case we do accidentally run !list on an archive channel, it would perhaps take about a minute to time out, rather than much longer.

I'm not sure if you've run this on any of the archive channels yet, but somewhat surprisingly the largest count of messages I can find among a small sample are <3K for the entire event:

image.

So perhaps we just want to stick with a limit, but one that's much higher than what could be reasonably sent in 15m?

anoadragon453 avatar Apr 01 '22 21:04 anoadragon453

Alternatively, we could impose no limit on channel.history, but make !list interruptable by a new !list invocation. I don't think we ever really want Busty to not read the entire channel, our only fear is that we don't want a scan run "too early" to block us for too long.

Extra: We could also add a command to cancel an active list without starting a new one, since it would be simple if we implemented the cancellable !list, though I'm not sure what the use case would really be other than saving VPS resources or wanting to not invalidate the file cache over an accidental !list, neither of which are a situation I've been in.

Cephian avatar Apr 01 '22 22:04 Cephian