Commit a9899554 authored by Robert Rudman's avatar Robert Rudman

Rename observation room when burn starts

parent 12b5fee0
Pipeline #43339222 failed with stages
in 1 minute and 41 seconds
......@@ -122,23 +122,23 @@ namespace Rodgort.Services
var roomId = observationRooms.FirstOrDefault();
if (roomId == 0)
roomId = await CreateBurnRoom(tag);
roomId = await CreateBurnRoom(metaPostUrl, tag);
else
await RenameObservationRoom(roomId);
await RenameObservationRoom(roomId, metaPostUrl, tag);
var burninationMessage = $"The burnination of [tag:{tag}] has STARTED! [Meta post]({metaPostUrl}). [Burnination progress room](https://chat.stackoverflow.com/rooms/{roomId}).";
await _chatClient.SendMessageAndPin(ChatSite.StackOverflow, ChatRooms.TROGDOR, burninationMessage);
}
private async Task RenameObservationRoom(int roomId)
private async Task RenameObservationRoom(int roomId, string metaPostUrl, string tag)
{
await Task.CompletedTask;
await _chatClient.EditRoom(ChatSite.StackOverflow, roomId, $"Burnination progress for the [{tag}] tag", metaPostUrl);
}
private async Task<int> CreateBurnRoom(string tag)
private async Task<int> CreateBurnRoom(string metaPostUrl, string tag)
{
var roomName = $"Burnination progress for the [{tag}] tag";
var roomId = await _chatClient.CreateRoom(ChatSite.StackOverflow, ChatRooms.SO_BOTICS_WORKSHOP, roomName, string.Empty);
var roomId = await _chatClient.CreateRoom(ChatSite.StackOverflow, ChatRooms.SO_BOTICS_WORKSHOP, roomName, metaPostUrl);
var gemmyMessage = $"@Gemmy start tag [{tag}] {roomId} https://chat.stackoverflow.com/rooms/{roomId}";
......@@ -166,7 +166,7 @@ namespace Rodgort.Services
var tag = tags.First();
var roomName = $"Observation room for [{tag}] burnination";
var roomId = await _chatClient.CreateRoom(ChatSite.StackOverflow, ChatRooms.SO_BOTICS_WORKSHOP, roomName, string.Empty);
var roomId = await _chatClient.CreateRoom(ChatSite.StackOverflow, ChatRooms.SO_BOTICS_WORKSHOP, roomName, metaPostUrl);
await _chatClient.SendMessageAndPin(ChatSite.StackOverflow, roomId, $"[Rodgort tag progress](https://rodgort.sobotics.org/progress?metaQuestionId={metaQuestionId})");
......
......@@ -98,6 +98,26 @@ namespace StackExchangeChat
}, _ => Task.Delay(TimeSpan.FromSeconds(5)));
}
public async Task EditRoom(ChatSite chatSite, int roomId, string roomName, string roomDescription)
{
await ThrottlingUtils.Throttle(ChatThrottleGroups.WebRequestThrottle, async () =>
{
var fkey = (await _siteAuthenticator.GetRoomDetails(chatSite, roomId)).FKey;
await _siteAuthenticator.AuthenticateClient(_httpClient, chatSite);
await _httpClient.PostAsync($"https://{chatSite.ChatDomain}/rooms/save",
new FormUrlEncodedContent(
new Dictionary<string, string>
{
{"fkey", fkey},
{"roomId", roomId.ToString()},
{"name", roomName},
{"description", roomDescription},
{"tags", string.Empty},
}));
});
}
public async Task PinMessage(ChatSite chatSite, int currentRoomId, int messageId)
{
await ThrottlingUtils.Throttle(ChatThrottleGroups.WebRequestThrottle, async () =>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment