diff options
Diffstat (limited to 'ircobsbridge.rb')
-rw-r--r-- | ircobsbridge.rb | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/ircobsbridge.rb b/ircobsbridge.rb index 326b8d4..3b7bf74 100644 --- a/ircobsbridge.rb +++ b/ircobsbridge.rb @@ -216,6 +216,11 @@ $globallastused = 0 def command_dispatch( mode, user, command, arg1 ) # arg1 may be empty String safe = /^[-0-9a-zA-Z_]+$/ + # '@'-style user mode reporting is super flaky on the Twitch IRC gateway. + # FIXME: Should probably dynamically poll and cache .mods/.vips output. + if user == $CHANNEL + mode = '@' + end if mode == '@' && command == 'scene' if arg1 =~ safe SetCurrentScene( arg1 ) @@ -257,6 +262,9 @@ def command_dispatch( mode, user, command, arg1 ) elsif mode == '@' && ( command == 'nextsong' || command == 'next' ) ircsocketwrite( "| " + $m.next["file"] + "\n" ) return + elsif ( command == 'uptime' ) + ircsocketwrite( "| " + $status["stream-timecode"] + "\n" ) + return elsif ( command == 'currentsong' ) || ( command == 'current' ) ircsocketwrite( "| " + $m.currentsong["file"] + "\n" ) return @@ -282,7 +290,7 @@ def command_dispatch( mode, user, command, arg1 ) end # popen to get output someday? elsif mode == '@' && command == 'commands' - ircsocketwrite( "| !songrequest !currentsong !next !volume !delsong !source !scene !pubg !metaminute !nopgl1 !nopgl2\n" ) + ircsocketwrite( "| !uptime !songrequest !currentsong !next !volume !delsong !source !scene !pubg !metaminute !nopgl1 !nopgl2 !design\n" ) return end # ratelimited commands after +o commands @@ -293,6 +301,20 @@ def command_dispatch( mode, user, command, arg1 ) return end end + if command =~ /^(design)$/ + if ( ! $lastused[ command ] || $lastused[ command ] <= ( Time.now.to_i - 5 ) ) # || mode == '@' + $lastused[ command ] = Time.now.to_i + ircsocketwrite( "| http://i.imgur.com/s29rvaw.jpg http://i.imgur.com/OjMkp6I.jpg\n" ) + return + end + end + if command =~ /^(mattscott)$/ + if ( ! $lastused[ command ] || $lastused[ command ] <= ( Time.now.to_i - 5 ) ) # || mode == '@' + $lastused[ command ] = Time.now.to_i + ircsocketwrite( "\"We're not looking to [...] change the monetization.\" https://forums-old.gamersfirst.com/topic/408317-/page-5#entry4522545\n" ) + return + end + end if command =~ /^(pubg)$/ if ( ! $lastused[ command ] || $lastused[ command ] <= ( Time.now.to_i - 5 ) ) # || mode == '@' $lastused[ command ] = Time.now.to_i @@ -307,7 +329,7 @@ def command_dispatch( mode, user, command, arg1 ) transientsource( command ) return elsif command == 'commands' - ircsocketwrite( "| !songrequest !currentsong !pubg !metaminute !nopgl1 !nopgl2\n" ) + ircsocketwrite( "| !design !uptime !songrequest !currentsong !pubg !metaminute !nopgl1 !nopgl2\n" ) return end end @@ -353,7 +375,7 @@ end # irclog read loop event thread ircreader = Thread.new { begin - irclog = IO.popen('/usr/bin/tail -n0 -F ' + ENV['HOME'] + '/irclogs/twitch/#' + $CHANNEL + '.log' ) + irclog = IO.popen('logtail ' + ENV['HOME'] + '/irclogs/twitch/#' + $CHANNEL + '/' ) irclog.each_line do |line| if ( match = line.match(/^\d\d:\d\d <([@ +])(.+)?> *!([-0-9a-zA-Z]+) *(.*)/) ) command_dispatch( *match.to_a[1..4] ) |