Skip to content

Commit 8114e61

Browse files
committed
- runners
1 parent b42f76b commit 8114e61

File tree

15 files changed

+73
-18
lines changed

15 files changed

+73
-18
lines changed

Botticelli.Bot.Interfaces/Botticelli.Bot.Interfaces.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>net7.0</TargetFramework>

Botticelli.Framework.Telegram/TelegramBot.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using Botticelli.Framework.Exceptions;
44
using Botticelli.Framework.SendOptions;
55
using Botticelli.Framework.Telegram.Handlers;
6+
using Botticelli.Interfaces;
67
using Botticelli.Shared.API;
78
using Botticelli.Shared.API.Admin.Requests;
89
using Botticelli.Shared.API.Admin.Responses;
@@ -100,7 +101,7 @@ await _client.DeleteMessageAsync(request.ChatId,
100101
/// <exception cref="BotException"></exception>
101102
/// <exception cref="ArgumentOutOfRangeException"></exception>
102103
public override async Task<SendMessageResponse> SendMessageAsync<TSendOptions>(SendMessageRequest request,
103-
SendOptionsBuilder<TSendOptions> optionsBuilder,
104+
ISendOptionsBuilder<TSendOptions> optionsBuilder,
104105
CancellationToken token)
105106
{
106107
if (!IsStarted)
@@ -132,7 +133,7 @@ public override async Task<SendMessageResponse> SendMessageAsync<TSendOptions>(S
132133

133134
text = Escape(text);
134135
var retText = text.ToString();
135-
136+
136137
if (!string.IsNullOrWhiteSpace(retText))
137138
await _client.SendTextMessageAsync(request.Message.ChatId,
138139
retText,

Botticelli.Framework/BaseBot.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public Task<SendMessageResponse> SendMessageAsync(SendMessageRequest request, Ca
101101
/// <param name="optionsBuilder"></param>
102102
/// <returns></returns>
103103
public abstract Task<SendMessageResponse> SendMessageAsync<TSendOptions>(SendMessageRequest request,
104-
SendOptionsBuilder<TSendOptions> optionsBuilder,
104+
ISendOptionsBuilder<TSendOptions> optionsBuilder,
105105
CancellationToken token)
106106
where TSendOptions : class;
107107

Botticelli.Framework/Commands/Processors/CommandProcessor.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ public async Task ProcessAsync(Message message, CancellationToken token)
3636

3737
try
3838
{
39+
if (string.IsNullOrWhiteSpace(message.Body))
40+
{
41+
Logger.LogWarning("Message {msgId} has an empty body! Skipping...", message.Uid);
42+
43+
return;
44+
}
45+
3946
if (Regex.IsMatch(message.Body, SimpleCommandPattern))
4047
{
4148
var match = Regex.Matches(message.Body, SimpleCommandPattern)
Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Botticelli.Framework.Exceptions;
2+
using Botticelli.Interfaces;
23

34
namespace Botticelli.Framework.SendOptions
45
{
@@ -7,18 +8,19 @@ namespace Botticelli.Framework.SendOptions
78
/// (for example you can use InlineKeyboardMarkup as T)
89
/// </summary>
910
/// <typeparam name="T"></typeparam>
10-
public class SendOptionsBuilder<T>
11-
where T : class
11+
public class SendOptionsBuilder<T> : ISendOptionsBuilder<T> where T : class
1212
{
13-
private T innerObject = default;
13+
private T _innerObject = default;
1414

1515
protected SendOptionsBuilder()
1616
{
1717
}
1818

19-
public T Create(params object[] args)
19+
protected SendOptionsBuilder(T innerObject) => this._innerObject = innerObject;
20+
21+
public ISendOptionsBuilder<T> Create(params object[] args)
2022
{
21-
if (innerObject != default)
23+
if (_innerObject != default)
2224
throw new BotException($"You shouldn't use {nameof(Create)}() method twice!");
2325

2426
var constructors = typeof(T)
@@ -28,9 +30,9 @@ public T Create(params object[] args)
2830
// no params? ok => let's seek a parameterless constructor!
2931
if ((args == null || !args.Any()) && constructors.Any(c => !c.GetParameters().Any()))
3032
{
31-
innerObject = Activator.CreateInstance<T>();
33+
_innerObject = Activator.CreateInstance<T>();
3234

33-
return innerObject;
35+
return this;
3436
}
3537

3638
// Let's see if we can process parameter set and put it to a constructor|initializer
@@ -41,19 +43,21 @@ public T Create(params object[] args)
4143

4244

4345

44-
return innerObject;
46+
return this;
4547
}
4648

47-
public T Set(Func<T> func)
49+
public ISendOptionsBuilder<T> Set(Func<T,T> func)
4850
{
49-
func?.Invoke();
51+
func?.Invoke(_innerObject);
5052

51-
return innerObject;
53+
return this;
5254
}
5355

5456
public T Build()
55-
=> innerObject;
57+
=> _innerObject;
5658

5759
public static SendOptionsBuilder<T> CreateBuilder() => new();
60+
61+
public static SendOptionsBuilder<T> CreateBuilder(T input) => new(input);
5862
}
5963
}

Botticelli.Interfaces/IEventBasedBotClientApi.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ namespace Botticelli.Interfaces;
55

66
public interface IEventBasedBotClientApi
77
{
8+
/// <summary>
9+
/// Sends a message
10+
/// </summary>
11+
/// <param name="request">Message request</param>
12+
/// <param name="token">Cancellation token</param>
13+
/// <returns></returns>
814
public Task<SendMessageResponse> SendMessageAsync(SendMessageRequest request, CancellationToken token);
15+
16+
/// <summary>
17+
/// Sends a message
18+
/// </summary>
19+
/// <param name="request">Message request</param>
20+
/// <param name="optionsBuilder">Specific options for a particular messenger (for example, ReplyMarkup for Telegram)</param>
21+
/// <param name="token">Cancellation token</param>
22+
/// <returns></returns>
23+
public Task<SendMessageResponse> SendMessageAsync<TSendOptions>(SendMessageRequest request,
24+
ISendOptionsBuilder<TSendOptions> optionsBuilder,
25+
CancellationToken token)
26+
where TSendOptions : class;
27+
928
public Task<RemoveMessageResponse> DeleteMessageAsync(RemoveMessageRequest request, CancellationToken token);
1029
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Botticelli.Interfaces;
2+
3+
public interface ISendOptionsBuilder<T> where T : class
4+
{
5+
ISendOptionsBuilder<T> Create(params object[] args);
6+
ISendOptionsBuilder<T> Set(Func<T,T> func);
7+
T Build();
8+
}

Botticelli.Server.FrontNew/Handler/AuthDelegatingHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ protected override async Task<HttpResponseMessage> SendAsync(
2424
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", session.Token);
2525

2626
var response = await base.SendAsync(request, cancellationToken);
27-
Console.WriteLine($"Resp: {await response.Content.ReadAsStringAsync()}");
27+
2828
return response;
2929
}
3030
}

Botticelli.sln

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "back", "back", "{05922003-7
9494
ProjectSection(SolutionItems) = preProject
9595
deploy\linux\server\back\build.sh = deploy\linux\server\back\build.sh
9696
deploy\linux\server\back\Dockerfile = deploy\linux\server\back\Dockerfile
97+
deploy\linux\server\back\run_standalone.sh = deploy\linux\server\back\run_standalone.sh
9798
EndProjectSection
9899
EndProject
99100
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "front", "front", "{7FF17C87-CC2B-4CD6-B667-18B7BED78850}"
100101
ProjectSection(SolutionItems) = preProject
101102
deploy\linux\server\front\build.sh = deploy\linux\server\front\build.sh
102103
deploy\linux\server\front\Dockerfile = deploy\linux\server\front\Dockerfile
104+
deploy\linux\server\front\run_standalone.sh = deploy\linux\server\front\run_standalone.sh
103105
EndProjectSection
104106
EndProject
105107
Global

Botticelli/botInfo.Db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)