Compare commits

..

4 Commits

15 changed files with 1350 additions and 11 deletions

View File

@ -1,5 +1,6 @@
namespace vassago.Behavior; namespace vassago;
#pragma warning disable 4014 //the "not awaited" error #pragma warning disable 4014 //the "not awaited" error
using vassago.Behavior;
using vassago.Models; using vassago.Models;
using System; using System;
using System.Linq; using System.Linq;
@ -12,18 +13,18 @@ public class Behaver
{ {
private List<Account> SelfAccounts { get; set; } = new List<Account>(); private List<Account> SelfAccounts { get; set; } = new List<Account>();
private User SelfUser { get; set; } private User SelfUser { get; set; }
public static List<Behavior> Behaviors { get; private set; } = new List<Behavior>(); public static List<vassago.Behavior.Behavior> Behaviors { get; private set; } = new List<vassago.Behavior.Behavior>();
internal Behaver() internal Behaver()
{ {
var subtypes = AppDomain.CurrentDomain.GetAssemblies() var subtypes = AppDomain.CurrentDomain.GetAssemblies()
.SelectMany(domainAssembly => domainAssembly.GetTypes()) .SelectMany(domainAssembly => domainAssembly.GetTypes())
.Where(type => type.IsSubclassOf(typeof(Behavior)) && !type.IsAbstract && .Where(type => type.IsSubclassOf(typeof(vassago.Behavior.Behavior)) && !type.IsAbstract &&
type.GetCustomAttributes(typeof(StaticPlzAttribute),false)?.Any() == true) type.GetCustomAttributes(typeof(StaticPlzAttribute),false)?.Any() == true)
.ToList(); .ToList();
foreach (var subtype in subtypes) foreach (var subtype in subtypes)
{ {
Behaviors.Add((Behavior)Activator.CreateInstance(subtype)); Behaviors.Add((vassago.Behavior.Behavior)Activator.CreateInstance(subtype));
} }
} }
static Behaver() { } static Behaver() { }

View File

@ -44,7 +44,7 @@ namespace vassago
public Task StopAsync(CancellationToken cancellationToken) public Task StopAsync(CancellationToken cancellationToken)
{ {
throw new NotImplementedException(); return null;
} }
} }
} }

8
Jenkinsfile vendored
View File

@ -13,5 +13,13 @@ pipeline {
archiveArtifacts artifacts: 'bin/Release/net7.0/linux-x64/publish/*' archiveArtifacts artifacts: 'bin/Release/net7.0/linux-x64/publish/*'
} }
} }
stage('Deploy'){
when{
branch "release"
}
steps{
}
}
} }
} }

View File

@ -17,6 +17,8 @@ public class ChattingContext : DbContext
public ChattingContext(DbContextOptions<ChattingContext> options) : base(options) { } public ChattingContext(DbContextOptions<ChattingContext> options) : base(options) { }
public ChattingContext() : base() { } public ChattingContext() : base() { }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseNpgsql(Shared.DBConnectionString) {
optionsBuilder.UseNpgsql(Shared.DBConnectionString)
.EnableSensitiveDataLogging(true); //who the fuck is looking at log output but not allowed to see it? this should be on by default. .EnableSensitiveDataLogging(true); //who the fuck is looking at log output but not allowed to see it? this should be on by default.
} }
}

View File

@ -6,8 +6,7 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container. // Add services to the container.
builder.Services.AddControllersWithViews(); builder.Services.AddControllersWithViews();
builder.Services.AddSingleton<IHostedService, vassago.ConsoleService>(); builder.Services.AddSingleton<IHostedService, vassago.ConsoleService>();
builder.Services.AddDbContext<ChattingContext>(options => builder.Services.AddDbContext<ChattingContext>();
options.UseNpgsql(builder.Configuration.GetConnectionString("ChattingContext") ));
var app = builder.Build(); var app = builder.Build();

View File

