Created
April 14, 2020 05:01
-
-
Save SplitPixl/d9d074ec49874580248d55695272d797 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import twitch | |
from escpos import printer | |
import string | |
printable = set(string.printable) | |
p = printer.Serial("COM13") | |
def do(message): | |
print(f"{message.sender}: {message.text}") | |
p.set(text_type="B") | |
p.text(message.sender) | |
p.set(text_type="NORMAL") | |
p.text(": ") | |
try: | |
truncated = message.text[0:min( | |
len(message.text), 86 - (len(message.sender) + 2))] | |
out = ''.join(filter(lambda x: x in printable, truncated)) | |
p.text(out) | |
except: | |
p.set(invert=True) | |
p.text("[unprintable]") | |
p.set(invert=False) | |
p.text("\n") | |
twitch.Chat(channel='#splitpixl', nickname='splitpixl', | |
oauth="YOUR AUTH TOKEN").subscribe(do) | |
# Get an auth token from: https://twitchapps.com/tmi/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment