Ejemplo n.º 1
0
 public async Task <string> ExecuteWhisperCommandIfApplicable(Dictionary <string, string> args, IServiceScopeFactory scopeFactory)
 {
     if (args["message"].ToLower().StartsWith(Trigger) || args["message"].ToLower().StartsWith(Alias))
     {
         using (var scope = scopeFactory.CreateScope())
         {
             var _context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
             if (_context.RandomChatUser.Where(x => x.ChatUser == args["username"] && x.Stream == args["channel"]).Count() == 0)
             {
                 RandomChatUser tmp = new RandomChatUser();
                 tmp.ChatUser = args["username"];
                 tmp.Stream   = args["channel"];
                 if (_context.RandomChatUser.Where(x => x.Stream == args["channel"]).Count() == 0)
                 {
                     tmp.Sort = 1;
                 }
                 else
                 {
                     tmp.Sort = _context.RandomChatUser.Where(x => x.Stream == args["channel"]).Max(t => t.Sort) + 1;
                 }
                 _context.RandomChatUser.Add(tmp);
                 _context.SaveChanges();
                 return("You were added.");
             }
             else
             {
                 return("Already in the List");
             }
         }
     }
     return("");
 }
Ejemplo n.º 2
0
        public async Task <ChatCommandOutput> execute(ChatCommandInputArgs args, IServiceScopeFactory scopeFactory)
        {
            ChatCommandOutput output = new ChatCommandOutput();

            output.ExecuteEvent = false;
            output.Type         = Eventbus.EventType.CommandResponseReceived;
            string message = "No skippable user found";

            if (args.elevatedPermissions && (args.Message.ToLower().StartsWith(Trigger) || args.Message.ToLower().StartsWith(Alias)))
            {
                output.ExecuteEvent = true;
                using (var scope = scopeFactory.CreateScope())
                {
                    var _context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
                    if (_context.RandomChatUser.Where(x => x.Stream == args.ChannelName && x.lastchecked).Count() > 0)
                    {
                        var skippeduser = _context.RandomChatUser.Where(x => x.Stream == args.ChannelName && x.lastchecked).FirstOrDefault();
                        if (skippeduser != null)
                        {
                            _context.RandomChatUser.Remove(skippeduser);
                            RandomChatUser tmp = new RandomChatUser();
                            tmp.ChatUser    = skippeduser.ChatUser;
                            tmp.lastchecked = false;
                            if (_context.RandomChatUser.Where(x => x.Stream == args.ChannelName).Count() == 0)
                            {
                                tmp.Sort = 1;
                            }
                            else
                            {
                                tmp.Sort = _context.RandomChatUser.Where(x => x.Stream == args.ChannelName).Max(t => t.Sort) + 1;
                            }
                            tmp.Stream = skippeduser.Stream;
                            _context.RandomChatUser.Add(tmp);
                            _context.SaveChanges();
                            message = "User skipped";
                        }
                    }
                }
                output.EventData = new CommandResponseArgs(args.Type, message, MessageType.ChannelMessage, args.Sender, args.ChannelName);
            }
            return(output);
        }
Ejemplo n.º 3
0
        public async Task <ChatCommandOutput> execute(ChatCommandInputArgs args, IServiceScopeFactory scopefactory)
        {
            ChatCommandOutput output = new ChatCommandOutput();

            output.ExecuteEvent = true;
            output.Type         = Eventbus.EventType.CommandResponseReceived;
            string message = "";

            using (var scope = scopefactory.CreateScope())
            {
                var _context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
                if (_context.RandomChatUser.Where(x => x.ChatUser.ToLower() == args.Sender.ToLower() && x.Stream.ToLower() == args.ChannelName.ToLower()).Count() == 0)
                {
                    RandomChatUser tmp = new RandomChatUser();
                    tmp.ChatUser = args.Sender;
                    tmp.Stream   = args.ChannelName;
                    if (_context.RandomChatUser.Where(x => x.Stream.ToLower() == args.ChannelName.ToLower()).Count() == 0)
                    {
                        tmp.Sort = 1;
                    }
                    else
                    {
                        tmp.Sort = _context.RandomChatUser.Where(x => x.Stream.ToLower() == args.ChannelName.ToLower()).Max(t => t.Sort) + 1;
                    }
                    _context.RandomChatUser.Add(tmp);
                    _context.SaveChanges();
                    message = "You were added.";
                }
                else
                {
                    message = "Already in the List";
                }
            }
            output.EventData = new CommandResponseArgs(args.Type, message, MessageType.PrivateMessage, args.Sender, args.ChannelName);
            return(output);
        }