public TickerMessage GenerateTickerMessage()
        {
            lock (countlock)
            {
                if (PollOptionCount > 0)
                {
                    index = (index + 1) % PollOptionCount;
                }
            }

            PollOption option = context.Database.LoadEntities <PollOption>().Where(o => !o.Locked).Offset(index).Execute().FirstOrDefault();

            if (option != null)
            {
                Poll poll = context.Database.LoadEntities <Poll>().Where(p => p.Name == option.Poll).Execute().FirstOrDefault();

                if (poll != null)
                {
                    return(new TickerMessage {
                        Content = new MessageBuilder()
                                  .Text("Type ")
                                  .Text($"!vote {option.Key}", StreamColors.Command, FontWeight.Bold)
                                  .Text(" in chat for ")
                                  .Text(option.Description, StreamColors.Game, FontWeight.Bold)
                                  .BuildMessage()
                    });
                }
            }

            throw new Exception("No poll data in database");
        }
Example #2
0
 void OnOptionRemoved(PollOption option)
 {
     OptionRemoved?.Invoke(option);
     if (tickergenerator.PollOptionCount == 0)
     {
         context.GetModule <TickerModule>().RemoveSource(tickergenerator);
     }
 }
Example #3
0
 void OnOptionAdded(PollOption option)
 {
     OptionAdded?.Invoke(option);
     if (tickergenerator.PollOptionCount == 1)
     {
         context.GetModule <TickerModule>().AddSource(tickergenerator);
     }
 }