diff options
author | Joe Rayhawk <jrayhawk+git@omgwallhack.org> | 2020-10-25 00:10:15 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk+git@omgwallhack.org> | 2020-10-25 00:10:15 -0700 |
commit | ad7a8b7b0520e59148c83daa46633463d8712fda (patch) | |
tree | 0c45a9cdb0ef1f476b8703ddd1f4f08067666e6b /twitchpubsub.rb | |
parent | 805ddfbbdc357d3348e6f8a0abb9bb0be631d543 (diff) | |
download | twitchtools-ad7a8b7b0520e59148c83daa46633463d8712fda.tar.gz twitchtools-ad7a8b7b0520e59148c83daa46633463d8712fda.zip |
Ruby pubsub: remove some "deprecated" pubsub subs.
Diffstat (limited to 'twitchpubsub.rb')
-rwxr-xr-x | twitchpubsub.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/twitchpubsub.rb b/twitchpubsub.rb index cd02c14..49ebe6d 100755 --- a/twitchpubsub.rb +++ b/twitchpubsub.rb @@ -26,7 +26,7 @@ http.read_timeout = 10 # kraken broke #channel_id = JSON.parse(http.request(Net::HTTP::Get.new("/kraken/channels/#{channel}?client_id=#{client_id}")).body)['_id'].to_s -def normalize_twitch_pubsub_bullshit_data_because_seriously_fuck_twitch( parsed ) +def normalize_twitch_pubsub_bullshit_data_because_seriously_fuck_twitch( parsed ) # Twitch may or may not have JSON-encoded this JSON because Twitch. begin message = JSON.parse( parsed['data']['message'] ) @@ -48,9 +48,9 @@ end def dispatch_message( message, unix_socket_path ) unix_socket = UNIXSocket.new( unix_socket_path ) if message['context'] == 'subgift' then # Gifted subscription - unix_socket.print( message['recipient_user_name'] + ' has subscribed for ' + (message['cumulative_months'].to_i+1).to_s + ' months at sub level #' + message['sub_plan'] + 'thanks to a gift from ' + message['user_name'] + ': "' + message['sub_message']['message'] + "\"\n" ) + unix_socket.print( message['recipient_user_name'] + ' has subscribed for ' + (message['cumulative_months'].to_i).to_s + ' months at sub level #' + message['sub_plan'] + 'thanks to a gift from ' + message['user_name'] + ': "' + message['sub_message']['message'] + "\"\n" ) elsif message['sub_plan'] then # Subscription - unix_socket.print( message['user_name'] + ' has ' + message['context'] + 'scribed for ' + (message['cumulative_months'].to_i+1).to_s + ' months at sub level #' + message['sub_plan'] + ': "' + message['sub_message']['message'] + "\"\n" ) + unix_socket.print( message['user_name'] + ' has ' + message['context'] + 'scribed for ' + (message['cumulative_months'].to_i).to_s + ' months at sub level #' + message['sub_plan'] + ': "' + message['sub_message']['message'] + "\"\n" ) elsif message['item_description'] then # commerce unix_socket.print( message['user_name'] + ' has purchased ' + message['item_description'] + ': "' + message['purchase_message']['message'] + "\"\n" ) elsif message['bits_used'] then # bits @@ -74,7 +74,7 @@ IO.select( [ tcp_socket ] ) print ssl_socket.read_nonblock( 4096 ) # Twitch calls it "auth_token" here rather than the usual "access_token" because Twitch. -ssl_socket.write( WebSocket::Frame::Outgoing::Client.new( data: '{ "type": "LISTEN", "nonce": "fart", "data": { "topics": ["channel-bits-events-v1.' + channel_id + '", "channel-subscribe-events-v1.' + channel_id + '", "channel-commerce-events-v1.' + channel_id + '", "whispers.' + channel_id + '" ], "auth_token": "'+access_token+'" } }', type: :text ).to_s ) +ssl_socket.write( WebSocket::Frame::Outgoing::Client.new( data: '{ "type": "LISTEN", "nonce": "fart", "data": { "topics": ["channel-bits-events-v1.' + channel_id + '", "channel-subscribe-events-v1.' + channel_id + '", "whispers.' + channel_id + '" ], "auth_token": "'+access_token+'" } }', type: :text ).to_s ) # Keepalive thread t2 = Thread.new { |