Skip to content

Instantly share code, notes, and snippets.

@jen20
Created June 9, 2014 17:23
Show Gist options
  • Save jen20/9518774c99e3fe022f5e to your computer and use it in GitHub Desktop.
Save jen20/9518774c99e3fe022f5e to your computer and use it in GitHub Desktop.
Necessary patches to make skype-log-viewer export in the format for import into SlackHQ. This is obviously the worst code ever and the worst method of distributing it ever, but meh, works until I have more time to turn it into a proper command line utility. GPL I guess (since the upstream is).
using System;
namespace SkypeLogViewerLGG
{
public static class DateTimeExtensions
{
public static long ToUnixTimestamp(this DateTime target)
{
var date = new DateTime(1970, 1, 1, 0, 0, 0, target.Kind);
var unixTimestamp = Convert.ToInt64((target - date).TotalSeconds);
return unixTimestamp;
}
}
}
diff -r b9fd81bbdcff SkypeLogViewerLGG/MainWindowForm.cs
--- a/SkypeLogViewerLGG/MainWindowForm.cs Mon May 26 14:15:12 2014 -0500
+++ b/SkypeLogViewerLGG/MainWindowForm.cs Mon Jun 09 18:20:51 2014 +0100
@@ -376,22 +376,26 @@
}
}
- public String formatMessage(SkypeMessage message, String messageFormat = "[[Month]/[Day]/[Year] [Time]] [DisplayName]:")
+ public String formatMessage(SkypeMessage message, string conversationName, String messageFormat = "[[Month]/[Day]/[Year] [Time]] [DisplayName]:")
{
+ var sanitizedData = message.msgData.Replace(Environment.NewLine, "").Replace("\n", "");
+
+ return string.Format("{0},{1},{2},{3}", message.msgDate.ToUnixTimestamp(), conversationName, message.sender,
+ sanitizedData);
- messageFormat = messageFormat.Replace("[Day]", message.msgDate.Day.ToString());
- messageFormat = messageFormat.Replace("[Month]", message.msgDate.Month.ToString());
- messageFormat = messageFormat.Replace("[Year]", message.msgDate.Year.ToString());
+ //messageFormat = messageFormat.Replace("[Day]", message.msgDate.Day.ToString());
+ //messageFormat = messageFormat.Replace("[Month]", message.msgDate.Month.ToString());
+ //messageFormat = messageFormat.Replace("[Year]", message.msgDate.Year.ToString());
- messageFormat = messageFormat.Replace("[Time]", message.msgDate.ToString("h:mm:ss tt"));
+ //messageFormat = messageFormat.Replace("[Time]", message.msgDate.ToString("h:mm:ss tt"));
- messageFormat = messageFormat.Replace("[DisplayName]", message.sender);
- messageFormat = messageFormat.Replace("[UserName]", message.senderID);
+ //messageFormat = messageFormat.Replace("[DisplayName]", message.sender);
+ //messageFormat = messageFormat.Replace("[UserName]", message.senderID);
- messageFormat += " " + message.msgData;
+ //messageFormat += " " + message.msgData;
- return messageFormat;
+ //return messageFormat;
}
private void exportConversation(Conversation c, String directory)
@@ -405,8 +409,7 @@
{
foreach (SkypeMessage message in messages)
{
- String format = (Properties.Settings.Default.Format != "") ? Properties.Settings.Default.Format : "[[Month]/[Day]/[Year] [Time]] [DisplayName]:";
- file.WriteLine(this.formatMessage(message,format));
+ file.WriteLine(this.formatMessage(message, c.DisplayName));
}
}
}
diff -r b9fd81bbdcff SkypeLogViewerLGG/SkypeLogViewerLGG.csproj
--- a/SkypeLogViewerLGG/SkypeLogViewerLGG.csproj Mon May 26 14:15:12 2014 -0500
+++ b/SkypeLogViewerLGG/SkypeLogViewerLGG.csproj Mon Jun 09 18:20:51 2014 +0100
@@ -67,6 +67,7 @@
<Compile Include="AboutForm.Designer.cs">
<DependentUpon>AboutForm.cs</DependentUpon>
</Compile>
+ <Compile Include="DateTimeExtensions.cs" />
<Compile Include="HelpForm.cs">
<SubType>Form</SubType>
</Compile>
@@ -121,7 +122,6 @@
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
- <None Include="SkypeLogViewerLGG_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\SkypeLogLGG.png" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment