Changing messageloop behaviour and fix missing Device instance in UpdateResult
- simplified for future changes
This commit is contained in:
parent
07fe8e9074
commit
c821a69d57
@ -22,7 +22,7 @@ namespace DemoBot
|
||||
|
||||
public ExternalActionManager ExternalActionManager { get; set; }
|
||||
|
||||
public async Task MessageLoop(BotBase bot, DeviceSession session, UpdateResult ur, MessageResult mr)
|
||||
public async Task MessageLoop(BotBase bot, DeviceSession s, UpdateResult ur, MessageResult mr)
|
||||
{
|
||||
var update = ur.RawData;
|
||||
|
||||
@ -34,6 +34,9 @@ namespace DemoBot
|
||||
return;
|
||||
}
|
||||
|
||||
//Remove unecessary parameter from method call in the future
|
||||
var session = ur.Device;
|
||||
|
||||
//Is this a bot command ?
|
||||
if (mr.IsFirstHandler && mr.IsBotCommand && bot.IsKnownBotCommand(mr.BotCommand))
|
||||
{
|
||||
|
||||
@ -115,12 +115,13 @@ public sealed class BotBase
|
||||
if (ds == null)
|
||||
{
|
||||
ds = await Sessions.StartSession(e.DeviceId);
|
||||
e.Device = ds;
|
||||
ds.LastMessage = e.RawData.Message;
|
||||
|
||||
OnSessionBegins(new SessionBeginEventArgs(e.DeviceId, ds));
|
||||
OnSessionBegins(new SessionBeginEventArgs(e.DeviceId, ds));
|
||||
}
|
||||
|
||||
e.Device = ds;
|
||||
|
||||
var mr = new MessageResult(e.RawData);
|
||||
|
||||
var i = 0;
|
||||
@ -210,6 +211,7 @@ public sealed class BotBase
|
||||
try
|
||||
{
|
||||
var ds = Sessions.GetSession(deviceId);
|
||||
|
||||
e.Device = ds;
|
||||
|
||||
await MessageLoopFactory.MessageLoop(this, ds, new UpdateResult(e.UpdateData, ds), e);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user