• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CommandTarget类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CommandTarget的典型用法代码示例。如果您正苦于以下问题:C# CommandTarget类的具体用法?C# CommandTarget怎么用?C# CommandTarget使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CommandTarget类属于命名空间,在下文中一共展示了CommandTarget类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsMod(target) || parameters.Length == 0)
                return;

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            if (!Account.Exists(parameters[0]))
            {
                target.Send("Account does not exist.");
                return;
            }

            if (Util.IsAdmin(target.Room, parameters[0]))
            {
                target.Send("Administrators can not be banned.");
                return;
            }

            string sourceUser;
            if (target.IsWeb)
                sourceUser = target.Connection.Session.Account.Name;
            else
                sourceUser = string.Format("steam:{0:D}", (ulong)target.SteamId);

            Program.Logger.InfoFormat("User '{0}' unbanning '{1}'", sourceUser, parameters[0]);

            target.Room.Unban(parameters[0]);
            target.Send("Account unbanned.");
        }
开发者ID:krixalis,项目名称:RohBot,代码行数:34,代码来源:Unban.cs


示例2: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target) || parameters.Length < 1)
                return;

            Program.RoomManager.Broadcast("Broadcast: " + parameters[0]);
        }
开发者ID:Rohansi,项目名称:RohBot,代码行数:7,代码来源:Broadcast.cs


示例3: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || !target.IsRoom || parameters.Length == 0)
                return;

            if (Program.DelayManager.AddAndCheck(target.Connection, DelayManager.Message))
                return;

            var username = target.Connection.Session.Account.Name;
            var room = target.Room;
            if (room.IsBanned(username))
            {
                target.Send("You are banned from this room.");
                return;
            }

            var line = new StateLine(
                Util.GetCurrentTimestamp(),
                target.Room.RoomInfo.ShortName,
                "Action",
                username,
                target.Connection.Session.Account.Id.ToString("D"),
                "RohBot",
                "", "0", "",
                string.Format("{0} {1}", username, parameters[0]));

            target.Room.SendLine(line);
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:28,代码来源:Me.cs


示例4: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsSession || !target.IsRoom || !(target.Room is MafiaRoom))
                return;

            var room = (MafiaRoom)target.Room;
            var userList = new Packets.UserList();

            if (room.IsPlaying)
            {
                foreach (var player in room.Players)
                {
                    userList.AddUser(player.Alias, "0", "Member", "", "", true);
                }
            }
            else
            {
                var sessions = Program.SessionManager.List.Where(s => s.Account != null).ToList();
                var accounts = sessions.Where(s => s.Room == room.RoomInfo.ShortName).Select(s => s.Account).Distinct(new Account.Comparer());

                foreach (var account in accounts)
                {
                    var userId = account.Id.ToString();
                    userList.AddUser(account.Name, userId, "Member", "", "", true);
                }
            }

            userList.Users = userList.Users.OrderBy(u => u.Name).ToList();
            target.Session.Send(userList);
        }
开发者ID:ToXIcGaming,项目名称:SteamMobile,代码行数:30,代码来源:Users.cs


示例5: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsAdmin(target) || parameters.Length == 0)
                return;

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            if (!Account.Exists(parameters[0]))
            {
                target.Send("Account does not exist.");
                return;
            }

            if (!target.Room.IsMod(parameters[0]))
            {
                target.Send("Account is not a mod.");
                return;
            }

            target.Room.Demod(parameters[0]);
            target.Send("Account demodded.");
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:26,代码来源:Demod.cs


示例6: Handle

 public override void Handle(Connection connection)
 {
     // TODO: move implementation here later
     var commandTarget = new CommandTarget(connection, Target);
     var command = new Commands.Users();
     command.Handle(commandTarget, command.Type, new string[0]);
 }
开发者ID:Rohansi,项目名称:RohBot,代码行数:7,代码来源:UserListRequest.cs


示例7: SetUp

        public void SetUp()
        {
            disposables = new CompositeDisposable
            {
                VirtualClock.Start()
            };

            clockName = Any.CamelCaseName();
            targetId = Any.Word();
            target = new CommandTarget(targetId);
            store = new InMemoryStore<CommandTarget>(
                _ => _.Id,
                id => new CommandTarget(id))
            {
                target
            };

            CommandSchedulerDbContext.NameOrConnectionString =
                @"Data Source=(localdb)\MSSQLLocalDB; Integrated Security=True; MultipleActiveResultSets=False; Initial Catalog=ItsCqrsTestsCommandScheduler";

            configuration = new Configuration()
                .UseInMemoryCommandScheduling()
                .UseDependency<IStore<CommandTarget>>(_ => store)
                .UseDependency<GetClockName>(c => _ => clockName)
                .TraceScheduledCommands();

            scheduler = configuration.CommandScheduler<CommandTarget>();

            Command<CommandTarget>.AuthorizeDefault = (commandTarget, command) => true;

            disposables.Add(ConfigurationContext.Establish(configuration));
            disposables.Add(configuration);
        }
