From 661d689c9e85d2f4ff6fdff7ff9cfcd71387384a Mon Sep 17 00:00:00 2001 From: Ian Mancini Date: Mon, 15 Nov 2021 11:47:01 -0300 Subject: [PATCH] Remove twitch notifications script --- data/twitch-oauth.gpg | Bin 911 -> 0 bytes launch-twitch-notify | 7 --- twitch-notify | 111 ------------------------------------------ 3 files changed, 118 deletions(-) delete mode 100644 data/twitch-oauth.gpg delete mode 100755 launch-twitch-notify delete mode 100644 twitch-notify diff --git a/data/twitch-oauth.gpg b/data/twitch-oauth.gpg deleted file mode 100644 index 03428a687a0bf96d9ea52c851a8b326530f45035..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 911 zcmV;A191F>0Sp6B$Bdlj8sSd?2mKkeeH9g{$=|&u)7BXk+EI4vY*x@09t|= z87KnrvJgf8=sK-u=&HJ8AQNHS&oyQ0z9mUL`lTIThts%lO(9Q#K?*{8f>o%P8KJqJ z!NXFGLsdB^X>VEws3q^O=M|&GPz6*tdQ)E1-Hy8yzI*7Jq?0cAb6t^E>yOW#)tKYz zse603L(Y0x_Ir`aJVH7>`iq4D3>;zo$Z+RM4 z%4K93)HM1(um=E0{DLshV|%OB`cnn?3hRDzE=leMN_ZdR9Yko8nt&;PEXpZHv zT7j~s3e`4D8g}+kJ{7iKqnr)gM|SM1NbwCa^$Kqt^o)CRQ^;^l18!E ze5I>Y1Y^}zU_*PLUU|md;_F*eSr<1nx;daRT;_RKxmfJ85^hTb@n8oL}7f_ z*e*5zR_JabSb75U#1TTpI11^kVbeDP%?Hr2WNE)RffwQI3$po6(qI9g5xVpV4-I3q zyLgHsgwK=Z(XHXPmio>S*Im`bhSEI$Bi?d(9}4*y)xDsK))RVGKU&F^80!RRRqY)m lrH0yQ#N-fS+Sb?5I)ETKl(J=Tniq4o6^gSaN~ {__file__}" - """ - print(dedent(helpText)) - sys.exit(1) - - -def connect(): - """Connect to IRC and authenticate""" - - sock.connect((HOST, PORT)) - sock.send(f"PASS {config['token']}\n".encode('utf-8')) - sock.send(f"NICK {config['nickname']}\n".encode('utf-8')) - sock.send(f"JOIN {config['channel']}\n".encode('utf-8')) - - -def pong(resp): - """Answer to server PING to keep socket connection alive""" - - if resp.startswith('PING'): - sock.send("PONG\n".encode('utf-8')) - return True - return False - - -def wait_for_chat(resp): - """Wait until all welcome and user list messages are received""" - - if "End of /NAMES list" in resp: - global connected - connected = True - run(["notify-send", - f"connected to {config['channel']} as {config['nickname']}"]) - - -def handle_message(resp): - """Parse the message and send it as a notification""" - - print(resp) - user, channel, message = re.search(MESSAGE_REGEX, resp).groups() - - if user and channel and message: - if config['short_notification']: - notification_text = f"@{user}: {message}" - else: - notification_text = f"@{user} in #{channel}\n{message}" - - if not (config['supress_own'] and config['nickname'] == user): - run(["notify-send", notification_text]) - - -def handle_exit(sig, frame): - """Close socket connection before exit""" - - print(f"Got {sig.name}, closing socket") - sock.shutdown(socket.SHUT_RDWR) - sock.close() - sys.exit(0) - - -if __name__ == "__main__": - # Register signal handlers - signal.signal(signal.SIGINT, handle_exit) - signal.signal(signal.SIGTERM, handle_exit) - - get_token_from_env() - connect() - - while True: - resp = sock.recv(2048).decode('utf-8') - - if len(resp) > 0: - if not (pong(resp)): - if connected: - handle_message(resp) - else: - wait_for_chat(resp)