summaryrefslogtreecommitdiff
path: root/twitchpubsub.rb
diff options
context:
space:
mode:
Diffstat (limited to 'twitchpubsub.rb')
-rwxr-xr-xtwitchpubsub.rb8
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 {