@@ -29,6 +29,12 @@ func (robo *Robot) tmiMessage(ctx context.Context, send chan<- *tmi.Message, msg
29
29
// channel that isn't configured. Ignore it.
30
30
return
31
31
}
32
+ room , _ := msg .Tag ("room-id" )
33
+ source , ok := msg .Tag ("source-room-id" )
34
+ // TODO(zeph): This prevents commands from any shared chat, even if the bot
35
+ // isn't in the source room. We should still allow commands from shared
36
+ // chats that we aren't in.
37
+ shared := ok && room != source
32
38
m := message .FromTMI (msg )
33
39
log := slog .With (slog .String ("trace" , m .ID ), slog .String ("in" , ch .Name ))
34
40
log .InfoContext (ctx , "privmsg" , slog .Duration ("bias" , time .Since (m .Time ())))
@@ -42,6 +48,10 @@ func (robo *Robot) tmiMessage(ctx context.Context, send chan<- *tmi.Message, msg
42
48
return
43
49
}
44
50
if cmd , ok := parseCommand (robo .tmi .name , m .Text ); ok {
51
+ if shared {
52
+ log .InfoContext (ctx , "ignore shared chat command" )
53
+ return
54
+ }
45
55
robo .command (ctx , log , ch , m , cmd )
46
56
return
47
57
}
@@ -100,6 +110,11 @@ func (robo *Robot) tmiMessage(ctx context.Context, send chan<- *tmi.Message, msg
100
110
log .ErrorContext (ctx , "failed copypasta check" , slog .Any ("err" , err ))
101
111
// Continue on.
102
112
}
113
+ // If this is a shared chat, we don't want to respond unprompted, so that
114
+ // we don't get double probability if we're in multiple shared chats.
115
+ if shared {
116
+ return
117
+ }
103
118
if rand .Float64 () > ch .Responses {
104
119
return
105
120
}
0 commit comments