init
This commit is contained in:
302
.gitignore
vendored
Normal file
302
.gitignore
vendored
Normal file
@@ -0,0 +1,302 @@
|
|||||||
|
## Ignore Visual Studio temporary files, build results, and
|
||||||
|
## files generated by popular Visual Studio add-ons.
|
||||||
|
##
|
||||||
|
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||||
|
|
||||||
|
# User-specific files
|
||||||
|
*.suo
|
||||||
|
*.user
|
||||||
|
*.userosscache
|
||||||
|
*.sln.docstates
|
||||||
|
|
||||||
|
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||||
|
*.userprefs
|
||||||
|
|
||||||
|
# Build results
|
||||||
|
[Dd]ebug/
|
||||||
|
[Dd]ebugPublic/
|
||||||
|
[Rr]elease/
|
||||||
|
[Rr]eleases/
|
||||||
|
x64/
|
||||||
|
x86/
|
||||||
|
bld/
|
||||||
|
[Bb]in/
|
||||||
|
[Oo]bj/
|
||||||
|
[Ll]og/
|
||||||
|
|
||||||
|
# Visual Studio 2015 cache/options directory
|
||||||
|
.vs/
|
||||||
|
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||||
|
#wwwroot/
|
||||||
|
|
||||||
|
# MSTest test Results
|
||||||
|
[Tt]est[Rr]esult*/
|
||||||
|
[Bb]uild[Ll]og.*
|
||||||
|
|
||||||
|
# NUNIT
|
||||||
|
*.VisualState.xml
|
||||||
|
TestResult.xml
|
||||||
|
|
||||||
|
# Build Results of an ATL Project
|
||||||
|
[Dd]ebugPS/
|
||||||
|
[Rr]eleasePS/
|
||||||
|
dlldata.c
|
||||||
|
|
||||||
|
# Benchmark Results
|
||||||
|
BenchmarkDotNet.Artifacts/
|
||||||
|
|
||||||
|
# .NET Core
|
||||||
|
project.lock.json
|
||||||
|
project.fragment.lock.json
|
||||||
|
artifacts/
|
||||||
|
**/Properties/launchSettings.json
|
||||||
|
|
||||||
|
*_i.c
|
||||||
|
*_p.c
|
||||||
|
*_i.h
|
||||||
|
*.ilk
|
||||||
|
*.meta
|
||||||
|
*.obj
|
||||||
|
*.pch
|
||||||
|
*.pdb
|
||||||
|
*.pgc
|
||||||
|
*.pgd
|
||||||
|
*.rsp
|
||||||
|
*.sbr
|
||||||
|
*.tlb
|
||||||
|
*.tli
|
||||||
|
*.tlh
|
||||||
|
*.tmp
|
||||||
|
*.tmp_proj
|
||||||
|
*.log
|
||||||
|
*.vspscc
|
||||||
|
*.vssscc
|
||||||
|
.builds
|
||||||
|
*.pidb
|
||||||
|
*.svclog
|
||||||
|
*.scc
|
||||||
|
|
||||||
|
# Chutzpah Test files
|
||||||
|
_Chutzpah*
|
||||||
|
|
||||||
|
# Visual C++ cache files
|
||||||
|
ipch/
|
||||||
|
*.aps
|
||||||
|
*.ncb
|
||||||
|
*.opendb
|
||||||
|
*.opensdf
|
||||||
|
*.sdf
|
||||||
|
*.cachefile
|
||||||
|
*.VC.db
|
||||||
|
*.VC.VC.opendb
|
||||||
|
|
||||||
|
# Visual Studio profiler
|
||||||
|
*.psess
|
||||||
|
*.vsp
|
||||||
|
*.vspx
|
||||||
|
*.sap
|
||||||
|
|
||||||
|
# TFS 2012 Local Workspace
|
||||||
|
$tf/
|
||||||
|
|
||||||
|
# Guidance Automation Toolkit
|
||||||
|
*.gpState
|
||||||
|
|
||||||
|
# ReSharper is a .NET coding add-in
|
||||||
|
_ReSharper*/
|
||||||
|
*.[Rr]e[Ss]harper
|
||||||
|
*.DotSettings.user
|
||||||
|
|
||||||
|
# JustCode is a .NET coding add-in
|
||||||
|
.JustCode
|
||||||
|
|
||||||
|
# TeamCity is a build add-in
|
||||||
|
_TeamCity*
|
||||||
|
|
||||||
|
# DotCover is a Code Coverage Tool
|
||||||
|
*.dotCover
|
||||||
|
|
||||||
|
# AxoCover is a Code Coverage Tool
|
||||||
|
.axoCover/*
|
||||||
|
!.axoCover/settings.json
|
||||||
|
|
||||||
|
# Visual Studio code coverage results
|
||||||
|
*.coverage
|
||||||
|
*.coveragexml
|
||||||
|
|
||||||
|
# NCrunch
|
||||||
|
_NCrunch_*
|
||||||
|
.*crunch*.local.xml
|
||||||
|
nCrunchTemp_*
|
||||||
|
|
||||||
|
# MightyMoose
|
||||||
|
*.mm.*
|
||||||
|
AutoTest.Net/
|
||||||
|
|
||||||
|
# Web workbench (sass)
|
||||||
|
.sass-cache/
|
||||||
|
|
||||||
|
# Installshield output folder
|
||||||
|
[Ee]xpress/
|
||||||
|
|
||||||
|
# DocProject is a documentation generator add-in
|
||||||
|
DocProject/buildhelp/
|
||||||
|
DocProject/Help/*.HxT
|
||||||
|
DocProject/Help/*.HxC
|
||||||
|
DocProject/Help/*.hhc
|
||||||
|
DocProject/Help/*.hhk
|
||||||
|
DocProject/Help/*.hhp
|
||||||
|
DocProject/Help/Html2
|
||||||
|
DocProject/Help/html
|
||||||
|
|
||||||
|
# Click-Once directory
|
||||||
|
publish/
|
||||||
|
|
||||||
|
# Publish Web Output
|
||||||
|
*.[Pp]ublish.xml
|
||||||
|
*.azurePubxml
|
||||||
|
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||||
|
# but database connection strings (with potential passwords) will be unencrypted
|
||||||
|
*.pubxml
|
||||||
|
*.publishproj
|
||||||
|
|
||||||
|
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||||
|
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||||
|
# in these scripts will be unencrypted
|
||||||
|
PublishScripts/
|
||||||
|
|
||||||
|
# NuGet Packages
|
||||||
|
*.nupkg
|
||||||
|
# The packages folder can be ignored because of Package Restore
|
||||||
|
**/packages/*
|
||||||
|
# except build/, which is used as an MSBuild target.
|
||||||
|
!**/packages/build/
|
||||||
|
# Uncomment if necessary however generally it will be regenerated when needed
|
||||||
|
#!**/packages/repositories.config
|
||||||
|
# NuGet v3's project.json files produces more ignorable files
|
||||||
|
*.nuget.props
|
||||||
|
*.nuget.targets
|
||||||
|
|
||||||
|
# Microsoft Azure Build Output
|
||||||
|
csx/
|
||||||
|
*.build.csdef
|
||||||
|
|
||||||
|
# Microsoft Azure Emulator
|
||||||
|
ecf/
|
||||||
|
rcf/
|
||||||
|
|
||||||
|
# Windows Store app package directories and files
|
||||||
|
AppPackages/
|
||||||
|
BundleArtifacts/
|
||||||
|
Package.StoreAssociation.xml
|
||||||
|
_pkginfo.txt
|
||||||
|
*.appx
|
||||||
|
|
||||||
|
# Visual Studio cache files
|
||||||
|
# files ending in .cache can be ignored
|
||||||
|
*.[Cc]ache
|
||||||
|
# but keep track of directories ending in .cache
|
||||||
|
!*.[Cc]ache/
|
||||||
|
|
||||||
|
# Others
|
||||||
|
ClientBin/
|
||||||
|
~$*
|
||||||
|
*~
|
||||||
|
*.dbmdl
|
||||||
|
*.dbproj.schemaview
|
||||||
|
*.jfm
|
||||||
|
*.pfx
|
||||||
|
*.publishsettings
|
||||||
|
orleans.codegen.cs
|
||||||
|
|
||||||
|
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||||
|
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||||
|
#bower_components/
|
||||||
|
|
||||||
|
# RIA/Silverlight projects
|
||||||
|
Generated_Code/
|
||||||
|
|
||||||
|
# Backup & report files from converting an old project file
|
||||||
|
# to a newer Visual Studio version. Backup files are not needed,
|
||||||
|
# because we have git ;-)
|
||||||
|
_UpgradeReport_Files/
|
||||||
|
Backup*/
|
||||||
|
UpgradeLog*.XML
|
||||||
|
UpgradeLog*.htm
|
||||||
|
|
||||||
|
# SQL Server files
|
||||||
|
*.mdf
|
||||||
|
*.ldf
|
||||||
|
*.ndf
|
||||||
|
|
||||||
|
# Business Intelligence projects
|
||||||
|
*.rdl.data
|
||||||
|
*.bim.layout
|
||||||
|
*.bim_*.settings
|
||||||
|
|
||||||
|
# Microsoft Fakes
|
||||||
|
FakesAssemblies/
|
||||||
|
|
||||||
|
# GhostDoc plugin setting file
|
||||||
|
*.GhostDoc.xml
|
||||||
|
|
||||||
|
# Node.js Tools for Visual Studio
|
||||||
|
.ntvs_analysis.dat
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# Typescript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# Visual Studio 6 build log
|
||||||
|
*.plg
|
||||||
|
|
||||||
|
# Visual Studio 6 workspace options file
|
||||||
|
*.opt
|
||||||
|
|
||||||
|
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||||
|
*.vbw
|
||||||
|
|
||||||
|
# Visual Studio LightSwitch build output
|
||||||
|
**/*.HTMLClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/GeneratedArtifacts
|
||||||
|
**/*.DesktopClient/ModelManifest.xml
|
||||||
|
**/*.Server/GeneratedArtifacts
|
||||||
|
**/*.Server/ModelManifest.xml
|
||||||
|
_Pvt_Extensions
|
||||||
|
|
||||||
|
# Paket dependency manager
|
||||||
|
.paket/paket.exe
|
||||||
|
paket-files/
|
||||||
|
|
||||||
|
# FAKE - F# Make
|
||||||
|
.fake/
|
||||||
|
|
||||||
|
# JetBrains Rider
|
||||||
|
.idea/
|
||||||
|
*.sln.iml
|
||||||
|
|
||||||
|
# CodeRush
|
||||||
|
.cr/
|
||||||
|
|
||||||
|
# Python Tools for Visual Studio (PTVS)
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
|
||||||
|
# Cake - Uncomment if you are using it
|
||||||
|
# tools/**
|
||||||
|
# !tools/packages.config
|
||||||
|
|
||||||
|
# Tabs Studio
|
||||||
|
*.tss
|
||||||
|
|
||||||
|
# Telerik's JustMock configuration file
|
||||||
|
*.jmconfig
|
||||||
|
|
||||||
|
# BizTalk build output
|
||||||
|
*.btp.cs
|
||||||
|
*.btm.cs
|
||||||
|
*.odx.cs
|
||||||
|
*.xsd.cs
|
||||||
|
|
||||||
|
# OpenCover UI analysis results
|
||||||
|
OpenCover/
|
||||||
9
LICENSE
Normal file
9
LICENSE
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
Copyright 2017 Tommy "Terrible Dev" Parnell
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
3
Readme.md
Normal file
3
Readme.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
** Work in progress**
|
||||||
|
|
||||||
|
A typed C# client for the [StreamElements](http://streamelements.com/) api
|
||||||
39
StreamElements.Net.sln
Normal file
39
StreamElements.Net.sln
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
|
# Visual Studio 15
|
||||||
|
VisualStudioVersion = 15.0.26124.0
|
||||||
|
MinimumVisualStudioVersion = 15.0.26124.0
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F7E2C1BF-9166-4BE9-BE4B-08BE0CEE439F}"
|
||||||
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StreamElements.Net", "src\StreamElements.Net\StreamElements.Net.csproj", "{859D5B9E-479D-4374-A600-6706623FD29B}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
Debug|x64 = Debug|x64
|
||||||
|
Debug|x86 = Debug|x86
|
||||||
|
Release|Any CPU = Release|Any CPU
|
||||||
|
Release|x64 = Release|x64
|
||||||
|
Release|x86 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Debug|x64.Build.0 = Debug|x64
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Debug|x86.ActiveCfg = Debug|x86
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Debug|x86.Build.0 = Debug|x86
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Release|x64.ActiveCfg = Release|x64
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Release|x64.Build.0 = Release|x64
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Release|x86.ActiveCfg = Release|x86
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B}.Release|x86.Build.0 = Release|x86
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{859D5B9E-479D-4374-A600-6706623FD29B} = {F7E2C1BF-9166-4BE9-BE4B-08BE0CEE439F}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
101
src/StreamElements.Net/AuthRestClient.cs
Normal file
101
src/StreamElements.Net/AuthRestClient.cs
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Refit;
|
||||||
|
using StreamElements.Net.Models;
|
||||||
|
using StreamElements.Net.Rest;
|
||||||
|
|
||||||
|
namespace StreamElements.Net
|
||||||
|
{
|
||||||
|
|
||||||
|
public class AuthRestClient : RestClient
|
||||||
|
{
|
||||||
|
private string JwtToken { get; }
|
||||||
|
private IAuthenticatedStreamElementsApi Client { get; }
|
||||||
|
public AuthRestClient(string jwtToken)
|
||||||
|
{
|
||||||
|
this.JwtToken = jwtToken;
|
||||||
|
if (string.IsNullOrWhiteSpace(jwtToken))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(jwtToken));
|
||||||
|
}
|
||||||
|
this.Client = BuildHttpClient<IAuthenticatedStreamElementsApi>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of activities sorted by createdAt.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<IList<Activity>> GetActivities() => Client.GetActivitiesAsync();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a single activity
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="id"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<Activity> GetActivity(string id)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(id))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(id));
|
||||||
|
}
|
||||||
|
return Client.GetActivityAsync(id);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an object with information about the bot.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<BotObj> GetBotAsync() => Client.GetBotAsync();
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the bots action log. These logs include command updates.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<List<BotLog>> GetBotLogsAsync() => Client.GetBotLogsAsync();
|
||||||
|
/// <summary>
|
||||||
|
/// Make the bot do something
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="action"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<Result> PostBotActionAsync(BotActionEnum action)
|
||||||
|
{
|
||||||
|
var actionParsed = Enum.GetName(typeof(BotActionEnum), action);
|
||||||
|
return this.Client.PostBotActionAsync(actionParsed);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Makes the bot send a message in current user's the channel.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<Result> PostBotSayAsync(string message)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(message))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(message));
|
||||||
|
}
|
||||||
|
return Client.PostBotSayAsync(new{ message } );
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns an array of users with levels in your channel.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<BotLevels> GetBotLevels() => Client.GetBotLevels();
|
||||||
|
/// <summary>
|
||||||
|
/// Create a new permission for the current channel.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public Task<SubmitBotLevelResponse> PostBotLevels(string userName, BotLevelEnum botEnum)
|
||||||
|
{
|
||||||
|
if(string.IsNullOrWhiteSpace(userName))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(userName));
|
||||||
|
}
|
||||||
|
return Client.PostBotLevel(new { username = userName, level = botEnum});
|
||||||
|
}
|
||||||
|
public override T BuildHttpClient<T>()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient() { BaseAddress = new Uri("https://api.streamelements.com/kappa/v1") };
|
||||||
|
httpClient.DefaultRequestHeaders.Add("authorization", $"Bearer {this.JwtToken}");
|
||||||
|
return RestService.For<T>(httpClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
42
src/StreamElements.Net/Models/Activity.cs
Normal file
42
src/StreamElements.Net/Models/Activity.cs
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace StreamElements.Net.Models
|
||||||
|
{
|
||||||
|
public class Data
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("amount")]
|
||||||
|
public decimal? Amount { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("message")]
|
||||||
|
public string Message { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Activity
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonProperty("_id")]
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("_username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// could be one of the following strings: follow, host, tip, subscriber, cheer
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[JsonProperty("type")]
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("data")]
|
||||||
|
public Data Data { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("createdAt")]
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
47
src/StreamElements.Net/Models/Bot.cs
Normal file
47
src/StreamElements.Net/Models/Bot.cs
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace StreamElements.Net.Models
|
||||||
|
{
|
||||||
|
public class Bot
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonProperty("_user")]
|
||||||
|
public string User { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("muted")]
|
||||||
|
public bool Muted { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("joined")]
|
||||||
|
public bool Joined { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("enabled")]
|
||||||
|
public bool Enabled { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Stats
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonProperty("commands")]
|
||||||
|
public int Commands { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("messages")]
|
||||||
|
public int Messages { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("timeouts")]
|
||||||
|
public int Timeouts { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BotObj
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonProperty("bot")]
|
||||||
|
public Bot Bot { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("stats")]
|
||||||
|
public Stats Stats { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
10
src/StreamElements.Net/Models/BotActionEnum.cs
Normal file
10
src/StreamElements.Net/Models/BotActionEnum.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace StreamElements.Net.Models
|
||||||
|
{
|
||||||
|
public enum BotActionEnum
|
||||||
|
{
|
||||||
|
join,
|
||||||
|
part,
|
||||||
|
mute,
|
||||||
|
unmute
|
||||||
|
}
|
||||||
|
}
|
||||||
12
src/StreamElements.Net/Models/BotLevelEnum.cs
Normal file
12
src/StreamElements.Net/Models/BotLevelEnum.cs
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
namespace StreamElements.Net.Models
|
||||||
|
{
|
||||||
|
public enum BotLevelEnum
|
||||||
|
{
|
||||||
|
BroadCaster = 1500,
|
||||||
|
SuperModerator = 1000,
|
||||||
|
Moderator = 500,
|
||||||
|
Regulars = 300,
|
||||||
|
Subscriber = 250,
|
||||||
|
Everyone = 100
|
||||||
|
}
|
||||||
|
}
|
||||||
22
src/StreamElements.Net/Models/BotLevels.cs
Normal file
22
src/StreamElements.Net/Models/BotLevels.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace StreamElements.Net.Models
|
||||||
|
{
|
||||||
|
public class BotLevels
|
||||||
|
{
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("lastActive")]
|
||||||
|
public string LastActive { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("moderator")]
|
||||||
|
public bool Moderator { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("subscriber")]
|
||||||
|
public bool Subscriber { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("level")]
|
||||||
|
public BotLevelEnum Level { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/StreamElements.Net/Models/BotLogs.cs
Normal file
24
src/StreamElements.Net/Models/BotLogs.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace StreamElements.Net.Models
|
||||||
|
{
|
||||||
|
public class BotLog
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonProperty("type")]
|
||||||
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("message")]
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("_id")]
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("createdAt")]
|
||||||
|
public DateTime CreatedAt { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
10
src/StreamElements.Net/Models/Result.cs
Normal file
10
src/StreamElements.Net/Models/Result.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace StreamElements.Net.Models
|
||||||
|
{
|
||||||
|
public class Result
|
||||||
|
{
|
||||||
|
public int Status { get; set; }
|
||||||
|
public string Channel { get; set; }
|
||||||
|
public string Message { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/StreamElements.Net/Models/SubmitBotLevelReponse.cs
Normal file
29
src/StreamElements.Net/Models/SubmitBotLevelReponse.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using System;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace StreamElements.Net.Models
|
||||||
|
{
|
||||||
|
// public class SubmitBotLevel
|
||||||
|
// {
|
||||||
|
// public string username { get; set; }
|
||||||
|
// public BotLevelEnum level { get; set; }
|
||||||
|
// }
|
||||||
|
public class SubmitBotLevelResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
[JsonProperty("username")]
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("lastActive")]
|
||||||
|
public DateTime LastActive { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("moderator")]
|
||||||
|
public bool Moderator { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("subscriber")]
|
||||||
|
public bool Subscriber { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("level")]
|
||||||
|
public BotLevelEnum Level { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Refit;
|
||||||
|
using StreamElements.Net.Models;
|
||||||
|
|
||||||
|
namespace StreamElements.Net.Rest
|
||||||
|
{
|
||||||
|
public interface IAuthenticatedStreamElementsApi
|
||||||
|
{
|
||||||
|
[Get("/activities")]
|
||||||
|
Task<IList<Activity>> GetActivitiesAsync();
|
||||||
|
|
||||||
|
[Get("/activities/{id}")]
|
||||||
|
Task<Activity> GetActivityAsync(string id);
|
||||||
|
|
||||||
|
[Get("/bot")]
|
||||||
|
Task<BotObj> GetBotAsync();
|
||||||
|
|
||||||
|
[Get("/bot/logs")]
|
||||||
|
Task<List<BotLog>> GetBotLogsAsync();
|
||||||
|
|
||||||
|
[Post("/bot/{action}")]
|
||||||
|
Task<Result> PostBotActionAsync(string action);
|
||||||
|
|
||||||
|
[Post("/bot/say")]
|
||||||
|
Task<Result> PostBotSayAsync([Body] object message);
|
||||||
|
|
||||||
|
[Get("/bot/levels")]
|
||||||
|
Task<BotLevels> GetBotLevels();
|
||||||
|
|
||||||
|
[Post("/bot/levels")]
|
||||||
|
Task<SubmitBotLevelResponse> PostBotLevel([Body] object submit);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/StreamElements.Net/RestClient.cs
Normal file
16
src/StreamElements.Net/RestClient.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Net.Http;
|
||||||
|
using Refit;
|
||||||
|
using StreamElements.Net.Rest;
|
||||||
|
|
||||||
|
namespace StreamElements.Net
|
||||||
|
{
|
||||||
|
public class RestClient
|
||||||
|
{
|
||||||
|
public virtual T BuildHttpClient<T>()
|
||||||
|
{
|
||||||
|
var httpClient = new HttpClient() { BaseAddress = new Uri("https://api.streamelements.com/kappa/v1") };
|
||||||
|
return RestService.For<T>(httpClient);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
src/StreamElements.Net/StreamElements.Net.csproj
Normal file
8
src/StreamElements.Net/StreamElements.Net.csproj
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="refit" Version="4.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
Reference in New Issue
Block a user