allow custom local bot name (#2027)

Co-authored-by: ggurdin <46800240+ggurdin@users.noreply.github.com>
This commit is contained in:
Wilson 2025-03-05 10:13:47 -05:00 committed by GitHub
parent d0a5844483
commit 7d52f58b4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 31 additions and 13 deletions

View file

@ -12,3 +12,6 @@ RC_OFFERING_NAME = 'test'
STRIPE_MANAGEMENT_LINK = 'https://billing.stripe.com/p/login/test_9AQaI8d3O9lmaXe5kk'
SUPPORT_SPACE_ID = '!gqSNSkvwTpgumyjLsV:staging.pangea.chat'
# custom bot name for local bot development
# BOT_NAME="@local-bot:staging.pangea.chat"

View file

@ -16,15 +16,21 @@ class ActivityPlanPageLaunchIconButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
if (controller.room.isBotDM) {
return const SizedBox();
}
return IconButton(
icon: const Icon(Icons.event_note_outlined),
tooltip: L10n.of(context).activityPlannerTitle,
onPressed: () {
controller.stopAudioStream.add(null);
context.go('/rooms/${controller.room.id}/planner');
return FutureBuilder<bool>(
future: controller.room.isBotDM,
builder: (BuildContext context, snapshot) {
final isBotDM = snapshot.data;
if (isBotDM == true || isBotDM == null) {
return const SizedBox();
}
return IconButton(
icon: const Icon(Icons.event_note_outlined),
tooltip: L10n.of(context).activityPlannerTitle,
onPressed: () {
controller.stopAudioStream.add(null);
context.go('/rooms/${controller.room.id}/planner');
},
);
},
);
}

View file

@ -1,7 +1,10 @@
import 'package:fluffychat/pangea/common/config/environment.dart';
class BotName {
static String get byEnvironment =>
Environment.isStaging ? "@bot:staging.pangea.chat" : "@bot:pangea.chat";
static String get byEnvironment => Environment.botName != null
? Environment.botName!
: Environment.isStaging
? "@bot:staging.pangea.chat"
: "@bot:pangea.chat";
static String get localBot => "@matrix-bot-test:staging.pangea.chat";
}

View file

@ -94,4 +94,8 @@ class Environment {
static String get supportUserId {
return isStaging ? '@support:staging.pangea.chat' : '@support:pangea.chat';
}
static String? get botName {
return dotenv.env["BOT_NAME"];
}
}

View file

@ -198,7 +198,7 @@ class PangeaController {
final List<Room> botDMs = [];
for (final room in matrixState.client.rooms) {
if (room.isBotDM) {
if (await room.isBotDM) {
botDMs.add(room);
}
}

View file

@ -41,7 +41,9 @@ extension RoomInformationRoomExtension on Room {
);
}
bool get isBotDM => botOptions?.mode == BotMode.directChat;
Future<bool> get isBotDM async {
return botOptions?.mode == BotMode.directChat && await botIsInRoom;
}
bool isAnalyticsRoomOfUser(String userId) =>
isAnalyticsRoom && isMadeByUser(userId);