Skip to content

Commit

Permalink
license change to agpl, update mirai_csharp version
Browse files Browse the repository at this point in the history
  • Loading branch information
cc004 committed Oct 18, 2020
1 parent 7228cf9 commit 95fee38
Show file tree
Hide file tree
Showing 176 changed files with 4,894 additions and 2,057 deletions.
12 changes: 6 additions & 6 deletions BandoriBot.sln
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BandoriBot", "BandoriBotCor
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MsgPack", "MsgPack\MsgPack.csproj", "{A2097E23-A7CE-4D55-A0A7-95D350727ADF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mirai-CSharp", "Mirai-CSharp\Mirai-CSharp.csproj", "{70AE3964-4DAC-419D-8721-EDA73C4631C7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SekaiClient", "SekaiClient\SekaiClient.csproj", "{15C2B7D6-FAC3-4746-A1C8-87FDF927C70C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mirai-CSharp", "Mirai-CSharp\Mirai-CSharp\Mirai-CSharp.csproj", "{F484C48F-5AE1-4471-B43A-DCEB149831DD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -25,14 +25,14 @@ Global
{A2097E23-A7CE-4D55-A0A7-95D350727ADF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2097E23-A7CE-4D55-A0A7-95D350727ADF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2097E23-A7CE-4D55-A0A7-95D350727ADF}.Release|Any CPU.Build.0 = Release|Any CPU
{70AE3964-4DAC-419D-8721-EDA73C4631C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70AE3964-4DAC-419D-8721-EDA73C4631C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70AE3964-4DAC-419D-8721-EDA73C4631C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70AE3964-4DAC-419D-8721-EDA73C4631C7}.Release|Any CPU.Build.0 = Release|Any CPU
{15C2B7D6-FAC3-4746-A1C8-87FDF927C70C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{15C2B7D6-FAC3-4746-A1C8-87FDF927C70C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{15C2B7D6-FAC3-4746-A1C8-87FDF927C70C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{15C2B7D6-FAC3-4746-A1C8-87FDF927C70C}.Release|Any CPU.Build.0 = Release|Any CPU
{F484C48F-5AE1-4471-B43A-DCEB149831DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F484C48F-5AE1-4471-B43A-DCEB149831DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F484C48F-5AE1-4471-B43A-DCEB149831DD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F484C48F-5AE1-4471-B43A-DCEB149831DD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion BandoriBotCore/BandoriBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Mirai-CSharp\Mirai-CSharp.csproj" />
<ProjectReference Include="..\Mirai-CSharp\Mirai-CSharp\Mirai-CSharp.csproj" />
<ProjectReference Include="..\MsgPack\MsgPack.csproj" />
<ProjectReference Include="..\SekaiClient\SekaiClient.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion BandoriBotCore/Commands/Activator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void Run(CommandArgs args)
group = long.Parse(args.Arg);
if (!args.IsAdmin)
{
source = Common.CqApi.GetMemberList(group).Where((GroupMemberInfo info) => (info.QQId == args.Source.FromQQ)).ToList();
source = args.Source.Session.GetMemberList(group).Where((GroupMemberInfo info) => (info.QQId == args.Source.FromQQ)).ToList();
if (source.Count == 0 || source[0].PermitType == PermitType.None)
{
args.Callback("权限不足");
Expand Down
6 changes: 4 additions & 2 deletions BandoriBotCore/Commands/AdditionalCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
using System.Threading.Tasks;
using System.Web;

#pragma warning disable CS0028

namespace BandoriBot.Commands
{
public static class AdditionalCommands
Expand All @@ -28,7 +30,7 @@ public class 随机禁言
[Admin]
public static void Main(CommandArgs args, long qq)
{
//Common.CqApi.SetGroupBanSpeak(args.Source.FromGroup, qq, new TimeSpan(0, 0, new Random().Next(3600 * 24 * 30)));
//args.Source.Session.SetGroupBanSpeak(args.Source.FromGroup, qq, new TimeSpan(0, 0, new Random().Next(3600 * 24 * 30)));
}
}
public class 绑定
Expand Down Expand Up @@ -376,7 +378,7 @@ public static void Main(CommandArgs args, string name)
Configuration.GetConfig<ServerManager>().GetServer(args).RunCommand($"/ban add {name}");
args.Callback(string.Format(GlobalConfiguration.Global.func5Info, name));

//Common.CqApi.SetGroupMemberRemove(args.Source.FromGroup,
//args.Source.Session.SetGroupMemberRemove(args.Source.FromGroup,
// (long)Configuration.GetConfig<AccountBinding>().list.Where((o) => (string)o["username"] == name).Single()["qq"]);
}
}
Expand Down
12 changes: 2 additions & 10 deletions BandoriBotCore/Commands/FindCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void Run(CommandArgs args)
}
infos.Clear();
args.Callback($"refreshing...please wait.");
foreach (var group in (groups = Common.CqApi.GetGroupList()))
foreach (var member in Common.CqApi.GetMemberList(group.Id) ?? new List<GroupMemberInfo>())
foreach (var group in (groups = args.Source.Session.GetGroupList()))
foreach (var member in args.Source.Session.GetMemberList(group.Id) ?? new List<GroupMemberInfo>())
infos.Add(member);
var idhash = new HashSet<long>(groups.Select((group) => group.Id));
var groupfile = Path.Combine("groups.json");
Expand All @@ -62,15 +62,8 @@ public void Run(CommandArgs args)
foreach (JObject member in group["members"])
infos.Add(new GroupMemberInfo
{
Nick = (string)member["nick"],
QQId = (long)member["qq"],
Age = (int)member["age"],
Sex = (Sex)Enum.Parse(typeof(Sex), (string)member["sex"]),
Card = (string)member["card"],
PermitType = (PermitType)Enum.Parse(typeof(PermitType), (string)member["position"]),
JoiningTime = DateTime.Parse((string)member["join"]),
LastDateTime = DateTime.Parse((string)member["last"]),
SpecialTitle = (string)member["title"],
GroupId = info.Id
});

Expand Down Expand Up @@ -98,7 +91,6 @@ public void Run(CommandArgs args)
users.Add(member.QQId);
args.Callback(@$"{
new HashSet<long>(infos
.Where((info) => info.LastDateTime > active)
.Select((info) => info.QQId)).Count
} members in total {(active.Ticks == 0 ? "" : "is active after " + active.ToString())} (counting in {groups.Count} groups).");
break;
Expand Down
1 change: 1 addition & 0 deletions BandoriBotCore/Commands/ICommand.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using BandoriBot.Handler;
using BandoriBot.Models;
using Mirai_CSharp;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
4 changes: 2 additions & 2 deletions BandoriBotCore/Commands/PCRCommands.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public void Run(CommandArgs args)
DateTime start = DateTime.ParseExact(splits[0], "MMddHH", CultureInfo.CurrentCulture);
DateTime end = DateTime.ParseExact(splits[1], "MMddHH", CultureInfo.CurrentCulture);
var list = Configuration.GetConfig<PCRConfig>().Query(start, end);
foreach (var info in Common.CqApi.GetMemberList(args.Source.FromGroup).Where(info => !list.Contains(info.QQId)))
foreach (var info in args.Source.Session.GetMemberList(args.Source.FromGroup).Where(info => !list.Contains(info.QQId)))
{
//Common.CqApi.SendPrivateMessage(info.QQId, string.Join(" ", split1.Skip(1)));
//args.Source.Session.SendPrivateMessage(info.QQId, string.Join(" ", split1.Skip(1)));
result += $"[mirai:at={info.QQId}] ";
}

Expand Down
2 changes: 1 addition & 1 deletion BandoriBotCore/Commands/TitleCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected override TimeSpan DoRun(CommandArgs args)
try
{
var title = args.Arg.Trim();
var res = Common.CqApi.SetGroupSpecialTitle(args.Source.FromGroup, args.Source.FromQQ, title, new TimeSpan(-1L));
var res = args.Source.Session.SetGroupSpecialTitle(args.Source.FromGroup, args.Source.FromQQ, title, new TimeSpan(-1L));
args.Callback($"你的头衔已经修改为:`{title}`!");
return new TimeSpan(1, 0, 0);
}
Expand Down
3 changes: 2 additions & 1 deletion BandoriBotCore/Commands/YCM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public void Run(CommandArgs args)
List<Car> cars = Configuration.GetConfig<CarTypeConfig>()[args.Source.FromGroup] switch
{
CarType.Bandori => listener.Cars,
CarType.Sekai => CarHandler.Cars
CarType.Sekai => CarHandler.Cars,
_ => null
};

string result = "";
Expand Down
16 changes: 0 additions & 16 deletions BandoriBotCore/Common.cs

This file was deleted.

51 changes: 22 additions & 29 deletions BandoriBotCore/CqApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using BandoriBot.Models;
using Mirai_CSharp;
using Mirai_CSharp.Models;
using System;
using System.Collections.Generic;
using System.IO;
Expand All @@ -13,44 +15,35 @@ namespace BandoriBot
/// <summary>
/// 酷Q Api封装类
/// </summary>
public class CqApi
public static class CqApi
{
public GroupMemberInfo GetMemberInfo (long groupId, long qqId, bool notCache = false)
public static List<Models.GroupMemberInfo> GetMemberList(this MiraiHttpSession session, long groupId)
{
throw new NotImplementedException();
return session.GetGroupMemberListAsync(groupId).Result.Select(info => new Models.GroupMemberInfo
{
GroupId = groupId,
QQId = info.Id,
PermitType = info.Permission switch
{
GroupPermission.Owner => PermitType.Holder,
GroupPermission.Administrator => PermitType.Manage,
_ => PermitType.None
}
}).ToList();
}

public List<GroupMemberInfo> GetMemberList (long groupId)
public static List<Models.GroupInfo> GetGroupList(this MiraiHttpSession session)
{
throw new NotImplementedException();
return session.GetGroupListAsync().Result.Select(info => new Models.GroupInfo
{
Id = info.Id,
Name = info.Name
}).ToList();
}

public List<GroupInfo> GetGroupList ()
public static int SetGroupSpecialTitle(this MiraiHttpSession session, long groupId, long qqId, string specialTitle, TimeSpan time)
{
throw new NotImplementedException();
}

public GroupInfo GetGroupInfo (long groupId, bool notCache = false)
{
throw new NotImplementedException();
}

#region --管理--

/// <summary>
/// 置群成员专属头衔
/// </summary>
/// <param name="groupId">目标群</param>
/// <param name="qqId">目标QQ</param>
/// <param name="specialTitle">如果要删除,这里填空</param>
/// <param name="time">专属头衔有效期,单位为秒。如果永久有效,time填写负数</param>
/// <returns></returns>
public int SetGroupSpecialTitle (long groupId, long qqId, string specialTitle, TimeSpan time)
{
throw new NotImplementedException();
}

#endregion

}
}
2 changes: 1 addition & 1 deletion BandoriBotCore/Handler/MessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public async Task<bool> GroupMessageRevoked(MiraiHttpSession session, IGroupMess
{
await session.SendGroupMessageAsync(record.group, (new IMessageBase[]
{
new AtMessage(e.Operator.Id, ""),
new AtMessage(e.Operator.Id),
new PlainMessage("尝试撤回一条消息:")
}).Concat(record.message).ToArray());
return true;
Expand Down
10 changes: 1 addition & 9 deletions BandoriBotCore/Models/GroupInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ public class GroupInfo
/// <summary>
/// 群名字
/// </summary>
public string Name;
/// <summary>
/// 当前成员数量, 由 <see cref="CqApi.GetGroupInfo"/> 方法获取
/// </summary>
public int CurrentNumber;
/// <summary>
/// 获取最大成员数量, 由 <see cref="CqApi.GetGroupInfo"/> 方法获取
/// </summary>
public int MaximumNumber;
public string Name;
}
}
46 changes: 1 addition & 45 deletions BandoriBotCore/Models/GroupMemberInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,56 +19,12 @@ public class GroupMemberInfo
/// </summary>
public long QQId { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员昵称
/// </summary>
public string Nick { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员群名片
/// </summary>
public string Card { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员性别
/// </summary>
public Sex Sex { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员年龄
/// </summary>
public int Age { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员所在地区
/// </summary>
public string Area { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员入群的时间
/// </summary>
public DateTime JoiningTime { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员最后发言时间
/// </summary>
public DateTime LastDateTime { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员等级的名称
/// </summary>
public string Level { get; set; }
//public DateTime LastDateTime { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员在此群的权限
/// </summary>
public PermitType PermitType { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员在此群获得的专属头衔
/// </summary>
public string SpecialTitle { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员在此群的专属头衔过期时间, 若过期时间换算的秒数为 "-1" 则为无期限
/// </summary>
public DateTime SpecialTitleDurationTime { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员是否为不良记录成员
/// </summary>
public bool BadRecord { get; set; }
/// <summary>
/// 获取或设置一个值, 指示成员是否被允许修改群名片
/// </summary>
public bool CanModifiedCard { get; set; }
}
}
1 change: 1 addition & 0 deletions BandoriBotCore/Services/JJCManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public sealed class JJCManager : IDisposable
{
public static JJCManager Instance = new JJCManager(Path.Combine("jjc"));

#pragma warning disable CS0649
[JsonObject]
private class Character
{
Expand Down
4 changes: 2 additions & 2 deletions BandoriBotCore/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static IMessageBase[] GetMessageChain(string msg)
var val = match.Groups[3].Value;
switch (match.Groups[2].Value)
{
case "mirai:at": result.Add(new AtMessage(long.Parse(val), "")); break;
case "mirai:at": result.Add(new AtMessage(long.Parse(val))); break;
case "mirai:imageid": result.Add(new ImageMessage(val.Decode(), "", "")); break;
case "mirai:imageurl": result.Add(new ImageMessage("", val.Decode(), "")); break;
case "mirai:imagepath": result.Add(new ImageMessage("", "", val.Decode())); break;
Expand All @@ -80,7 +80,7 @@ public static IMessageBase[] GetMessageChain(string msg)
case "mirai:xml": result.Add(new XmlMessage(val.Decode())); break;
case "mirai:poke": result.Add(new PokeMessage(Enum.Parse<PokeType>(val))); break;
case "mirai:face": result.Add(new FaceMessage(int.Parse(val), "")); break;
case "CQ:at,qq": result.Add(new AtMessage(long.Parse(val), "")); break;
case "CQ:at,qq": result.Add(new AtMessage(long.Parse(val))); break;
case "CQ:face,id": result.Add(new FaceMessage(int.Parse(val), "")); break;
}
msg = match.Groups[4].Value;
Expand Down
Loading

0 comments on commit 95fee38

Please sign in to comment.