summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcrystal/bungmobott.cr68
1 files changed, 44 insertions, 24 deletions
diff --git a/crystal/bungmobott.cr b/crystal/bungmobott.cr
index aad49b9..34c2328 100755
--- a/crystal/bungmobott.cr
+++ b/crystal/bungmobott.cr
@@ -68,11 +68,11 @@ else
aws = true
end
-# enable explosions?
-explosions = Hash( String, String ).new
-if File.exists?( settings["configdir"] + "/explosionlist.txt" )
- File.each_line( settings["configdir"] + "/explosionlist.txt" ) do |line|
- explosions[ line.downcase ] = line
+# enable effects?
+effects = Hash( String, String ).new
+if File.exists?( settings["configdir"] + "/effects.txt" )
+ File.each_line( settings["configdir"] + "/effects.txt" ) do |line|
+ effects[ line.downcase ] = line
end
end
@@ -133,6 +133,8 @@ spawn do
when "MediaInputPlaybackEnded"
if d["eventData"]["inputName"].as_s =~ /^media-temporary-/
obs.reqchan.send( { nil, OBSWebSocket.req( "RemoveInput", UUID.random.to_s, JSON.parse({ "inputName" => d["eventData"]["inputName"].as_s }.to_json) ) } )
+ elsif d["eventData"]["inputName"].as_s =~ /^media-/
+ obs.scenes.current.metascene[d["eventData"]["inputName"].as_s][0].disable!
end
when "SceneItemEnableStateChanged"
edata = d["eventData"]
@@ -196,7 +198,7 @@ spawn do
end
def obstemporarymediacreate( obs : OBSWebSocket::Server, sname : String, iname, path : String )
- iname = "media-temporary-explosion-#{iname}"
+ iname = "media-temporary-effect-#{iname}"
isettings = Hash( String, String | Bool | Int64 | Float64 ){
"advanced" => true,
"clear_on_media_end" => true,
@@ -584,18 +586,23 @@ loop do
vip = ( message.tags["badges"].to_s.matches?( /(^|,)vip\// ) )
mod = ( message.tags["mod"] == "1" )
sub = ( message.tags["subscriber"] == "1" )
- # bungmoBoom
- # message.tags["emotes"] =~ /^322820/
- bungmobooms = Array( String ).new
- if ( message.tags["emotes"]? ) &&
- ( message.tags["emotes"] ) &&
- ( bungmobooms = message.tags["emotes"].not_nil!.split("/").select( /^322820[:_]/ ).join(",").split(",") ) &&
- ( ! bungmobooms[0].empty? ) &&
- ( explosions.size > 0 )
- explosions.values.sample( bungmobooms.size ).each do | explosion |
- obstemporarymediacreate( obs, "meta-foreground", explosion, "C:/cygwin64/home/user/effects/explosions/#{explosion}.webm" )
+ [ { 301501910, "farts" },
+ { 322820, "explosions" } ].each do | fx |
+ emoteid = fx[0]
+ fxname = fx[1]
+ if ( message.tags["emotes"]? ) &&
+ ( message.tags["emotes"] ) &&
+ ( fxemotes = message.tags["emotes"].not_nil!.split("/").select( /^#{emoteid}[:_]/ ).join(",").split(",") ) &&
+ ( ! fxemotes[0].empty? ) &&
+ ( effects.values.select(/^#{fxname}/).size > 0 )
+ effects.values.select(/^#{fxname}/).sample( fxemotes.size ).each do | filepath |
+ obstemporarymediacreate( obs, "meta-foreground", filepath.gsub(/[\/ ]/, '_').downcase, "C:/cygwin64/home/user/effects/#{filepath}" )
+ end
end
end
+ if ( message.params[1] =~ /thanks.*obama/i )
+ obs.scenes["meta-foreground"]["media-youdied-thanksobama"].enable!
+ end
next unless ( ( match = message.params[1].match(/^ *!([A-Za-z]+) (([a-zA-Z0-9= _\:,.&'\/?;\\\(\)\[\]+\-]|!)+)/) || message.params[1].match(/^ *!([A-Za-z]+)/) ) )
cmd = match[1]
if ( ( cmd =~ /^(substitute|voicesub)$/ ) && ( mod || sub ) )
@@ -688,7 +695,7 @@ loop do
elsif ( ( cmd =~ /^source(|s)$/ ) && ( mod || own || vip ) )
request = Hash( String, String | Bool ).new
if ( match[2]? && match[2] =~ /^[a-zA-Z0-9-_]+$/ )
- obs.scenes.current.metascene[match[2]].toggle!
+ obs.scenes.current.metascene[match[2]][0].toggle!
# in studio mode, direct Scene->SceneItem toggles require a transition
obs.scenes.current.preview!
obs.transition!
@@ -704,22 +711,35 @@ loop do
ircipc.send( { "##{settings["channel"]}", "Must provide at least one source name as argument, and optionally one filter name to toggle on or off." } )
end
elsif ( cmd == "create" && ( mod || own || vip ) )
- if ( match[2]? ) && ( match[2] =~ /^([a-zA-Z0-9-_]+)/ )
- obstemporarymediacreate( obs, "meta-foreground", match[2], "C:/cygwin64/home/user/effects/explosions/#{match[2]}.webm" )
+ if ( match[2]? ) && ( match[2] =~ /^([\/a-zA-Z0-9-_]+)/ )
+ obstemporarymediacreate( obs, "meta-foreground", match[2], "C:/cygwin64/home/user/effects/#{match[2]}.webm" )
else
ircipc.send( { "##{settings["channel"]}", "Must provide at least one source name as argument." } )
end
elsif ( cmd =~ /^(metaminute|youdied)$/ )
- obs.scenes.current.metascene["media-#{cmd}"].enable!
- elsif ( cmd =~ /^explosion$/ ) && ( sub || mod || own || vip )
- if explosions
+ obs.scenes.current.metascene["media-#{cmd}"][0].enable!
+ elsif ( cmd =~ /^fart(s|)$/ ) && ( sub || mod || own || vip )
+ if effects.values.select( /^farts/ ).size > 0
+ if ( match[2]? ) && ( match[2].match( /^([0-9]+)/ ) && ( match[2].to_i > 1 ) && ( match[2].to_i <= 32 ) )
+ count = match[2].to_i
+ else
+ count = 1
+ end
+ effects.values.select( /^farts/ ).sample( count ).each do | effect |
+ obstemporarymediacreate( obs, "meta-foreground", effect.gsub(/[\/ ]/, '_').downcase, "C:/cygwin64/home/user/effects/#{effect}" )
+ end
+ else
+ puts "farts undefined"
+ end
+ elsif ( cmd =~ /^explosion(s|)$/ ) && ( sub || mod || own || vip )
+ if effects.values.select( /^explosions/ ).size > 0
if ( match[2]? ) && ( match[2].match( /^([0-9]+)/ ) && ( match[2].to_i > 1 ) && ( match[2].to_i <= 32 ) )
count = match[2].to_i
else
count = 1
end
- explosions.values.sample( count ).each do | explosion |
- obstemporarymediacreate( obs, "meta-foreground", explosion, "C:/cygwin64/home/user/effects/explosions/#{explosion}.webm" )
+ effects.values.select( /^explosions/ ).sample( count ).each do | effect |
+ obstemporarymediacreate( obs, "meta-foreground", effect.gsub(/[\/ ]/, '_').downcase, "C:/cygwin64/home/user/effects/#{effect}" )
end
else
puts "explosions undefined"