Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ChannelSurfCli/Utils/Channels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public class Channels
channelId = "";
}

if ((bool)obj.SelectToken("is_archived"))
{
Console.WriteLine("Skipping archived slack channel: {0}", obj["name"].ToString());
continue;
}

slackChannels.Add(new Models.Slack.Channels()
{
channelId = channelId,
Expand Down
13 changes: 10 additions & 3 deletions ChannelSurfCli/Utils/Messages.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace ChannelSurfCli.Utils
{
Expand Down Expand Up @@ -54,10 +55,10 @@ public static void ScanMessagesByChannel(List<Models.Combined.ChannelsMapping> c

// deal with message basics: when, body, who

var messageTs = (string)obj.SelectToken("ts");
var messageTs = new DateTime(1970, 1, 1, 0, 0, 0).AddSeconds(Double.Parse((string)obj.SelectToken("ts")));
var messageText = (string)obj.SelectToken("text");
var messageId = channelsMapping.slackChannelId + "." + messageTs;
//messageText = RegexDetector.DetectSlackParens(messageText, slackUserList);
messageText = DetectSlackParens(messageText, slackUserList);
var messageSender = Utils.Messages.FindMessageSender(obj, slackUserList);

// create a list of attachments to upload
Expand Down Expand Up @@ -170,7 +171,7 @@ public static void ScanMessagesByChannel(List<Models.Combined.ChannelsMapping> c
{
id = messageId,
text = messageText,
ts = messageTs,
ts = messageTs.ToLocalTime().ToString(),
user = messageSender,
fileAttachment = fileAttachment,
attachments = attachmentsList,
Expand Down Expand Up @@ -358,6 +359,12 @@ public static string MessageToHtml(ViewModels.SimpleMessage simpleMessage, Model
return w;
}

static string DetectSlackParens(string messageText, List<ViewModels.SimpleUser> slackUserList)
{
return Regex.Replace(messageText, @"<@(\w+)>",
m => slackUserList.Where(w => w.userId == m.Groups[1].Value)
.DefaultIfEmpty(new ViewModels.SimpleUser() { name = m.Value }).First().name);
}

static string FindMessageSender(JObject obj, List<ViewModels.SimpleUser> slackUserList)
{
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Either way, you'll need to decide if you want to:
* Re-create Slack channels

You can create a Slack Team export on a self-service basis as a Slack Team Owner or Admin at this page [https://my.slack.com/services/export](https://my.slack.com/services/export). Download the export file and tell Channel Surf its location. We'll scan it and re-create the Slack channel structure in Teams - and give you the option to do more.

WARNING: Slack channels can be public or private - a concept not currently supported in Microsoft Teams. This import tool will re-create all Slack channels in MS Teams, irrespective of whether they were public or private in Slack. Want that to change? Go ahead and [file an issue](https://github.com/tamhinsf/ChannelSurf/issues).

* Archive Slack message history (optional)

Expand Down