Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial/get basics done #1

Merged
merged 7 commits into from
May 10, 2024
Merged
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 .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ko_fi: fabiothefox
25 changes: 25 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Dev Test

on:
pull_request:
branches:
- dev

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '7.x'

- name: Restore dependencies
run: dotnet restore

- name: Build and test
run: dotnet build --configuration Release && dotnet test --no-build --verbosity normal
31 changes: 31 additions & 0 deletions Amino.NET.Interactions/Amino.NET.Interactions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,41 @@
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Authors>FabioTheeFox</Authors>
<Company>FabiDev</Company>
<Description>A simple framework for Amino chatbots built on Amino.NET</Description>
<PackageId>Amino.NET.Interactions</PackageId>
<Title>Amino.NET.Interactions</Title>
<Version>1.0.0</Version>
<Product>Amino.NET.Interactions</Product>
<Copyright>FabioTheFox</Copyright>
<PackageIcon>Amino.Net-Logo-V2.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/Amino-NET-Group/Amino.NET.Interactions</RepositoryUrl>
<RepositoryType>GIT</RepositoryType>
<PackageTags>Amino, Aminoapps, Amino.NET, rest, api, framework, Amino.NET.Interactions, Interactions</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<IncludeSymbols>False</IncludeSymbols>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

<ItemGroup>
<PackageReference Include="Amino.NET" Version="1.6.0" />
</ItemGroup>

<ItemGroup>
<None Update="Media\Amino.Net-Logo-V2.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>

</Project>
3 changes: 3 additions & 0 deletions Amino.NET.Interactions/Attributes/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@

namespace Amino.Interactions.Attributes
{
/// <summary>
/// This Attribute defines a Module to be a command
/// </summary>
public class Command : Attribute
{
public string CommandName { get; }
public string CommandDescription { get; }
public string CommunityId { get; }

public Command(string commandName, string commandDescription = null, string communityId = null)

Check warning on line 18 in Amino.NET.Interactions/Attributes/Command.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.

Check warning on line 18 in Amino.NET.Interactions/Attributes/Command.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.
{
this.CommandName = commandName;
this.CommunityId = communityId;
Expand Down
4 changes: 4 additions & 0 deletions Amino.NET.Interactions/Attributes/EnabledInDms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

namespace Amino.Interactions.Attributes
{
/// <summary>
/// This Attribute defines if a Module can be used in DMs and or DM Groups
/// </summary>
/// <remarks>Note: Using this attribute will not have any effect on your program as it is not fully implemented yet. You can still have it and update your project dependencies later for this take effect.</remarks>
public class EnabledInDms : Attribute
{
public bool IsEnabledInDms { get; } = true;
Expand Down
18 changes: 11 additions & 7 deletions Amino.NET.Interactions/Attributes/PermissionGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@

namespace Amino.Interactions.Attributes
{
public class PermissionGroup
/// <summary>
/// With this Attribute you can determine what permission level is required in order for a user to be able to use your module
/// </summary>
/// <remarks>Note: Using this attribute will not have any effect on your program as it is not fully implemented yet. You can still have it and update your project dependencies later for this take effect.</remarks>
public class PermissionGroup : Attribute
{
public enum PermissionGroups
{
All,
Chat_Staff,
Staff,
Curator,
Leader,
Agent
All = 0,
Chat_Staff = 1,
Staff = 2,
Curator = 3,
Leader = 4,
Agent = 5
}

public PermissionGroups RequiredPermission { get; set; } = PermissionGroups.All;
Expand Down
29 changes: 29 additions & 0 deletions Amino.NET.Interactions/FunctionAnalyizer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Amino.Interactions
{
public class ParameterInfo
{
public string Name { get; set; }
public bool IsOptional { get; set; }
}

public class FunctionAnalyzer
{
public ParameterInfo[] GetParameters(MethodInfo method)
{
return method.GetParameters()
.Select(p => new ParameterInfo
{
Name = p.ParameterType.Name,
IsOptional = p.HasDefaultValue
})
.ToArray();
}
}
}
35 changes: 32 additions & 3 deletions Amino.NET.Interactions/InteractionBase.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
using System;
using Amino.Interactions.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Amino;
using System.Security.Cryptography.X509Certificates;
namespace Amino.Interactions
{
public class InteractionBase
{
public Objects.Interaction Context;


public Task<Amino.Objects.Message> Respond(Interaction context, string message, bool asReply = true)
{
SubClient subClient = new SubClient(context.AminoClient, context.Message.communityId.ToString());
var ReturnMessage = subClient.send_message(message, context.InteractionChatId, replyTo: asReply ? context.Message.messageId : null);
return Task.FromResult(ReturnMessage);
}

public Task RespondWithFile(Interaction context, byte[] file, Amino.Types.upload_File_Types type = Types.upload_File_Types.Image)
{
SubClient subClient = new SubClient(context.AminoClient, context.Message.communityId.ToString());
subClient.send_file_message(context.InteractionChatId, file, type);
return Task.CompletedTask;
}

public Task RespondWithSticker(Interaction context, string stickerId)
{
SubClient subClient = new SubClient(context.AminoClient, context.Message.communityId.ToString());
subClient.send_sticker(context.InteractionChatId, stickerId);
return Task.CompletedTask;
}

public Task RespondWithEmbed(Interaction context, string content, string embedId = null, string embedLink = null, string embedTitle = null, string embedContent = null, byte[] embedImage = null)

Check warning on line 36 in Amino.NET.Interactions/InteractionBase.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.

Check warning on line 36 in Amino.NET.Interactions/InteractionBase.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.

Check warning on line 36 in Amino.NET.Interactions/InteractionBase.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.

Check warning on line 36 in Amino.NET.Interactions/InteractionBase.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.

Check warning on line 36 in Amino.NET.Interactions/InteractionBase.cs

View workflow job for this annotation

GitHub Actions / test

Cannot convert null literal to non-nullable reference type.
{
SubClient subClient = new SubClient(context.AminoClient, context.Message.communityId.ToString());
subClient.send_embed(context.InteractionChatId, content, embedId, embedLink, embedTitle, embedContent, embedImage);
return Task.CompletedTask;
}

}
}
Loading
Loading