diff options
author | Joe Rayhawk <jrayhawk+git@omgwallhack.org> | 2022-07-19 00:39:20 -0700 |
---|---|---|
committer | Joe Rayhawk <jrayhawk+git@omgwallhack.org> | 2022-07-19 00:39:20 -0700 |
commit | 36cbfdaaf559629b9298c9ee011580554dddeb0b (patch) | |
tree | 391d80df42401672d9486325bd404f1fa89fd671 /crystal | |
parent | 2de61509f24621300d439a133f6c4dc5a932dfeb (diff) | |
download | twitchtools-36cbfdaaf559629b9298c9ee011580554dddeb0b.tar.gz twitchtools-36cbfdaaf559629b9298c9ee011580554dddeb0b.zip |
bungmobott: various small corrections
Diffstat (limited to 'crystal')
-rwxr-xr-x | crystal/bungmobott.cr | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/crystal/bungmobott.cr b/crystal/bungmobott.cr index 0f95e7a..d2b2cd9 100755 --- a/crystal/bungmobott.cr +++ b/crystal/bungmobott.cr @@ -56,8 +56,8 @@ else end # enable aws? -if ! File.exists?( Path.home./("\\.aws\\credentials") ) - STDERR.puts "Warning: #{Path.home}\\.aws\\credentials is missing; AWS voices disabled." +if ! File.exists?( Path.home./("/.aws/credentials") ) + STDERR.puts "Warning: #{Path.home}/.aws/credentials is missing; AWS voices disabled." aws = false elsif ! Process.find_executable( "aws.exe" ) STDERR.puts "Warning: aws.exe is missing; AWS voices disabled." @@ -69,18 +69,14 @@ end client = Twitcr::Client.new( settings ) # derive channel_id from channel or vice versa -if ( - File.exists?( settings["configdir"] + "channel" ) && - ( settings["channel"] = File.read( settings["configdir"] + "channel" ).chomp ) - ) || ( - File.exists?( settings["configdir"] + "channel_id" ) && - ( settings["channel_id"] = File.read( settings["configdir"] + "channel_id" ).chomp ) - ) - if ! ( settings["channel"]? =~ regextwitchuser ) && settings["channel_id"]? =~ /^[0-9]+$/ - settings["channel"] = client.user( settings["channel_id"].to_u64 ).login - elsif ( settings["channel_id"]? =~ regextwitchuser ) && ! settings["channel_id"]? =~ /^[0-9]+$/ - settings["channel_id"] = client.user( settings["channel"] ).id.to_s - end +[ "channel", "channel_id" ].each do |key| + File.exists?( settings["configdir"] + key ) && ( settings[key] = File.read( settings["configdir"] + key ).chomp ) +end +if ( settings["channel"]? =~ regextwitchuser ) && ( settings["channel_id"]? =~ /^[0-9]+$/ ) +elsif ! ( settings["channel"]? =~ regextwitchuser ) && ( settings["channel_id"]? =~ /^[0-9]+$/ ) + settings["channel"] = client.user( settings["channel_id"].to_u64 ).login +elsif ( settings["channel"]? =~ regextwitchuser ) && ! ( settings["channel_id"]? =~ /^[0-9]+$/ ) + settings["channel_id"] = client.user( settings["channel"] ).id.to_s else STDERR.puts "ERROR: Missing #{settings["configdir"]}channel and channel_id configuration keys." error = true @@ -88,7 +84,7 @@ else end if error == true {% if flag?(:windows) %} - puts "press enter to end program" + STDERR.puts "press enter to end program" gets {% end %} exit 1 @@ -97,7 +93,7 @@ end if File.exists?( settings["configdir"] + "chatuser" ) File.read( settings["configdir"] + "chat_user" ).chomp else - STDERR.puts "Missing " + settings["configdir"] + "chat_user; using configured channel instead." + STDERR.puts "Warning: " + settings["configdir"] + "chat_user is missing; using configured channel instead." settings["chat_user"] = settings["channel"] end @@ -231,9 +227,9 @@ def t2s( t2sipc : Channel, settings : Hash(String, String), userdir : String, ch }.each do | subtuple | text = text.gsub( subtuple[0], subtuple[1] ) end - {% if flag?(:windows) %} # send to thread + {% if flag?(:windows) %} t2sipc.send( { voice, "#{namesub} #{text}" } ) - {% else %} # send to socket + {% else %} t2smsg( settings, "#{voice} #{namesub} #{text}" ) {% end %} return( voice ) @@ -866,10 +862,8 @@ loop do ircipc.send( { "##{settings["channel"]}", "| overlay requires an argument consisting wholly of lower case characters."} ) effectsmsg( settings, "overlay #{match[2]}" ) end - {% if flag?(:unix) %} - elsif ( cmd =~ /^(system|dxdiag|computer)$/ ) + elsif ( cmd =~ /^(system|dxdiag|computer)$/ ) && ( Crystal::DESCRIPTION =~ /linux/ ) ircipc.send( { "##{settings["channel"]}", "| https://bungmonkey.omgwallhack.org/tmp/DxDiag.txt" } ) - {% end %} elsif ( cmd == "hackerman" ) ircipc.send( { "##{settings["channel"]}", "| https://bungmonkey.omgwallhack.org/img/hackerman.jpg" } ) elsif ( cmd =~ /^(songrequest|sr)$/ ) && match[2]? |