Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
1.2.1
Browse files Browse the repository at this point in the history
1. Теперь при запросах ответ возвращается мгновенно
  • Loading branch information
likhner committed Jul 15, 2022
1 parent f6e7476 commit be9ecd3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
8 changes: 4 additions & 4 deletions Controllers/EditorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ private string GetStartMenuKeyboard(long id)
return IfUserIsAdmin(id) ? AdminStartButtons : StartButtons;
}

private async Task DialogProcessor(long? peer, long? userId, Message message)
private void DialogProcessor(long? peer, long? userId, Message message)
{
if (peer == null || userId == null)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ private async Task DialogProcessor(long? peer, long? userId, Message message)
break;

case PayloadTemplates.IveJoined:
await ProcessIveJoined(user);
ProcessIveJoined(user);
break;

case PayloadTemplates.IveJoinedInFiftySubs:
Expand Down Expand Up @@ -227,7 +227,7 @@ private async Task DialogProcessor(long? peer, long? userId, Message message)
}

[HttpPost]
public async Task<IActionResult> Dialog([FromBody] VkEvent vkEvent)
public IActionResult Dialog([FromBody] VkEvent vkEvent)
{
if (!IsAllowed(vkEvent.GroupId, vkEvent.Secret)) return Ok("ok");

Expand All @@ -238,7 +238,7 @@ public async Task<IActionResult> Dialog([FromBody] VkEvent vkEvent)
var message = Message.FromJson(new VkResponse(vkEvent.Object));
Logger.LogInformation("message_new\n\tUser: {User}\n\tContent: «{Content}»",
message.FromId, message.Text);
await DialogProcessor(message.PeerId, message.FromId, message);
new Thread(() => DialogProcessor(message.PeerId, message.FromId, message)).Start();
}

return Ok("ok");
Expand Down
12 changes: 3 additions & 9 deletions Controllers/EditorControllerAdminRegion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,15 @@ private void ProcessAdminUnbanRequestAccept(long user)
private void ProcessUnbanUserInAllGroups(long admin, UnbanRequest request)
{
var data = CacheFramework.LoadCache().Data;
var userObject = new User
{
Id = request.UserId
};
var id = request.UserId;
foreach (var cacheGroup in data)
{
var banned = VkFramework.GetBanned(cacheGroup.Id);
if (banned.All(x => x.Id != request.UserId)) continue;
var group = new Group
{
Id = cacheGroup.Id
};
var group = cacheGroup.Id;
try
{
VkFramework.UnBlock(group, userObject);
VkFramework.UnBlock(group, id);
}
catch (VkApiException e)
{
Expand Down
8 changes: 4 additions & 4 deletions Controllers/EditorControllerPayloadProcessors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ private void ProcessGiveEditor(long user)
VkController.SendMessage(PhraseFramework.PleaseJoinGroup(group), IveJoinedButtons, user);
}

private async Task ProcessIveJoined(long user)
private void ProcessIveJoined(long user)
{
var cachedGroups = CacheFramework.LoadCache();
var priority = IfUserPrioritized(user);
Expand Down Expand Up @@ -237,14 +237,14 @@ private async Task ProcessIveJoined(long user)
return;
}

await Task.Delay(TimeSpan.FromSeconds(2));
Thread.Sleep(TimeSpan.FromSeconds(2));

var data = VkController.GetGroupInfo(request.Group);
if (!data.Members.Contains(request.User))
{
VkController.SendMessage(PhraseFramework.YouHaveNotJoinedClub,
IveJoinedButtons, user);
await Task.Delay(500);
Thread.Sleep(TimeSpan.FromMilliseconds(500));
ReplaceLongToGroup(ref cachedGroups, request);
CacheFramework.SaveCache(cachedGroups);
return;
Expand Down Expand Up @@ -280,7 +280,7 @@ private async Task ProcessIveJoined(long user)
return;
}

await Task.Delay(1000);
Thread.Sleep(TimeSpan.FromSeconds(1));
ReplaceLongToGroup(ref cachedGroups, request);
if (priority) Status.AddLimitlessUserCoolDown(user);
else Status.CoolDownUsers.Add(user);
Expand Down
2 changes: 1 addition & 1 deletion nng-bot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<PropertyGroup>
<PackageId>nng-bot</PackageId>
<PackageVersion>1.2.0</PackageVersion>
<PackageVersion>1.2.1</PackageVersion>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Authors>likhner;RomanKochetov</Authors>
<RepositoryUrl>https://github.com/MrAlonas/nng-bot.git</RepositoryUrl>
Expand Down

0 comments on commit be9ecd3

Please sign in to comment.