mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[rules] Implement /rules and /setrules. DIsable build of arm images.
This commit is contained in:
@@ -33,7 +33,7 @@ jobs:
|
||||
name: Build and push
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
platforms: linux/amd64
|
||||
push: ${{ github.ref == 'refs/heads/dev' }}
|
||||
tags: ${{ secrets.REGISTRY_URL }}/west/telegram-bot:latest,
|
||||
${{ secrets.REGISTRY_URL }}/west/telegram-bot:${{ steps.commit_sha.outputs.sha_short }}
|
||||
@@ -4,45 +4,43 @@ using BotFramework.Enums;
|
||||
using Kruzya.TelegramBot.Core.Data;
|
||||
using Kruzya.TelegramBot.Core.Extensions;
|
||||
using Telegram.Bot;
|
||||
using Telegram.Bot.Exceptions;
|
||||
|
||||
namespace West.TelegramBot.ChatManagement.Handler
|
||||
{
|
||||
internal partial class Rules : ManagementHandler
|
||||
internal class Rules : ManagementHandler
|
||||
{
|
||||
[Command(InChat.Public, "setrules", CommandParseMode.Both)]
|
||||
public async Task HandleSetRules()
|
||||
{
|
||||
var replyToMessage = Message?.ReplyToMessage;
|
||||
var text = replyToMessage?.Text;
|
||||
if (replyToMessage == null || text == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//var entities = replyToMessage.Entities;
|
||||
//if (entities != null)
|
||||
//{
|
||||
// //foreach (var entity in entities)
|
||||
// //{
|
||||
// // var entityText = text.Substring(entity.Offset, entity.Length);
|
||||
// // text = text
|
||||
// // .Remove(entity.Offset, entity.Length)
|
||||
// // .Insert(entity.Offset)
|
||||
// //}
|
||||
//}
|
||||
if (replyToMessage == null || !await CanPunish()) return;
|
||||
|
||||
|
||||
await Bot.SendTextMessageAsync(Chat, "tut bilo milo kruzi no on protiv");
|
||||
var opt = await Db.UserValues.FindOrCreateOption(Chat.Id, "rulesMsgId");
|
||||
opt.SetValue(replyToMessage.MessageId);
|
||||
Db.MarkAsModified(opt);
|
||||
}
|
||||
|
||||
[Command(InChat.Public, "rules", CommandParseMode.Both)]
|
||||
public async Task HandleRules()
|
||||
{
|
||||
var opt = Db.UserValues.FindOrCreateOption(Chat.Id, "rules");
|
||||
var opt = await Db.UserValues.FindOption(Chat.Id, "rulesMsgId");
|
||||
if (opt == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
public Rules(CoreContext db) : base(db)
|
||||
try
|
||||
{
|
||||
await Bot.CopyMessageAsync(Chat.Id, Chat.Id, opt.GetValue<int>());
|
||||
}
|
||||
catch (ApiRequestException)
|
||||
{
|
||||
Db.MarkAsDeleted(opt);
|
||||
}
|
||||
}
|
||||
|
||||
public Rules(CoreContext db) : base(db) {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user