summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crystal/bungmobott.cr37
1 files changed, 29 insertions, 8 deletions
diff --git a/crystal/bungmobott.cr b/crystal/bungmobott.cr
index 5c21a74..67d5c9e 100644
--- a/crystal/bungmobott.cr
+++ b/crystal/bungmobott.cr
@@ -52,9 +52,9 @@ end
macro say( service, channel, text )
case {{service}}
when "twitch"
- send_and_log( twitchircifc, { "#" + {{channel}}, {{text}} } )
+ send_and_log( twitchircifc, { {{channel}}, {{text}} } )
when "gamesurge"
- send_and_log( gamesurgeircifc, { "#" + {{channel}}, {{text}} } )
+ send_and_log( gamesurgeircifc, { {{channel}}, {{text}} } )
when "twitch_remote"
send_and_log( bbscliifc, "say twitch " + {{text}} )
when "gamesurge_remote"
@@ -65,13 +65,13 @@ end
# Say() in all available primary channels
macro say_all_self_chan( text )
if fibers["Twitch::IRC"]?
- say( "twitch", config.chat_user.not_nil!.twitch.not_nil!, {{text}} )
+ say( "twitch", "#" + config.chat_user.not_nil!.twitch.not_nil!, {{text}} )
elsif fibers["BungmoBott::Socket client"]? &&
say( "twitch_remote", config.chat_user.not_nil!.twitch.not_nil!, {{text}} )
end
# FIXME: Maybe use config.join_channels.gamesurge[0]? think about this later
if fibers["GameSurge::IRC"]?
- say( "gamesurge", config.chat_user.not_nil!.gamesurge.not_nil!, {{text}} )
+ say( "gamesurge", "#" + config.chat_user.not_nil!.gamesurge.not_nil!, {{text}} )
elsif fibers["BungmoBott::Socket client"]?
say( "gamesurge_remote", config.chat_user.not_nil!.gamesurge.not_nil!, {{text}} )
end
@@ -843,7 +843,7 @@ spawn name: "command_dispatch" do
if service =~ /^twitch/
if ( exec.func == "detect_rename" && uid.is_a?( UInt64 ) )
if oldname.is_a?( String )
- say( service, config.chat_user.not_nil!.twitch.not_nil!, "Rename detected: #{uid}: #{oldname} -> #{chatuser}" )
+ say( service, "#" + config.chat_user.not_nil!.twitch.not_nil!, "Rename detected: #{uid}: #{oldname} -> #{chatuser}" )
end
next
end
@@ -977,7 +977,7 @@ spawn name: "command_dispatch" do
if ( exec.func == "tts_voice_get" )
puts "Exec-ing tts_voice_get"
namesub, voice_setting, voice_output = getvoice( config.voice_list.not_nil!, userdir, chatuser )
- say( service, config.chat_user.not_nil!.twitch.not_nil!, "| Current voice is #{voice_setting}" )
+ say( service, ircchannel, "| Current voice is #{voice_setting}" )
next
end
if ( exec.func == "tts_voice_set" )
@@ -1035,8 +1035,26 @@ spawn name: "command_dispatch" do
next
end
end
+ if ( exec.func == "urban" )
+ puts "Exec-ing Urban dictionary lookup"
+ if ( match = / ([a-zA-Z0-9 -]+)/.match( message.params[1] ) )
+ pp match
+ definition = urbandef( match[1] )
+ say( service, ircchannel, definition[0,400] )
+ if text2speech # hardcode this section for now; maybe process outgoing messages at some point
+ if ( t2sreturn = t2s( t2sifc, config, userdir, chatuser, definition[0,400]) )
+ lastvoice.insert( 0, t2sreturn.strip )
+ lastvoice = lastvoice[0..4]
+ end
+ end
+ else
+ say( service, ircchannel, "| Urban Dictionary search term should consist of letters, numbers, spaces, and/or hyphens." )
+ end
+ next
+ end
+
if ( exec.func == "say" )
- say( service, config.chat_user.not_nil!.twitch.not_nil!, exec.arg.not_nil![0].not_nil! )
+ say( service, ircchannel, exec.arg.not_nil![0].not_nil! )
next
end
if ( exec.func == "run" )
@@ -1332,6 +1350,7 @@ if twitchclient.is_a?( Twitcr::Client )
begin
while twitchtuple = twitchapiifc.receive
puts( "#{Fiber.current.name}: #{twitchtuple}" )
+ # How does this return to the requester? Routed through the main thread with a nonce, or directly via a Channel( string )
cmd, arg = [ *twitchtuple ]
case cmd
when "get_user"
@@ -1734,7 +1753,7 @@ if config.bungmobott_listen
client.puts "ERROR: gcloud_token missing, gcs commands disabled."
end
elsif ( match = message.match( /^say (twitch|gamesurge) (.+)/i ) )
- say( match[1], connections[client]["user"], match[2] )
+ say( match[1], "#" + connections[client]["user"], match[2] )
elsif ( message =~ /^twitchapi/i)
if ( twitchapi )
if ( match = message.match( /^twitchapigetuser id:(\d+)/i ) )
@@ -1742,6 +1761,8 @@ if config.bungmobott_listen
elsif ( match = message.match( /^twitchapigetuser name:(\w+)/i ) )
send_and_log( twitchapiifc, { "get_user", match[1] } )
end
+ else
+ client.puts "ERROR: twitch api unavailable."
end
elsif ( message =~ /testchannelsubs/ )
#commandifc.send( "testchannelsubs" )