Skip to content

Commit 1345803

Browse files
committed
Add dynamic welcome message
1 parent 0c9ce98 commit 1345803

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

.idea/.idea.GolfClapBot/.idea/.name

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/GolfClapBot.Bot/Bot.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,14 @@ public async Task<string> AnalyzeChatMessage(string message, string username)
4646
chat.AppendUserInputWithName(username, message);
4747
return await chat.GetResponseFromChatbotAsync();
4848
}
49+
50+
public Task<string> GetWelcomeMessage(string? version = "1.0.0")
51+
{
52+
var chat = _openAiClient.Chat.CreateConversation();
53+
54+
chat.AppendUserInputWithName("Bapes",
55+
$"Create a message welcoming people to Bapes Twitch Stream. You are GolfClapBot a Twitch Chat Bot for Bapes. Be friendly and informative. You are on version {version} of GolfClapBot. Do not go over 250 characters.+");
56+
57+
return chat.GetResponseFromChatbotAsync();
58+
}
4959
}

src/GolfClapBot.Bot/IBot.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ namespace GolfClapBot.Bot;
33
public interface IBot
44
{
55
Task<string> AnalyzeChatMessage(string message, string username);
6+
7+
Task<string> GetWelcomeMessage(string? version = "1.0.0");
68
}

src/GolfClapBot.Runner/TwitchWorker.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@ private async Task TwitchClientOnMessageReceived(object? sender, OnMessageReceiv
4848
if (string.IsNullOrEmpty(e.ChatMessage.Message))
4949
return;
5050

51-
var b = RemoveEmotes(e.ChatMessage);
51+
var m = RemoveEmotes(e.ChatMessage);
5252

53-
var response = await _bot.AnalyzeChatMessage(e.ChatMessage.Message, e.ChatMessage.Username);
53+
if (string.IsNullOrEmpty(m.Trim()))
54+
return;
55+
56+
var response = await _bot.AnalyzeChatMessage(m, e.ChatMessage.Username);
5457

5558
if (_data.RestrictedPhrases != null && _data.RestrictedPhrases.Exists(
5659
restrictedPhrase =>
@@ -62,10 +65,12 @@ private async Task TwitchClientOnMessageReceived(object? sender, OnMessageReceiv
6265
await SendMessage(response, e.ChatMessage.Username);
6366
}
6467

65-
private Task TwitchClientOnJoinedChannel(object? sender, OnJoinedChannelArgs e)
68+
private async Task<Task> TwitchClientOnJoinedChannel(object? sender, OnJoinedChannelArgs e)
6669
{
67-
return SendMessage(
68-
$"Hello! I'm GolfClapBot, the AI chat bot developed by Bapes. If you're interested in learning more about it, please feel free to message him! v{GetVersion()}");
70+
// return SendMessage(
71+
// $"Hello! I'm GolfClapBot, the AI chat bot developed by Bapes. If you're interested in learning more about it, please feel free to message him! v{GetVersion()}");
72+
73+
return SendMessage(await _bot.GetWelcomeMessage(GetVersion()));
6974
}
7075

7176
private Task TwitchClientOnDisconnected(object? sender, OnDisconnectedEventArgs e)

0 commit comments

Comments
 (0)