开发者ID:PhillipPruett,项目名称:Its.Cqrs,代码行数:33,代码来源:NonEventSourcedAggregateCommandSchedulingTests.cs


示例8: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target))
                return;

            Program.Steam.Disconnect(); // should auto-reconnect
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:7,代码来源:FixSteam.cs


示例9: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsSession || !target.IsRoom || target.Session.Account == null || !(target.Room is MafiaRoom))
                return;

            var room = (MafiaRoom)target.Room;

            if (room.IsPlaying)
            {
                target.Send("A game is currently in progress. You must wait until it has finished to join.");
                return;
            }

            if (parameters.Length < 1)
            {
                target.Send("You must specify an alias to join the game: /join Brian");
                return;
            }

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send(Util.InvalidUsernameMessage);
                return;
            }

            // TODO: add to game
        }
开发者ID:ToXIcGaming,项目名称:SteamMobile,代码行数:27,代码来源:Join.cs


示例10: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !Util.IsMod(target) || parameters.Length == 0)
                return;

            if (!Util.IsValidUsername(parameters[0]))
            {
                target.Send("Invalid username.");
                return;
            }

            if (!Account.Exists(parameters[0]))
            {
                target.Send("Account does not exist.");
                return;
            }

            if (Util.IsAdmin(target.Room, parameters[0]))
            {
                target.Send("Administrators can not be banned.");
                return;
            }

            if (!target.Room.IsWhitelisted)
                target.Room.Unban(parameters[0]);
            else
                target.Room.Ban(parameters[0]);

            target.Send("Account unbanned.");
        }
开发者ID:ToXIcGaming,项目名称:SteamMobile,代码行数:30,代码来源:Unban.cs


示例11: Commandform

		public Commandform(CommandTarget commandTarget) {
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
            m_commandTarget = commandTarget;
		}
开发者ID:JnS-Software-LLC,项目名称:iiop-net,代码行数:7,代码来源:ClientForm.cs


示例12: SetUp

        public void SetUp()
        {
            disposables = new CompositeDisposable
            {
                VirtualClock.Start()
            };

            clockName = Any.CamelCaseName();
            targetId = Any.Word();
            target = new CommandTarget(targetId);
            store = new InMemoryStore<CommandTarget>(
                _ => _.Id,
                id => new CommandTarget(id))
            {
                target
            };

            configuration = new Configuration()
                .UseInMemoryCommandScheduling()
                .UseDependency<IStore<CommandTarget>>(_ => store)
                .UseDependency<GetClockName>(c => _ => clockName)
                .TraceScheduledCommands();

            scheduler = configuration.CommandScheduler<CommandTarget>();

            Command<CommandTarget>.AuthorizeDefault = (commandTarget, command) => true;

            disposables.Add(ConfigurationContext.Establish(configuration));
            disposables.Add(configuration);
        }
开发者ID:charlesmccarthyirl,项目名称:Its.Cqrs,代码行数:30,代码来源:NonEventSourcedAggregateCommandSchedulingTests.cs


示例13: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target))
                return;

            Program.Logger.Info("Reboot requested");
            Environment.Exit(0);
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:8,代码来源:Reboot.cs


示例14: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || !(target.Room is ScriptRoom) || !Util.IsSuperAdmin(target))
                return;

            var scriptRoom = (ScriptRoom)target.Room;
            scriptRoom.Recompile();
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:8,代码来源:Compile.cs


示例15: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!Util.IsSuperAdmin(target))
                return;

            var sessions = Program.SessionManager.List.Select(s => string.Format("{0} ({1})", s.Account.Name, s.ConnectionCount));
            var sessionsText = string.Join(", ", sessions);
            target.Send(string.Format("Active sessions: {0}", sessionsText));
        }
开发者ID:krixalis,项目名称:RohBot,代码行数:9,代码来源:Sessions.cs


示例16: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || !Util.IsSuperAdmin(target))
                return;

            var sessions = Program.SessionManager.List.Select(s => $"{s.Account.Name} ({s.ConnectionCount})");
            var sessionsText = string.Join(", ", sessions);
            target.Send($"Sessions: {sessionsText}");
        }
开发者ID:Rohansi,项目名称:RohBot,代码行数:9,代码来源:Sessions.cs


