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 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;
|
var update = ur.RawData;
|
||||||
|
|
||||||
@ -34,6 +34,9 @@ namespace DemoBot
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Remove unecessary parameter from method call in the future
|
||||||
|
var session = ur.Device;
|
||||||
|
|
||||||
//Is this a bot command ?
|
//Is this a bot command ?
|
||||||
if (mr.IsFirstHandler && mr.IsBotCommand && bot.IsKnownBotCommand(mr.BotCommand))
|
if (mr.IsFirstHandler && mr.IsBotCommand && bot.IsKnownBotCommand(mr.BotCommand))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -115,12 +115,13 @@ public sealed class BotBase
|
|||||||
if (ds == null)
|
if (ds == null)
|
||||||
{
|
{
|
||||||
ds = await Sessions.StartSession(e.DeviceId);
|
ds = await Sessions.StartSession(e.DeviceId);
|
||||||
e.Device = ds;
|
|
||||||
ds.LastMessage = e.RawData.Message;
|
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 mr = new MessageResult(e.RawData);
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
@ -210,6 +211,7 @@ public sealed class BotBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
var ds = Sessions.GetSession(deviceId);
|
var ds = Sessions.GetSession(deviceId);
|
||||||
|
|
||||||
e.Device = ds;
|
e.Device = ds;
|
||||||
|
|
||||||
await MessageLoopFactory.MessageLoop(this, ds, new UpdateResult(e.UpdateData, ds), e);
|
await MessageLoopFactory.MessageLoop(this, ds, new UpdateResult(e.UpdateData, ds), e);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user