添加新的功能 (#1)
- 群精华相关(设置精华/取消精华) - 下载图片相关(一些API不能直接发,需要添加referrer然后下载本地) - 添加了DEBUG沙盒群聊(快捷方式在目标后面添加*-g群号*,没空格) - FunGame相关(模拟/查数据)
This commit is contained in:
parent
b6b7ad9257
commit
fb6eebcc22
Binary file not shown.
@ -535,11 +535,22 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Api.Utility.Factory.GetItem(Milimoe.FunGame.Core.Library.Constant.ItemType)">
|
||||
<member name="M:Milimoe.FunGame.Core.Api.Utility.Factory.GetSkill">
|
||||
<summary>
|
||||
获取技能实例
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Api.Utility.Factory.GetEffect">
|
||||
<summary>
|
||||
获取技能特效实例
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Api.Utility.Factory.GetItem">
|
||||
<summary>
|
||||
获取物品实例
|
||||
</summary>
|
||||
<param name="type">Item类型 主动 或 被动</param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Api.Utility.Factory.GetRoom(System.Int64,System.String,System.Nullable{System.DateTime},Milimoe.FunGame.Core.Entity.User,Milimoe.FunGame.Core.Library.Constant.RoomType,System.String,System.String,Milimoe.FunGame.Core.Library.Constant.RoomState,System.Boolean,System.String)">
|
||||
@ -847,6 +858,22 @@
|
||||
<param name="options"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Api.Utility.NetworkUtility.HttpGet``1(System.String)">
|
||||
<summary>
|
||||
发送 GET 请求
|
||||
</summary>
|
||||
<param name="url"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Api.Utility.NetworkUtility.HttpPost``1(System.String,System.String)">
|
||||
<summary>
|
||||
发送 POST 请求
|
||||
</summary>
|
||||
<typeparam name="T"></typeparam>
|
||||
<param name="url"></param>
|
||||
<param name="json"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Milimoe.FunGame.Core.Api.Utility.DateTimeUtility">
|
||||
<summary>
|
||||
时间服务工具箱
|
||||
@ -1983,6 +2010,11 @@
|
||||
角色的详细资料
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Character.EquipSlot">
|
||||
<summary>
|
||||
角色的详细资料
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Character.MagicType">
|
||||
<summary>
|
||||
魔法属性
|
||||
@ -2473,7 +2505,7 @@
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Character.Equals(Milimoe.FunGame.Core.Interface.Entity.IBaseEntity)">
|
||||
<summary>
|
||||
比较一个角色(只比较 <see cref="P:Milimoe.FunGame.Core.Entity.Character.Name"/>)
|
||||
比较一个角色(只比较 <see cref="M:Milimoe.FunGame.Core.Entity.Character.ToString"/>)
|
||||
</summary>
|
||||
<param name="other"></param>
|
||||
<returns></returns>
|
||||
@ -2523,6 +2555,22 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Milimoe.FunGame.Core.Entity.CharacterProfile">
|
||||
<summary>
|
||||
角色的一些个人信息
|
||||
</summary>
|
||||
<param name="name"></param>
|
||||
<param name="firstname"></param>
|
||||
<param name="nickname"></param>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.CharacterProfile.#ctor(System.String,System.String,System.String)">
|
||||
<summary>
|
||||
角色的一些个人信息
|
||||
</summary>
|
||||
<param name="name"></param>
|
||||
<param name="firstname"></param>
|
||||
<param name="nickname"></param>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.CharacterProfile.Name">
|
||||
<summary>
|
||||
角色的姓
|
||||
@ -2578,12 +2626,149 @@
|
||||
角色的故事
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Milimoe.FunGame.Core.Entity.Effect">
|
||||
<member name="T:Milimoe.FunGame.Core.Entity.EquipSlot">
|
||||
<summary>
|
||||
特殊效果类,需要继承
|
||||
角色的装备槽位
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Effect.#ctor(Milimoe.FunGame.Core.Entity.Skill)">
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.EquipSlot.#ctor">
|
||||
<summary>
|
||||
角色的装备槽位
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.EquipSlot.MagicCardPack">
|
||||
<summary>
|
||||
魔法卡包
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.EquipSlot.Weapon">
|
||||
<summary>
|
||||
武器
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.EquipSlot.Armor">
|
||||
<summary>
|
||||
防具
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.EquipSlot.Shoes">
|
||||
<summary>
|
||||
鞋子
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.EquipSlot.Accessory1">
|
||||
<summary>
|
||||
饰品1
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.EquipSlot.Accessory2">
|
||||
<summary>
|
||||
饰品2
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Milimoe.FunGame.Core.Entity.MagicResistance">
|
||||
<summary>
|
||||
角色的魔法抗性,对不同的魔法类型有不同抗性
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.MagicResistance.#ctor">
|
||||
<summary>
|
||||
角色的魔法抗性,对不同的魔法类型有不同抗性
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Milimoe.FunGame.Core.Entity.Item">
|
||||
<summary>
|
||||
和 <see cref="T:Milimoe.FunGame.Core.Entity.Skill"/> 一样,需要继承构造
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Item.Description">
|
||||
<summary>
|
||||
物品的描述
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Item.ItemType">
|
||||
<summary>
|
||||
物品类型
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Item.EquipSlotType">
|
||||
<summary>
|
||||
物品槽位
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Item.Price">
|
||||
<summary>
|
||||
物品的价格
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Item.Key">
|
||||
<summary>
|
||||
快捷键
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Item.IsActive">
|
||||
<summary>
|
||||
是否是主动物品
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Item.Enable">
|
||||
<summary>
|
||||
是否可用(涉及冷却和禁用等)
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Item.Character">
|
||||
<summary>
|
||||
物品所属的角色
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Item.Skills">
|
||||
<summary>
|
||||
物品拥有的技能
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Item.OnItemGained">
|
||||
<summary>
|
||||
当获得物品时
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Item.UseItem(Milimoe.FunGame.Core.Api.Utility.ActionQueue,System.Collections.Generic.List{Milimoe.FunGame.Core.Entity.Character},System.Collections.Generic.List{Milimoe.FunGame.Core.Entity.Character})">
|
||||
<summary>
|
||||
局内使用物品触发
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Item.UseItem">
|
||||
<summary>
|
||||
局外(库存)使用物品触发
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Item.OnItemUsed">
|
||||
<summary>
|
||||
当物品被使用时
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Item.Equals(Milimoe.FunGame.Core.Interface.Entity.IBaseEntity)">
|
||||
<summary>
|
||||
判断两个物品是否相同 检查Id.Name
|
||||
</summary>
|
||||
<param name="other"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Milimoe.FunGame.Core.Entity.SkillGroup">
|
||||
<summary>
|
||||
物品只有一个主动技能,但是可以有很多个被动技能
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.SkillGroup.Active">
|
||||
<summary>
|
||||
唯一的主动技能
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.SkillGroup.Passive">
|
||||
<summary>
|
||||
被动技能组
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Milimoe.FunGame.Core.Entity.Effect">
|
||||
<summary>
|
||||
特殊效果类,需要继承
|
||||
</summary>
|
||||
@ -2977,11 +3162,6 @@
|
||||
技能描述
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Skill.Key">
|
||||
<summary>
|
||||
快捷键
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Skill.Level">
|
||||
<summary>
|
||||
技能等级,等于 0 时可以称之为尚未学习
|
||||
@ -2989,7 +3169,7 @@
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Skill.SkillType">
|
||||
<summary>
|
||||
技能 [ 此项为最高优先级 ]
|
||||
技能类型 [ 此项为最高优先级 ]
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Milimoe.FunGame.Core.Entity.Skill.IsActive">
|
||||
@ -3072,6 +3252,18 @@
|
||||
游戏中的行动顺序表实例,在技能效果被触发时,此实例会获得赋值,使用时需要判断其是否存在
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Skill.#ctor(Milimoe.FunGame.Core.Library.Constant.SkillType,Milimoe.FunGame.Core.Entity.Character)">
|
||||
<summary>
|
||||
继承此类实现时,调用基类的构造函数
|
||||
</summary>
|
||||
<param name="type"></param>
|
||||
<param name="character"></param>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Skill.#ctor">
|
||||
<summary>
|
||||
用于构造 JSON
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Skill.OnLevelUp">
|
||||
<summary>
|
||||
触发技能升级
|
||||
@ -3105,6 +3297,13 @@
|
||||
</summary>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Milimoe.FunGame.Core.Entity.Skill.Equals(Milimoe.FunGame.Core.Interface.Entity.IBaseEntity)">
|
||||
<summary>
|
||||
判断两个技能是否相同 检查Id.Name
|
||||
</summary>
|
||||
<param name="other"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="F:Milimoe.FunGame.Core.Entity.Skill._Level">
|
||||
<summary>
|
||||
等级
|
||||
|
||||
Binary file not shown.
@ -55,6 +55,27 @@ namespace Milimoe.RainBOT.ListeningTask
|
||||
return quick_reply;
|
||||
}
|
||||
|
||||
if (e.detail.Length >= 9 && e.detail[..9].Equals("FunGame模拟", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
if (!await Bot.CheckBlackList(true, e.user_id, e.user_id)) return quick_reply;
|
||||
if (!Bot.FunGameSimulation)
|
||||
{
|
||||
Bot.FunGameSimulation = true;
|
||||
List<string> msgs = await Bot.HttpGet<List<string>>("https://api.milimoe.com/fungame/test?isweb=false") ?? [];
|
||||
foreach (string msg in msgs)
|
||||
{
|
||||
await Bot.SendFriendMessage(e.user_id, "FunGame模拟", msg.Trim());
|
||||
await Task.Delay(5500);
|
||||
}
|
||||
Bot.FunGameSimulation = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
await Bot.SendFriendMessage(e.user_id, "FunGame模拟", "游戏正在模拟中,请勿重复请求!");
|
||||
}
|
||||
return quick_reply;
|
||||
}
|
||||
|
||||
if (GeneralSettings.IsMute && e.detail == "忏悔")
|
||||
{
|
||||
if (!await Bot.CheckBlackList(false, e.user_id, e.user_id)) return quick_reply;
|
||||
|
||||
@ -24,6 +24,11 @@ namespace Milimoe.RainBOT.ListeningTask
|
||||
Sender sender = e.sender;
|
||||
if (e.user_id == 0 || e.sender.user_id == 0) return quick_reply;
|
||||
|
||||
if (GeneralSettings.DebugGroupID != 0 && e.group_id != GeneralSettings.DebugGroupID)
|
||||
{
|
||||
Console.WriteLine($"{e.group_id} 不是沙盒群聊,已经过滤。");
|
||||
return quick_reply;
|
||||
}
|
||||
Console.WriteLine($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} G/{e.group_id}{(e.detail.Trim() == "" ? "" : " -> " + e.detail)} by {sender.user_id}({(sender.card != "" ? sender.card : sender.nickname)})");
|
||||
if (GeneralSettings.IsDebug)
|
||||
{
|
||||
@ -73,6 +78,27 @@ namespace Milimoe.RainBOT.ListeningTask
|
||||
}
|
||||
}
|
||||
|
||||
// 精华消息
|
||||
if ((e.user_id == GeneralSettings.Master || Bot.IsAdmin(e.group_id, e.user_id)) && e.detail.Contains("精华;") && e.message.Any(m => m.type == "reply"))
|
||||
{
|
||||
ReplyMessage reply = (ReplyMessage)e.message.Where(m => m.type == "reply").First();
|
||||
if (int.TryParse(reply.data.id, out int id))
|
||||
{
|
||||
if (e.detail.Contains("取消精华;"))
|
||||
{
|
||||
await Bot.SendMessage(SupportedAPI.delete_essence_msg, e.group_id, "取消精华", new DeleteEssenceMsgContent(id), true);
|
||||
await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.real_id), true);
|
||||
return quick_reply;
|
||||
}
|
||||
else
|
||||
{
|
||||
await Bot.SendMessage(SupportedAPI.set_essence_msg, e.group_id, "设置精华", new EssenceMsgContent(id), true);
|
||||
await Bot.SendMessage(SupportedAPI.delete_msg, e.group_id, "撤回", new DeleteMsgContent(e.real_id), true);
|
||||
return quick_reply;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!GeneralSettings.IsRun)
|
||||
{
|
||||
return quick_reply;
|
||||
@ -114,37 +140,89 @@ namespace Milimoe.RainBOT.ListeningTask
|
||||
return quick_reply;
|
||||
}
|
||||
|
||||
if (e.detail.Length >= 9 && e.detail[..9].Equals("FunGame模拟", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
|
||||
if (!Bot.FunGameSimulation)
|
||||
{
|
||||
Bot.FunGameSimulation = true;
|
||||
List<string> msgs = await Bot.HttpGet<List<string>>("https://api.milimoe.com/fungame/test?isweb=false") ?? [];
|
||||
foreach (string msg in msgs)
|
||||
{
|
||||
await Bot.SendGroupMessage(e.group_id, "FunGame模拟", msg.Trim());
|
||||
await Task.Delay(5500);
|
||||
}
|
||||
Bot.FunGameSimulation = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
await Bot.SendGroupMessage(e.group_id, "FunGame模拟", "游戏正在模拟中,请勿重复请求!");
|
||||
}
|
||||
return quick_reply;
|
||||
}
|
||||
|
||||
if (e.detail.Length >= 3 && e.detail[..3].Equals("查数据", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
|
||||
string detail = e.detail.Replace("查数据", "").Trim();
|
||||
if (int.TryParse(detail, out int id))
|
||||
{
|
||||
string msg = (await Bot.HttpGet<string>("https://api.milimoe.com/fungame/stats?id=" + id) ?? "").Trim();
|
||||
if (msg != "")
|
||||
{
|
||||
await Bot.SendGroupMessage(e.group_id, "查询FunGame数据", msg);
|
||||
}
|
||||
}
|
||||
return quick_reply;
|
||||
}
|
||||
|
||||
// 发图API
|
||||
if (e.detail == "来图")
|
||||
{
|
||||
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
|
||||
GroupMessageContent content = new(e.group_id);
|
||||
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=random"));
|
||||
await Bot.SendGroupMessage(e.group_id, "Image", content);
|
||||
Guid guid = await Bot.DownloadImageStream("https://iw233.cn/api.php?sort=random", "https://weibo.com/");
|
||||
if (guid != Guid.Empty)
|
||||
{
|
||||
GroupMessageContent content = new(e.group_id);
|
||||
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\download\" + guid.ToString() + ".jpg"));
|
||||
await Bot.SendGroupMessage(e.group_id, "Image", content);
|
||||
}
|
||||
return quick_reply;
|
||||
}
|
||||
if (e.detail.Contains("白毛"))
|
||||
{
|
||||
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
|
||||
GroupMessageContent content = new(e.group_id);
|
||||
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=yin"));
|
||||
await Bot.SendGroupMessage(e.group_id, "Image", content);
|
||||
Guid guid = await Bot.DownloadImageStream("https://iw233.cn/api.php?sort=yin", "https://weibo.com/");
|
||||
if (guid != Guid.Empty)
|
||||
{
|
||||
GroupMessageContent content = new(e.group_id);
|
||||
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\download\" + guid.ToString() + ".jpg"));
|
||||
await Bot.SendGroupMessage(e.group_id, "Image", content);
|
||||
}
|
||||
return quick_reply;
|
||||
}
|
||||
if (e.detail == "猫耳")
|
||||
{
|
||||
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
|
||||
GroupMessageContent content = new(e.group_id);
|
||||
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=cat"));
|
||||
await Bot.SendGroupMessage(e.group_id, "Image", content);
|
||||
Guid guid = await Bot.DownloadImageStream("https://iw233.cn/api.php?sort=cat", "https://weibo.com/");
|
||||
if (guid != Guid.Empty)
|
||||
{
|
||||
GroupMessageContent content = new(e.group_id);
|
||||
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\download\" + guid.ToString() + ".jpg"));
|
||||
await Bot.SendGroupMessage(e.group_id, "Image", content);
|
||||
}
|
||||
return quick_reply;
|
||||
}
|
||||
if (e.detail == "壁纸")
|
||||
{
|
||||
if (!await Bot.CheckBlackList(true, e.user_id, e.group_id)) return quick_reply;
|
||||
GroupMessageContent content = new(e.group_id);
|
||||
content.message.Add(new ImageMessage("https://iw233.cn/api.php?sort=pc"));
|
||||
await Bot.SendGroupMessage(e.group_id, "Image", content);
|
||||
Guid guid = await Bot.DownloadImageStream("https://iw233.cn/api.php?sort=pc", "https://weibo.com/");
|
||||
if (guid != Guid.Empty)
|
||||
{
|
||||
GroupMessageContent content = new(e.group_id);
|
||||
content.message.Add(new ImageMessage("file:///" + AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\download\" + guid.ToString() + ".jpg"));
|
||||
await Bot.SendGroupMessage(e.group_id, "Image", content);
|
||||
}
|
||||
return quick_reply;
|
||||
}
|
||||
if (e.detail == "新闻")
|
||||
|
||||
29
src/Main.cs
29
src/Main.cs
@ -1,4 +1,5 @@
|
||||
using Milimoe.OneBot.Framework;
|
||||
using System.IO;
|
||||
using Milimoe.OneBot.Framework;
|
||||
using Milimoe.OneBot.Model.Content;
|
||||
using Milimoe.OneBot.Model.Message;
|
||||
using Milimoe.OneBot.Model.Other;
|
||||
@ -17,6 +18,19 @@ try
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
|
||||
if (args.Any(a => a.StartsWith("-g")))
|
||||
{
|
||||
string debug_group = args.Where(a => a.StartsWith("-g")).FirstOrDefault() ?? "";
|
||||
debug_group = debug_group.Replace("-g", "").Trim();
|
||||
if (long.TryParse(debug_group, out long group_id))
|
||||
{
|
||||
GeneralSettings.DebugGroupID = group_id;
|
||||
Console.ForegroundColor = ConsoleColor.Cyan;
|
||||
Console.WriteLine("已指定Debug调试沙盒群聊:" + GeneralSettings.DebugGroupID);
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
}
|
||||
|
||||
HTTPListener? listener = default;
|
||||
|
||||
// 首先需要创建一个HTTP监听器
|
||||
@ -170,6 +184,19 @@ try
|
||||
{
|
||||
BlackList.Times.Remove(uid);
|
||||
}
|
||||
// 清空所有已下载的图片,释放空间
|
||||
string directory = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\download\";
|
||||
if (Directory.Exists(directory))
|
||||
{
|
||||
foreach (string file in Directory.GetFiles(directory))
|
||||
{
|
||||
try
|
||||
{
|
||||
File.Delete(file);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"profiles": {
|
||||
"RainBOT": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "--debug"
|
||||
"commandLineArgs": "--debug -g667678970"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="OneBot-HTTPClient">
|
||||
<HintPath>..\..\OneBot-HTTPClient\bin\Release\net8.0\win-x64\OneBot-HTTPClient.dll</HintPath>
|
||||
<HintPath>..\dll\OneBot-HTTPClient.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Text.Json;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using Milimoe.OneBot.Framework;
|
||||
using Milimoe.OneBot.Framework.Interface;
|
||||
@ -22,6 +23,8 @@ namespace Milimoe.RainBOT.Settings
|
||||
|
||||
public static Dictionary<long, List<Member>> GroupMembers { get; set; } = [];
|
||||
|
||||
public static bool FunGameSimulation { get; set; } = false;
|
||||
|
||||
public static bool IsAdmin(long group_id, long user_id)
|
||||
{
|
||||
if (GroupMembers.TryGetValue(group_id, out List<Member>? members) && members != null && members.Any(m => m.user_id == user_id && (m.role == "owner" || m.role == "admin")))
|
||||
@ -176,7 +179,7 @@ namespace Milimoe.RainBOT.Settings
|
||||
}
|
||||
await SendMessage(SupportedAPI.send_group_msg, group_id, function, content, true);
|
||||
}
|
||||
|
||||
|
||||
public static async Task SendGroupMessage(long group_id, string function, IEnumerable<IContent> contents) => await SendMessage(SupportedAPI.send_group_msg, group_id, function, contents, true);
|
||||
|
||||
public static async Task SendFriendMessage(long user_id, string function, string text)
|
||||
@ -190,10 +193,10 @@ namespace Milimoe.RainBOT.Settings
|
||||
|
||||
public static async Task SendFriendMessage(long user_id, string function, IEnumerable<IContent> contents) => await SendMessage(SupportedAPI.send_private_msg, user_id, function, contents, false);
|
||||
|
||||
public static async Task SendMessage(string api, long target_id, string function, IContent content, bool send_group)
|
||||
public static async Task SendMessage(string api, long target_id, string function, IContent content, bool send_group, string referrer = "")
|
||||
{
|
||||
string msg_type = send_group ? "G" : "P";
|
||||
string result = (await HTTPPost.Post(api, content)).ReasonPhrase ?? "";
|
||||
string result = (await HTTPPost.Post(api, content, referrer)).ReasonPhrase ?? "";
|
||||
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.Write(function);
|
||||
@ -208,10 +211,10 @@ namespace Milimoe.RainBOT.Settings
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task SendMessage(string api, long target_id, string function, IEnumerable<IContent> contents, bool send_group)
|
||||
public static async Task SendMessage(string api, long target_id, string function, IEnumerable<IContent> contents, bool send_group, string referrer = "")
|
||||
{
|
||||
string msg_type = send_group ? "G" : "P";
|
||||
await HTTPPost.Post(api, contents);
|
||||
await HTTPPost.Post(api, contents, referrer);
|
||||
Console.Write($"{DateTime.Now:yyyy/MM/dd HH:mm:ss} F/");
|
||||
Console.ForegroundColor = ConsoleColor.Yellow;
|
||||
Console.Write(function);
|
||||
@ -378,5 +381,59 @@ namespace Milimoe.RainBOT.Settings
|
||||
Console.WriteLine("已解禁所有参与12点大挑战的成员。");
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
}
|
||||
|
||||
private static readonly HttpClient client = new();
|
||||
|
||||
public static async Task<T?> HttpGet<T>(string url)
|
||||
{
|
||||
HttpResponseMessage response = await client.GetAsync(url);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
string content = await response.Content.ReadAsStringAsync();
|
||||
T? result = JsonSerializer.Deserialize<T>(content);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<T?> HttpPost<T>(string url, string json)
|
||||
{
|
||||
HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
HttpResponseMessage response = await client.PostAsync(url, content);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
string read = await response.Content.ReadAsStringAsync();
|
||||
T? result = JsonSerializer.Deserialize<T>(read);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async Task<Guid> DownloadImageStream(string url, string referrer)
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpClient client = new();
|
||||
if (referrer.Trim() != "") client.DefaultRequestHeaders.Referrer = new Uri(referrer);
|
||||
using HttpResponseMessage response = await client.GetAsync(url, HttpCompletionOption.ResponseHeadersRead);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
// 使用流的方式处理图片数据
|
||||
string directory = AppDomain.CurrentDomain.BaseDirectory.ToString() + @"img\download\";
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
Directory.CreateDirectory(directory);
|
||||
}
|
||||
|
||||
Guid guid = Guid.NewGuid();
|
||||
using Stream contentStream = await response.Content.ReadAsStreamAsync(), fileStream = new FileStream(directory + guid.ToString() + ".jpg", FileMode.Create, FileAccess.Write, FileShare.None, 16384, true);
|
||||
await contentStream.CopyToAsync(fileStream);
|
||||
client.Dispose();
|
||||
return guid;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine(e);
|
||||
Console.ForegroundColor = ConsoleColor.Gray;
|
||||
return Guid.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,6 +38,8 @@ namespace Milimoe.RainBOT.Settings
|
||||
|
||||
public static bool IsDebug { get; set; } = false;
|
||||
|
||||
public static long DebugGroupID { get; set; } = 0;
|
||||
|
||||
public static long BlackTimes { get; set; } = 5;
|
||||
|
||||
public static int BlackFrozenTime { get; set; } = 150;
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
{
|
||||
public const string version = "v1.0";
|
||||
public const string version2 = "Patch10";
|
||||
public const string time = "Sep. 12th 2024";
|
||||
public const string time = "Sep. 22nd 2024";
|
||||
|
||||
public static string Info => $"OSM Core {version} {version2}\r\nAuthor: Milimoe\r\nBuilt on {time}\r\nSee: https://github.com/milimoe";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user