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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,4 @@ paket-files/
# JetBrains Rider
.idea/
*.sln.iml
src/DynaSlack/keys.xml
Binary file added DynaSlack launch.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/.vs/DynaSlack/v15/.suo
Binary file not shown.
5 changes: 3 additions & 2 deletions src/DebugApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Slack.Client;
using Slack;

/// <summary>
Expand All @@ -13,11 +14,11 @@ private static void Main(string[] args)
{
// build a new Webhook object
var webhook = new Webhook(
"https://hooks.slack.com/services/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 ",
"https://hooks.slack.com/services/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",
"apitestground");

// build a new Slack client object
var slackClient = new Slack.Client();
var slackClient = new SlackClient();
slackClient.webhook = webhook;

// read a line from the console
Expand Down
Binary file removed src/DebugApp/bin/Release/DebugApp.exe
Binary file not shown.
6 changes: 0 additions & 6 deletions src/DebugApp/bin/Release/DebugApp.exe.config

This file was deleted.

Binary file removed src/DebugApp/bin/Release/DebugApp.pdb
Binary file not shown.
Binary file removed src/DebugApp/bin/Release/DynaSlack.dll
Binary file not shown.
Binary file removed src/DebugApp/bin/Release/DynaSlack.pdb
Binary file not shown.
Binary file removed src/DebugApp/bin/Release/Newtonsoft.Json.dll
Binary file not shown.
9,112 changes: 0 additions & 9,112 deletions src/DebugApp/bin/Release/Newtonsoft.Json.xml

This file was deleted.

Binary file removed src/DebugApp/obj/Release/DebugApp.exe
Binary file not shown.
Binary file removed src/DebugApp/obj/Release/DebugApp.pdb
Binary file not shown.

This file was deleted.

Binary file not shown.
2 changes: 1 addition & 1 deletion src/DynaSlack.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26014.0
VisualStudioVersion = 15.0.26430.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DynaSlack", "DynaSlack\DynaSlack.csproj", "{1A8FF892-E81A-4261-AAA0-43713D980C26}"
EndProject
Expand Down
21 changes: 14 additions & 7 deletions src/DynaSlack/DynaSlack.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch>
None
Expand Down Expand Up @@ -32,7 +32,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DynaSlack</RootNamespace>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down Expand Up @@ -99,6 +99,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Helpers\Helpers.Web.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
Expand All @@ -109,9 +110,16 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Web\Helpers.cs" />
<Compile Include="Slack\SlackClasses.cs" />
<Compile Include="Slack\SlackClient.cs" />
<Compile Include="Slack\Client\Authentication.cs" />
<Compile Include="Slack\Requests\SlackPayload.cs" />
<Compile Include="Slack\Classes\Message.cs" />
<Compile Include="Slack\Classes\Bot.cs" />
<Compile Include="Slack\Classes\Attachment.cs" />
<Compile Include="Slack\Classes\Webhook.cs" />
<Compile Include="Slack\Requests\SlackRequest.cs" />
<Compile Include="Slack\Requests\SlackResponse.cs" />
<Compile Include="Slack\Classes\Field.cs" />
<Compile Include="Slack\Client\SlackClient.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -144,8 +152,7 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="AfterClean">
<!-- Remove build folders -->
Expand Down
47 changes: 47 additions & 0 deletions src/DynaSlack/Helpers/Helpers.Web.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Collections.Specialized;
using Slack;
using RestSharp;

namespace Slack.Helpers
{
/// <summary>
/// Utility functions that are used for validation and other auxiliary tasks, during interactions with the Web
/// </summary>
internal static class Web
{
/// <summary>Check the URI is valid</summary>
/// <param name="uriToCheck">The URI to check</param>
/// <returns>True if is valid, False otherwise</returns>
public static Boolean checkURI(Uri uriToCheck)
{
if (uriToCheck.IsFile || uriToCheck.IsUnc)
{
throw new Exception("URI is file or is UNC pointing to internal network");
}
if (!Uri.CheckSchemeName(uriToCheck.Scheme))
return false;

return true;
}

internal static Boolean ServerReturnedSuccessfulResponse(IRestResponse response)
{
if (response.Request.Method == RestSharp.Method.GET)
{
if (response.StatusCode != HttpStatusCode.OK)
return false;
}
else
{
if ((int)response.StatusCode >= 300)
return false;
}
return true;
}
}

}
4 changes: 2 additions & 2 deletions src/DynaSlack/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2017.1.3.6")]
[assembly: AssemblyFileVersion("2017.1.3.6")]
[assembly: AssemblyVersion("2017.2.0.0")]
[assembly: AssemblyFileVersion("2017.2.0.0")]
[assembly: NeutralResourcesLanguage("en-GB")]

2 changes: 1 addition & 1 deletion src/DynaSlack/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions src/DynaSlack/Slack/Classes/Attachment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;

/// <summary>
/// The below classes follow the Slack API structure, see https://api.slack.com/docs/
/// </summary>
namespace Slack
{
/// <summary>
/// Represents attachments in Slack messages, which are used to send richly formatted messages.
/// </summary>
class Attachment
{
string fallback { get; set; }
string color { get; set; }
string pretext { get; set; }
string author_name { get; set; }
string author_link { get; set; }
string author_icon { get; set; }
string title { get; set; }
string title_link { get; set; }
string text { get; set; }
string image_url { get; set; }
string thumb_url { get; set; }
string footer { get; set; }
string footer_icon { get; set; }
DateTime ts { get; set; }
List<Field> fields { get; set; }

/// <summary>
/// Create a Slack message attachment, which are used to send richly formatted messages.
/// </summary>
public Attachment(string title=null, string title_link=null, string text=null, string color = null, string image_url = null)
{
if (title != null) this.title = title;
if (title_link != null) this.title_link = title_link;
if (text != null) this.text = text;
if (color != null) this.color = color;
if (image_url != null) this.image_url = image_url;
}
}
}
20 changes: 20 additions & 0 deletions src/DynaSlack/Slack/Classes/Bot.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;

/// <summary>
/// The below classes follow the Slack API structure, see https://api.slack.com/docs/
/// </summary>
namespace Slack
{
/// <summary>
/// Class represents a Bot object in Slack.
/// </summary>
public class Bot
{
public string bot_user_id { get; set; }
public string bot_access_token { get; set; }
public string bot_name { get; set; }
}

}
19 changes: 19 additions & 0 deletions src/DynaSlack/Slack/Classes/Field.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;

/// <summary>
/// The below classes follow the Slack API structure, see https://api.slack.com/docs/
/// </summary>
namespace Slack
{
/// <summary>
/// Represents individual fields which form attachments in Slack messages.
/// </summary>
class Field
{
public string title { get; set; }
public string value { get; set; }
public bool @short { get; set; }
}
}
58 changes: 58 additions & 0 deletions src/DynaSlack/Slack/Classes/Message.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
using System;
using Newtonsoft.Json;
using Slack.Client;

/// <summary>
/// The below classes follow the Slack API structure, see https://api.slack.com/docs/
/// </summary>
namespace Slack
{
/// <summary>
/// Class represents a Slack message.
/// </summary>
class Message
{
public string text { get; set; }
public Attachment attachment { get; set; }

/// <summary>
/// Construct a Slack message given a text and an optional attachment
/// </summary>
/// <param name="Text">The text to be sent as a Slack message</param>
public Message(string Text)
{
if (!String.IsNullOrEmpty(Text) && !String.IsNullOrWhiteSpace(Text)) this.text = Text;
}

/// <summary>
/// Serializes the Slack message to JSON
/// </summary>
/// <returns></returns>
public string ToJSON()
{
return JsonConvert.SerializeObject(this);
}

/// <summary>
/// Posts the message to Slack on behalf of the Slack Client's user. Requires a valid OAuth token in Client.
/// </summary>
/// <returns></returns>
public string Post(SlackClient slackClient)
{
string response = null;

try
{
if (slackClient == null) throw new Exception("A valid Slack client needs to be supplied.");

// TODO : implement message posting factory
}
catch (Exception ex)
{
return ex.Message;
}

return response;
}
}
}
Loading