Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sending game notify message after sending started game #623

Open
wants to merge 1 commit into
base: beta
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions Werewolf for Telegram/Werewolf Control/Commands/Helpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,25 +143,25 @@ private static void StartGame(GameMode gameMode, Update update)
{
node.StartGame(update, gameMode);
//notify waiting players
using (var db = new WWContext())
{
var notify = db.NotifyGames.Where(x => x.GroupId == update.Message.Chat.Id).ToList();
var groupName = update.Message.Chat.Title.ToBold();
if (update.Message.Chat.Username != null)
groupName += $" @{update.Message.Chat.Username}";
else if (grp.GroupLink != null)
groupName = $"<a href=\"{grp.GroupLink}\">{update.Message.Chat.Title}</a>";
foreach (var n in notify)
{
if (n.UserId != update.Message.From.Id)
Send(GetLocaleString("NotifyNewGame", grp.Language, groupName), n.UserId);
Thread.Sleep(500);
}
//using (var db = new WWContext())
//{
//var notify = db.NotifyGames.Where(x => x.GroupId == update.Message.Chat.Id).ToList();
//var groupName = update.Message.Chat.Title.ToBold();
//if (update.Message.Chat.Username != null)
//groupName += $" @{update.Message.Chat.Username}";
//else if (grp.GroupLink != null)
//groupName = $"<a href=\"{grp.GroupLink}\">{update.Message.Chat.Title}</a>";
//foreach (var n in notify)
//{
//if (n.UserId != update.Message.From.Id)
//Send(GetLocaleString("NotifyNewGame", grp.Language, groupName), n.UserId);
//Thread.Sleep(500);
//}

//just to be sure...
//db.Database.ExecuteSqlCommand($"DELETE FROM NotifyGame WHERE GroupId = {update.Message.Chat.Id}");
db.SaveChanges();
}
//db.SaveChanges();
//}
}
else
{
Expand Down
20 changes: 20 additions & 0 deletions Werewolf for Telegram/Werewolf Node/Werewolf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using Telegram.Bot.Types.ReplyMarkups;
using Werewolf_Node.Helpers;
using Werewolf_Node.Models;
using Werewolf_Control.Models;
using Shared;
using Telegram.Bot;

Expand Down Expand Up @@ -253,6 +254,25 @@ public Werewolf(long chatid, User u, string chatGroup, GameMode gameMode)
SendPlayerList(true);

new Thread(GameTimer).Start();

using (var db = new WWContext())
{
var notify = db.NotifyGames.Where(x => x.GroupId == update.Message.Chat.Id).ToList();
var groupName = update.Message.Chat.Title.ToBold();
if (update.Message.Chat.Username != null)
groupName += $" @{update.Message.Chat.Username}";
else if (grp.GroupLink != null)
groupName = $"<a href=\"{grp.GroupLink}\">{update.Message.Chat.Title}</a>";
foreach (var n in notify)
{
if (n.UserId != update.Message.From.Id)
Send(GetLocaleString("NotifyNewGame", grp.Language, groupName), n.UserId);
Thread.Sleep(500);
}

db.SaveChanges();
}

}
catch (Exception ex)
{
Expand Down