Skip to content

Commit

Permalink
slack prototype finished
Browse files Browse the repository at this point in the history
  • Loading branch information
nothingmn committed Sep 17, 2024
1 parent 7a1bb21 commit 3ce7f31
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Ollabotica/BotServices/SlackBotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
using Microsoft.AspNetCore.Mvc.Diagnostics;
using Microsoft.Extensions.Logging;
using Microsoft.VisualBasic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Ollabotica.ChatServices;
using OllamaSharp;
using Slack.NetStandard.AsyncEnumerable;
using Slack.NetStandard.Interaction;
using Slack.NetStandard.Messages.Blocks;
using Slack.NetStandard.Messages.Elements.RichText;
using Slack.NetStandard.Socket;
using SlackAPI;
Expand Down Expand Up @@ -54,6 +56,7 @@ public async Task StartAsync(BotConfiguration botConfig)

_clientWebSocket = new ClientWebSocket();
var _slackClient = new SocketModeClient();

await _slackClient.ConnectAsync(botConfig.ChatAuthToken);
_slackChatService.Init(_slackClient);

Expand Down
9 changes: 7 additions & 2 deletions Ollabotica/ChatServices/SlackChatService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Slack.NetStandard.AsyncEnumerable;
using Slack.NetStandard.Messages.Blocks;
using Slack.NetStandard.Socket;
using Slack.NetStandard.WebApi.Chat;
using SlackAPI.WebSocketMessages;
using Telegram.Bot;

Expand Down Expand Up @@ -65,12 +66,16 @@ public async Task SendTextMessageAsync(ChatMessage message)
_log.LogInformation("Message Sent: {msg}", msg);
try
{
await client.Send(msg);
await client.Acknowledge(msg);
await client.WebClient.Chat.Post(new PostMessageRequest()
{
Channel = message.ChatId,
Text = message.OutgoingText
});
}
catch (Exception e)
{
Console.WriteLine(e);
}

}
}
11 changes: 6 additions & 5 deletions appsettings.sample.json.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
},
{
"Name": "Lilly",
"TelegramToken": "7242289963:AAEisdfgsdfgsdfgsdfgELr_wFLTgBVLO2ho4",
"ServiceType": "Slack",
"ChatAuthToken": "xapp-.........",
"OllamaUrl": "http://192.168.194.41:3000/ollama/api",
"OllamaToken": "eyJhbGciOisdfhgsdfghsdfghsdfghsdgLTgwYTEtNDllNS05ODMxLWUzNDQ5YmU3YWFmNCJ9.s4hqSnlWGQX46HI3zeW46ZJLUDhhiOJEhPLwPn5MrRs",
"DefaultModel": "lilly",
"AllowedChatIdsRaw": "544445909,107787674540",
"AdminChatIdsRaw": "544445909"
"OllamaToken": "eyJhbGciasdfyhdfygjhgfyhsI6IkpXVCJ9.eyJpZCI6IjRmZjIyOTA2LTgwYTEtNDllNS05ODMxLWUzNDQ5YmU3YWFmNCJ9.s4hqSnlWGQX46HI3zeW46ZJLUDhhiOJEhPLwPn5MrRs",
"DefaultModel": "dev-bot",
"AllowedChatIdsRaw": "U7....",
"AdminChatIdsRaw": "U7...."
}
]
}

0 comments on commit 3ce7f31

Please sign in to comment.