twitch-chat-bot icon indicating copy to clipboard operation
twitch-chat-bot copied to clipboard

!! / !bang?

Open asottile opened this issue 5 years ago • 4 comments

1:05 MetaBytez: Do you have a command !! that just repeats the last bot command 
Kappa
1:05 MetaBytez: Or maybe !bang

asottile avatar Oct 14 '20 20:10 asottile

Would you two be open to me taking a stab at this one?

Preocts avatar Jan 30 '22 04:01 Preocts

iirc this is hard / not really feasible since every message is dispatched independently and asynchronously

asottile avatar Jan 30 '22 14:01 asottile

I was poking around and the add_alias() function caught my muse. Would appear if an alias !bang and !! were made of the most recent command successfully found that you'd have part of the desired outcome. I may have missed some I/O but it looked to me like commands are only held in memory so this call felt very inexpensive.

https://github.com/anthonywritescode/twitch-chat-bot/blob/50341c30d8eada4b50634c8f25a9eb0eed681735/bot/data.py#L113-L116

How to handle keeping message permissions from being skipped, that all commands are stripped of extra bangs, and the command pattern doesn't presently match !! were where I stopped.

https://github.com/anthonywritescode/twitch-chat-bot/blob/50341c30d8eada4b50634c8f25a9eb0eed681735/bot/data.py#L144

https://github.com/anthonywritescode/twitch-chat-bot/blob/50341c30d8eada4b50634c8f25a9eb0eed681735/bot/data.py#L18

(either way, neat implementation and I learned a few things digging through it which was my primary goal!)

Preocts avatar Jan 30 '22 15:01 Preocts

the aliasing system is for command names and probably wouldn't work or help for command values -- it's also meant to be ~immutable after process startup

asottile avatar Jan 30 '22 15:01 asottile