summaryrefslogtreecommitdiff
path: root/crystal/bungmobott.cr
diff options
context:
space:
mode:
Diffstat (limited to 'crystal/bungmobott.cr')
-rwxr-xr-xcrystal/bungmobott.cr36
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]?