This commit is contained in:
Paul Schneider 2026-02-14 16:54:27 +00:00
commit 45514010f2
3505 changed files with 154 additions and 523 deletions

View file

@ -1,24 +0,0 @@
namespace Yavsc.Abstract.Chat
{
public static class ChatHubConstants
{
public const string HubGroupAuthenticated = "authenticated";
public const string HubGroupAnonymous = "anonymous";
public const string HubGroupCops= "cops";
public const string HubGroupRomsPrefix = "room_";
public const int MaxChanelName = 255;
public const string HubGroupFollowingPrefix = "fol ";
public const string AnonymousUserNamePrefix = "?";
public const string KeyParamChatUserName = "username";
public const string JustCreatedBy = "just created by ";
public const string LabYouNotOp = "you're no op.";
public const string LabNoSuchUser = "No such user";
public const string LabNoSuchChan = "No such chan";
public const string HopWontKickOp = "Half operator cannot kick any operator";
public const string LabAuthChatUser = "Authenticated chat user";
public const string NoKickOnCop = "No, you won´t, you´ĺl never do kick a cop, it is the bad.";
public const string LabnoJoinNoSend = "LabnoJoinNoSend";
}
}

View file

@ -1,9 +0,0 @@
namespace Yavsc.Abstract.Chat
{
public enum ChatRoomAccessLevel: int {
None=0,
Voice,
Op,
HalfOp
}
}

View file

@ -1,90 +0,0 @@
//
// ChatHub.cs
//
// Author:
// Paul Schneider <paul@pschneider.fr>
//
// Copyright (c) 2016-2019 GNU GPL
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using System.Linq;
using Yavsc;
namespace Yavsc
{
public class HubInputValidator {
public Action<string,string,string> NotifyUser {get;set;}
public bool ValidateRoomName (string roomName)
{
bool valid = ValidateStringLength(roomName,1,25);
if (valid) valid = IsLetterOrDigit(roomName);
if (!valid) NotifyUser(NotificationTypes.Error, "roomName", ChatHubLabels.InvalidRoomName);
return valid;
}
public bool ValidateUserName (string userName)
{
bool valid = true;
if (userName.Length<1 || userName[0] == '?' && userName.Length<2) valid = false;
if (valid) {
string suname = (userName[0] == '?') ? userName.Substring(1) : userName;
if (valid) valid = ValidateStringLength(suname, 1,12);
if (valid) valid = IsLetterOrDigit(userName);
}
if (!valid) NotifyUser(NotificationTypes.Error, "userName" , ChatHubLabels.InvalidUserName);
return valid;
}
public bool ValidateMessage (string message)
{
if (!ValidateStringLength(message, 1, 10240))
{
NotifyUser(NotificationTypes.Error, "message", ChatHubLabels.InvalidMessage);
return false;
}
return true;
}
public bool ValidateReason (string reason)
{
if (!ValidateStringLength(reason, 1,240))
{
NotifyUser(NotificationTypes.Error, "reason", ChatHubLabels.InvalidReason);
return false;
}
return true;
}
static bool ValidateStringLength(string str, int minLen, int maxLen)
{
if (string.IsNullOrEmpty(str))
{
if (minLen<=0) {
return true;
} else {
return false;
}
}
if (str.Length>maxLen||str.Length<minLen) return false;
return true;
}
static bool IsLetterOrDigit(string s)
{
foreach (var c in s)
if (!char.IsLetterOrDigit(c))
return false;
return true;
}
}
}

View file

@ -1,18 +0,0 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Yavsc.Abstract.Chat
{
public interface IChatRoom<TMod> where TMod : IChatRoomAccess
{
[RegularExpression(@"^#?[a-zA-Z0-9'-']{3,10}$", ErrorMessage = "chan name cannot be validated.")]
string Name { get; }
[RegularExpression(@"^#?[a-zA-Z0-9'-']{3,255}$", ErrorMessage = "topic cannot be validated.")]
string Topic { get ; set; }
string OwnerId { get ; }
List<TMod> Moderation { get; }
}
}

View file

@ -1,12 +0,0 @@
namespace Yavsc.Abstract.Chat
{
public interface IChatRoomAccess
{
long Id { get; }
ChatRoomAccessLevel Level { get; set; }
string UserId { get; }
}
}

View file

@ -1,14 +0,0 @@
namespace Yavsc.Abstract.Chat
{
public interface IChatUserInfo
{
string UserId { get; set; }
string UserName { get; set; }
string Avatar { get; set; }
string[] Roles { get; set; }
}
}

View file

@ -1,10 +0,0 @@
namespace Yavsc.Abstract.Chat
{
public interface IConnection
{
string ConnectionId { get; set; }
string UserAgent { get; set; }
bool Connected { get; set; }
}
}