Skip to content
Closed
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
4 changes: 2 additions & 2 deletions SlackAPI.Tests/SlackAPI.Tests.NetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<TargetFrameworks>net452;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>net452;netcoreapp1.0;netcoreapp2.0</TargetFrameworks>
<AssemblyName>SlackAPI.Tests</AssemblyName>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
Expand All @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<PackageReference Include="Microsoft.NETCore.Platforms" Version="1.1.0" />
Expand Down
3 changes: 2 additions & 1 deletion SlackAPI.Tests/Users.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public void UserList()
Assert.True(actual.ok, "Error while fetching user list.");
Assert.True(actual.members.Any());

var someMember = actual.members.First();
// apparently deleted users do indeed have null values, so if the first user returned is deleted then there are failures.
var someMember = actual.members.Where(x => !x.deleted).First();
Assert.NotNull(someMember.id);
Assert.NotNull(someMember.color);
Assert.NotNull(someMember.real_name);
Expand Down
15 changes: 15 additions & 0 deletions SlackAPI/RPCMessages/PostEphemeralResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlackAPI.RPCMessages
{
[RequestPath("chat.postEphemeral")]
public class PostEphemeralResponse : Response
{
public string message_ts;
public string channel;
}
}
9 changes: 8 additions & 1 deletion SlackAPI/SlackAPI.NetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<VersionPrefix>1.0.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<Authors>Inumedia</Authors>
<TargetFrameworks>net45;netstandard1.6;netstandard1.3</TargetFrameworks>
<TargetFrameworks>netcoreapp2.0;net45;netstandard1.6;netstandard1.3</TargetFrameworks>
<AssemblyName>SlackAPI</AssemblyName>
<PackageProjectUrl>https://github.com/Inumedia/SlackAPI</PackageProjectUrl>
<PackageLicenseUrl>http://choosealicense.com/licenses/mit/</PackageLicenseUrl>
Expand All @@ -25,6 +25,10 @@
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="System.Net.Http" Version="4.3.1" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp2.0' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
Expand All @@ -46,4 +50,7 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net45|AnyCPU'">
<DefineConstants>TRACE;DEBUG;NET45</DefineConstants>
</PropertyGroup>
</Project>
36 changes: 36 additions & 0 deletions SlackAPI/SlackClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,42 @@ public void PostMessage(
APIRequestWithToken(callback, parameters.ToArray());
}

public void PostEphemeralMessage(
Action<PostEphemeralResponse> callback,
string channelId,
string text,
string targetuser,
string parse = null,
bool linkNames = false,
Attachment[] attachments = null,
bool as_user = false,
string thread_ts = null)
{
List<Tuple<string,string>> parameters = new List<Tuple<string,string>>();

parameters.Add(new Tuple<string,string>("channel", channelId));
parameters.Add(new Tuple<string,string>("text", text));
parameters.Add(new Tuple<string,string>("user", targetuser));

if (!string.IsNullOrEmpty(parse))
parameters.Add(new Tuple<string, string>("parse", parse));

if (linkNames)
parameters.Add(new Tuple<string, string>("link_names", "1"));

if (attachments != null && attachments.Length > 0)
parameters.Add(new Tuple<string, string>("attachments",
JsonConvert.SerializeObject(attachments, Formatting.None,
new JsonSerializerSettings // Shouldn't include a not set property
{
NullValueHandling = NullValueHandling.Ignore
})));

parameters.Add(new Tuple<string, string>("as_user", as_user.ToString()));

APIRequestWithToken(callback, parameters.ToArray());
}


public void AddReaction(
Action<ReactionAddedResponse> callback,
Expand Down
5 changes: 4 additions & 1 deletion SlackAPI/SlackSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ public class SlackSocket
static SlackSocket()
{
routing = new Dictionary<string, Dictionary<string, Type>>();
#if NET45

#if NETCOREAPP2_0
var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GlobalAssemblyCache == false);
#elif NET45
var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.GlobalAssemblyCache == false);
#elif NETSTANDARD1_6
var assemblies = DependencyContext.Default.GetDefaultAssemblyNames().Select(Assembly.Load);
Expand Down
3 changes: 3 additions & 0 deletions SlackAPI/WebSocketMessages/NewMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public class NewMessage : SlackSocketMessage
public string team;
public DateTime ts;
public DateTime thread_ts;
public string username;
public string bot_id;
public UserProfile icons;

public NewMessage()
{
Expand Down