forked from adam/discord-bot-shtik
react works, sendfile theoretically might
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good
All checks were successful
gitea.arg.rip/vassago/pipeline/head This commit looks good
but it turns out there's an issue, see note on #25
This commit is contained in:
parent
8cc6c00db3
commit
0ff3902fd0
17
Behaver.cs
17
Behaver.cs
@ -175,13 +175,26 @@ public class Behaver
|
|||||||
}
|
}
|
||||||
public async Task<int> React(Guid messageId, string reaction)
|
public async Task<int> React(Guid messageId, string reaction)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"sanity check: behaver is reacting, {messageId}, {reaction}");
|
||||||
var message = Rememberer.MessageDetail(messageId);
|
var message = Rememberer.MessageDetail(messageId);
|
||||||
if (message == null)
|
if (message == null)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"message {messageId} not found");
|
||||||
return 404;
|
return 404;
|
||||||
|
}
|
||||||
|
Console.WriteLine($"sanity check: message found.");
|
||||||
|
if (message.Channel == null)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"react is going to fail because message {messageId} has no Channel");
|
||||||
|
}
|
||||||
|
Console.WriteLine($"sanity check: message has a channel.");
|
||||||
var iprotocol = fetchInterface(message.Channel);
|
var iprotocol = fetchInterface(message.Channel);
|
||||||
if (iprotocol == null)
|
if (iprotocol == null)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"couldn't find protocol for {message.Channel?.Id}");
|
||||||
return 404;
|
return 404;
|
||||||
|
}
|
||||||
|
Console.WriteLine("I remember this message, i have found a protocol, i am ready to react toit");
|
||||||
return await iprotocol.React(message, reaction);
|
return await iprotocol.React(message, reaction);
|
||||||
}
|
}
|
||||||
public async Task<int> Reply(Guid messageId, string text)
|
public async Task<int> Reply(Guid messageId, string text)
|
||||||
@ -195,7 +208,7 @@ public class Behaver
|
|||||||
var iprotocol = fetchInterface(message.Channel);
|
var iprotocol = fetchInterface(message.Channel);
|
||||||
if (iprotocol == null)
|
if (iprotocol == null)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"couldn't find channel for {message.Channel.Id} not found");
|
Console.WriteLine($"couldn't find protocol for {message.Channel.Id}");
|
||||||
return 404;
|
return 404;
|
||||||
}
|
}
|
||||||
return await iprotocol.Reply(message, text);
|
return await iprotocol.Reply(message, text);
|
||||||
|
@ -384,6 +384,7 @@ public class DiscordInterface : ProtocolInterface
|
|||||||
|
|
||||||
private static async Task<int> AttemptReact(IUserMessage msg, string e)
|
private static async Task<int> AttemptReact(IUserMessage msg, string e)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("discord attempting to react");
|
||||||
var c = Rememberer.SearchChannel(c => c.ExternalId == msg.Channel.Id.ToString());// db.Channels.FirstOrDefault(c => c.ExternalId == msg.Channel.Id.ToString());
|
var c = Rememberer.SearchChannel(c => c.ExternalId == msg.Channel.Id.ToString());// db.Channels.FirstOrDefault(c => c.ExternalId == msg.Channel.Id.ToString());
|
||||||
//var preferredEmote = c.EmoteOverrides?[e] ?? e; //TODO: emote overrides
|
//var preferredEmote = c.EmoteOverrides?[e] ?? e; //TODO: emote overrides
|
||||||
var preferredEmote = e;
|
var preferredEmote = e;
|
||||||
|
@ -90,7 +90,6 @@ public static class Rememberer
|
|||||||
{
|
{
|
||||||
toRemember.Channel.Messages.Add(toRemember);
|
toRemember.Channel.Messages.Add(toRemember);
|
||||||
db.Update(toRemember.Channel);
|
db.Update(toRemember.Channel);
|
||||||
// db.SaveChanges();
|
|
||||||
}
|
}
|
||||||
db.Update(toRemember);
|
db.Update(toRemember);
|
||||||
db.SaveChanges();
|
db.SaveChanges();
|
||||||
@ -217,6 +216,7 @@ public static class Rememberer
|
|||||||
Message toReturn;
|
Message toReturn;
|
||||||
dbAccessSemaphore.Wait();
|
dbAccessSemaphore.Wait();
|
||||||
toReturn = db.Messages.Find(Id);
|
toReturn = db.Messages.Find(Id);
|
||||||
|
db.Entry(toReturn).Reference(m => m.Channel).Load();
|
||||||
dbAccessSemaphore.Release();
|
dbAccessSemaphore.Release();
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class InternalAPIProtocolController : ControllerBase
|
|||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("PostMessage")]
|
[Route("PostMessage")]
|
||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
public IActionResult PostMessage([FromBody]extraSpecialObjectReadGlorifiedTupleFor_PostMessage param)
|
public IActionResult PostMessage([FromBody] extraSpecialObjectReadGlorifiedTupleFor_PostMessage param)
|
||||||
{
|
{
|
||||||
return StatusCode(Behaver.Instance.SendMessage(param.channelId, param.messageText).Result);
|
return StatusCode(Behaver.Instance.SendMessage(param.channelId, param.messageText).Result);
|
||||||
}
|
}
|
||||||
@ -39,7 +39,34 @@ public class InternalAPIProtocolController : ControllerBase
|
|||||||
[Produces("application/json")]
|
[Produces("application/json")]
|
||||||
public IActionResult ReplyToMessage([FromBody] extraSpecialObjectReadGlorifiedTupleFor_ReplyToMessage param)
|
public IActionResult ReplyToMessage([FromBody] extraSpecialObjectReadGlorifiedTupleFor_ReplyToMessage param)
|
||||||
{
|
{
|
||||||
Console.WriteLine("ReplyToMessage - ${param.repliedMessageId}, {param.messageText}");
|
Console.WriteLine($"ReplyToMessage - {param.repliedMessageId}, {param.messageText}");
|
||||||
return StatusCode(Behaver.Instance.Reply(param.repliedMessageId, param.messageText).Result);
|
return StatusCode(Behaver.Instance.Reply(param.repliedMessageId, param.messageText).Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class extraSpecialObjectReadGlorifiedTupleFor_SendFile
|
||||||
|
{
|
||||||
|
public Guid channelId; public string path; public string accompanyingText;
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
[Route("SendFile")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public IActionResult SendFile([FromBody] extraSpecialObjectReadGlorifiedTupleFor_SendFile param)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"SendFile- {param.channelId}, {param.path}, {param.accompanyingText}");
|
||||||
|
return StatusCode(Behaver.Instance.SendFile(param.channelId, param.path, param.accompanyingText).Result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class extraSpecialObjectReadGlorifiedTupleFor_ReactToMessage
|
||||||
|
{
|
||||||
|
public string reactionString;
|
||||||
|
public Guid reactedMessageId;
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
[Route("ReactToMessage")]
|
||||||
|
[Produces("application/json")]
|
||||||
|
public IActionResult ReactToMessage([FromBody] extraSpecialObjectReadGlorifiedTupleFor_ReactToMessage param)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"ReactToMessage- {param.reactedMessageId}, {param.reactionString}");
|
||||||
|
return StatusCode(Behaver.Instance.React(param.reactedMessageId, param.reactionString).Result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user