@ -1,8 +1,46 @@
# discord-bot # discord-bot
copy appsettings.json and fill it in copy appsettings.json to appsettings.ENV.json and fill it in. dotnet seems to understand files called appsettings.json (and appsettings.xml?) and knows how to overwrite *specific values found within* the .[ENV].[extension] version
# auth link # auth link
https://discord.com/oauth2/authorize?client_id=913003037348491264&permissions=274877942784&scope=bot https://discord.com/oauth2/authorize?client_id=913003037348491264&permissions=274877942784&scope=bot
that's read messages/view channels, send messages, send messages in threads, and attach files. but not add reactions? that's read messages/view channels, send messages, send messages in threads, and attach files. but not add reactions?
# concepts
## Data Types
### Accounts
a `User` can have multiple `Account`s. e.g., @adam:greyn.club? that's an "account". I, however, am a `User`. An `Account` has references to the `Channels` its seen in.
### Attachment
debating whether to save a copy of every single attachment. Discord allows 25MB attachments, and shtikbot lives in several art channels.
### Channel
a place where communication can happen. any level of these can have any number of children. In matrix, everything is a "room" - even spaces and threads. Seems like a fine idea. So for vassago, a discord "channel" is a channel. a "thread" is a child of that channel. a "category" is a parent of that channel. A "server" (formerly "guild") is a parent of that channel. and fuck it, Discord itself is a "channel".
### ChannelPermissions
the permissions Vassago has for a channel. MaxAttachmentBytes, etc. (...shouldn't this be just part of Channel? You're *always* going down the hierarchy until you find an override. permissions should always inherit, right?)
### FeaturePermission
the permissions of a feature. It can be restricted to accounts, to users, to channels. It has an internal name... and tag? and it can be (or not be) inheritable?
### Message
a message (duh). features bools for "mentions me", the external ID, the reference to the account, the channel.
### User
a person or program who operates an account. recognizing that 2 `Account`s belong to 1 `User` can be done by that user (using LinkMe). I should be able to collapse myself automatically.
## Behavior
both a "feature" and an "anti-feature". a channel might dictate something isn't allowed (lewdness in a g-rated channel). A person might not be allowed to do something - lots of me-only things like directing other bots (and the now rendered-moot Torrent feature). A behavior might need a command alias in a particular channel (freedomunits in jubel's)
so "behavior" might need to tag other data types? do I have it do a full select every time we get a message? ...no, only if the (other) triggering conditions are met. Then you can take your time.

View File

@ -1,6 +1,7 @@
@{ @{
ViewData["Title"] = "Home Page"; ViewData["Title"] = "Home Page";
} }
<div id="tree"></div>
<div> <div>
<a href="Users">Users</a> <a href="Users">Users</a>
</div> </div>
@ -10,3 +11,6 @@
<div> <div>
<a href="Channels">Channels</a> <a href="Channels">Channels</a>
</div> </div>
<div>
<a href="Behaviors">Behaviors</a>
</div>

View File

@ -16,6 +16,7 @@
</div> </div>
<script src="~/lib/jquery/dist/jquery.min.js"></script> <script src="~/lib/jquery/dist/jquery.min.js"></script>
<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script> <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
<script src="bootstrap-treeview.js"></script>
<script src="~/js/site.js" asp-append-version="true"></script> <script src="~/js/site.js" asp-append-version="true"></script>
@await RenderSectionAsync("Scripts", required: false) @await RenderSectionAsync("Scripts", required: false)
</body> </body>

View File

@ -12,5 +12,5 @@
"TwitchConfigs": [ "TwitchConfigs": [
], ],
"exchangePairsLocation": "assets/exchangepairs.json", "exchangePairsLocation": "assets/exchangepairs.json",
"DBConnectionString": "Host=localhost;Database=db;Username=db;Password=db" "DBConnectionString": "Host=azure.club;Database=db;Username=user;Password=password"
} }

37
wwwroot/css/bootstrap-treeview.css vendored Normal file
View File

@ -0,0 +1,37 @@
/* =========================================================
* bootstrap-treeview.css v1.2.0
* =========================================================
* Copyright 2013 Jonathan Miles
* Project URL : http://www.jondmiles.com/bootstrap-treeview
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ========================================================= */
.treeview .list-group-item {
cursor: pointer;
}
.treeview span.indent {
margin-left: 10px;
margin-right: 10px;
}
.treeview span.icon {
width: 12px;
margin-right: 5px;
}
.treeview .node-disabled {
color: silver;
cursor: not-allowed;
}

1249
wwwroot/js/bootstrap-treeview.js vendored Normal file

File diff suppressed because it is too large Load Diff