示例17: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsRoom || target.IsPrivateChat)
                return;

            var room = target.Room;
            var roomName = room.RoomInfo.ShortName;

            var sessions = Program.SessionManager.List;
            var accounts = sessions.Where(s => s.IsInRoom(roomName))
                                   .Select(s => s.Account)
                                   .Distinct(new Account.Comparer());

            if (target.IsWeb)
            {
                var userList = new Packets.UserList();

                var steamRoom = room as SteamRoom;
                var chat = steamRoom != null && Program.Steam.Status == Steam.ConnectionStatus.Connected ? steamRoom.Chat : null;

                if (chat != null)
                {
                    var steamUsers = chat.Users.Select(p => p.Id)
                                               .Where(i => i != Program.Steam.Bot.SteamId);

                    foreach (var id in steamUsers)
                    {
                        var persona = Program.Steam.Bot.GetPersona(id);
                        var steamId = id.ConvertToUInt64().ToString("D");
                        var groupMember = chat.Group.Members.FirstOrDefault(m => m.Persona.Id == id);
                        var rank = groupMember != null ? GetRankString(groupMember.Rank) : "Guest";
                        var avatar = BitConverter.ToString(persona.Avatar).Replace("-", "").ToLower();
                        var status = GetStatusString(persona.State);
                        userList.AddUser(persona.DisplayName, steamId, rank, avatar, status, persona.PlayingName, false);
                    }
                }

                foreach (var account in accounts)
                {
                    var userId = account.Id.ToString("D");
                    var rank = GetRankString(target.Room, account.Name);
                    userList.AddUser(account.Name, userId, rank, "", "", null, true);
                }

                userList.ShortName = roomName;
                userList.Users = userList.Users.OrderBy(u => u.Name, StringComparer.InvariantCultureIgnoreCase).ToList();
                target.Connection.Send(userList);
            }
            else
            {
                var names = accounts.OrderBy(a => a.Name, StringComparer.InvariantCultureIgnoreCase)
                                    .Select(a => a.Name);

                target.Send("In this room: " + string.Join(", ", names));
            }
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:56,代码来源:Users.cs


示例18: Format

        public override string Format(CommandTarget target, string type)
        {
            if (!target.IsRoom || !(target.Room is ScriptRoom))
                return "";

            var scriptRoom = (ScriptRoom)target.Room;
            ScriptRoom.CommandHandler command;

            return scriptRoom.Commands.TryGetValue(type, out command) ? command.Format : null;
        }
开发者ID:ToXIcGaming,项目名称:SteamMobile,代码行数:10,代码来源:Default.cs


示例19: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsWeb || parameters.Length == 0)
                return;

            if (Program.DelayManager.AddAndCheck(target.Connection, DelayManager.Database))
                return;

            target.Connection.Session.Leave(parameters[0]);
        }
开发者ID:Naarkie,项目名称:RohBot,代码行数:10,代码来源:Leave.cs


示例20: Handle

        public override void Handle(CommandTarget target, string type, string[] parameters)
        {
            if (!target.IsSession || target.Session.Account == null)
                return;

            if (parameters.Length < 1)
            {
                target.Send("Currently in room: " + target.Session.Room);
                return;
            }

            if (Program.DelayManager.AddAndCheck(target.Session, 2.5))
                return;

            switch (parameters[0])
            {
                case "default":
                    {
                        var defaultRoom = target.Session.Account.DefaultRoom;
                        var newRoom = parameters.Length < 2 ? defaultRoom : parameters[1];

                        if (!target.Session.SwitchRoom(newRoom))
                            break;

                        if (parameters.Length >= 2)
                        {
                            target.Session.Account.DefaultRoom = target.Session.Room;
                            target.Session.Account.Save();
                        }

                        target.Send("Switched to room: " + newRoom);
                        break;
                    }

                case "list":
                    {
                        var roomNames = Program.RoomManager.List
                            .Where(r => !r.IsHidden)
                            .Select(r => r.RoomInfo)
                            .Select(r => string.Format("{0} ({1})", r.Name, r.ShortName));
                        target.Send("Available rooms: " + string.Join(", ", roomNames));
                        break;
                    }

                default:
                    {
                        if (!target.Session.SwitchRoom(parameters[0]))
                            break;

                        target.Send("Switched to room: " + parameters[0]);
                        break;
                    }
            }
        }
开发者ID:ToXIcGaming,项目名称:SteamMobile,代码行数:54,代码来源:ChangeRoom.cs



注:本文中的CommandTarget类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# CommandType类代码示例发布时间:2022-05-24
下一篇:
C# CommandStatus类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap