mirror of
https://github.com/oshima-studios/OshimaGameModule.git
synced 2025-04-23 04:19:36 +08:00
修改 Handler
This commit is contained in:
parent
59cdb29105
commit
e0d52167f1
@ -44,18 +44,8 @@ namespace Oshima.FunGame.OshimaServers
|
||||
}
|
||||
|
||||
public void AfterOpenStoreEvent(object sender, GeneralEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void SucceedOpenStoreEvent(object sender, GeneralEventArgs e)
|
||||
{
|
||||
if (e.EventMsg != "") Controller.WriteLine(e.EventMsg, Milimoe.FunGame.Core.Library.Constant.LogLevel.Debug);
|
||||
}
|
||||
|
||||
public void FailedOpenStoreEvent(object sender, GeneralEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4900,7 +4900,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
pc.SaveConfig();
|
||||
|
||||
e.EventMsg = $"{user.Username}访问每日商店成功";
|
||||
FunGameService.ServerPluginLoader?.OnSucceedOpenStoreEvent(user, e);
|
||||
FunGameService.ServerPluginLoader?.OnAfterOpenStoreEvent(user, e);
|
||||
|
||||
return NetworkUtility.JsonSerialize(msg);
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
//{
|
||||
// _logger.LogError("上传图片失败:{error}", error);
|
||||
//}
|
||||
TaskUtility.NewTask(async () => await FungameService.Handler(c2c: c2cMessage));
|
||||
TaskUtility.NewTask(async () => await FungameService.Handler(c2cMessage));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -150,7 +150,7 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
Logger.LogInformation("收到来自群组 {groupAtMessage.GroupOpenId} 的消息:{groupAtMessage.Content}", groupAtMessage.GroupOpenId, groupAtMessage.Content);
|
||||
// 回复消息
|
||||
//await _service.SendGroupMessageAsync(groupAtMessage.GroupOpenId, $"你发送的消息是:{groupAtMessage.Content}", msgId: groupAtMessage.Id);
|
||||
TaskUtility.NewTask(async () => await FungameService.Handler(groupAt: groupAtMessage));
|
||||
TaskUtility.NewTask(async () => await FungameService.Handler(groupAtMessage));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -178,37 +178,18 @@ namespace Oshima.FunGame.WebAPI.Controllers
|
||||
|
||||
[Authorize(AuthenticationSchemes = "CustomBearer")]
|
||||
[HttpPost("thirdparty")]
|
||||
public async Task<string> ThirdParty([FromBody] ThirdPartyMessage? msg = null)
|
||||
public async Task<IActionResult> ThirdParty([FromBody] ThirdPartyMessage? msg = null)
|
||||
{
|
||||
if (msg is null) return "";
|
||||
if (msg is null) return Ok("");
|
||||
|
||||
bool result = true;
|
||||
string error = "";
|
||||
TaskUtility.NewTask(async () => result = await FungameService.Handler(third: msg)).OnError(e => error = e.ToString());
|
||||
bool result = await FungameService.Handler(msg);
|
||||
|
||||
int time = 0;
|
||||
int timeout = 8 * 1000;
|
||||
while (true)
|
||||
if (!result || msg.IsCompleted)
|
||||
{
|
||||
await Task.Delay(200);
|
||||
time += 200;
|
||||
if (time >= timeout)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!result || msg.IsCompleted)
|
||||
{
|
||||
break;
|
||||
}
|
||||
return Ok(msg.Result);
|
||||
}
|
||||
|
||||
if (error != "")
|
||||
{
|
||||
if (msg.Result != "") msg.Result += "\r\n";
|
||||
msg.Result += error;
|
||||
}
|
||||
|
||||
return NetworkUtility.JsonSerialize(msg.Result);
|
||||
return Ok("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,26 +43,13 @@ namespace Oshima.FunGame.WebAPI.Services
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> Handler(GroupAtMessage? groupAt = null, C2CMessage? c2c = null, ThirdPartyMessage? third = null)
|
||||
public async Task<bool> Handler(IBotMessage e)
|
||||
{
|
||||
bool result = true;
|
||||
try
|
||||
{
|
||||
IBotMessage? e = null;
|
||||
string openid = "";
|
||||
long uid = 0;
|
||||
if (groupAt != null)
|
||||
{
|
||||
e = groupAt;
|
||||
}
|
||||
else if (c2c != null)
|
||||
{
|
||||
e = c2c;
|
||||
}
|
||||
else if (third != null)
|
||||
{
|
||||
e = third;
|
||||
}
|
||||
|
||||
if (e is null)
|
||||
{
|
||||
@ -2017,9 +2004,9 @@ namespace Oshima.FunGame.WebAPI.Services
|
||||
return result;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogError("Error: {e}", e);
|
||||
Logger.LogError("Error: {ex}", ex);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user