当前位置: 首页>>代码示例>>C#>>正文


C# SteamKit2.SteamFriends类代码示例

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


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

示例1: GroupRun

        public void GroupRun(SteamFriends.ChatMsgCallback callback, Bot bot, object[] args = null)
        {
            Random rnd = new Random();

            string result = Util.RandomChoice<string>(Util.eightballAnswers);

            bot.ChatroomMessage(bot.chatRoomID, result);
        }
开发者ID:nukeop,项目名称:SteamRelayBot,代码行数:8,代码来源:EightBall.cs

示例2: Events_OnChatMsgCallbaack

        void Events_OnChatMsgCallbaack(SteamFriends.ChatMsgCallback msg)
        {
            var userId = msg.ChatterID.ConvertToUInt64();
            var message = msg.Message;

            if (userId == 76561198071890301)
            {
                if (msg.Message.StartsWith("["))
                {
                    var nameEnd = message.IndexOf(']');
                    var name = message.Substring(1, nameEnd - 1);
                    var content = message.Substring(nameEnd + 2);
                    userId = (ulong)Math.Abs(name.GetHashCode());

                    if (!rohUsers.ContainsValue(name))
                        rohUsers[userId] = name;

                    message = content;
                } else {
                    return;
                }
            }

            if (IsReservedFunction(message))
                return;

            if (Ignored.Contains(userId))
                return;

            var bucket = GetBucket(msg.ChatRoomID);
            bucket.ProcessMessage(userId, message);
        }
开发者ID:benjojo,项目名称:PublicSwBPlugins,代码行数:32,代码来源:Plugin.cs

示例3: Login

        private static void Login()
        {
            steamClient = new SteamClient();
            callBackManager = new CallbackManager(steamClient);
            steamFriends = steamClient.GetHandler<SteamFriends>();
            steamUser = steamClient.GetHandler<SteamUser>();

            callBackManager.Subscribe<SteamClient.ConnectedCallback>(OnConnected);
            callBackManager.Subscribe<SteamUser.LoggedOnCallback>(OnLoggedIn);
            callBackManager.Subscribe<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth);
            callBackManager.Subscribe<SteamClient.DisconnectedCallback>(OnDisconnected);
            callBackManager.Subscribe<SteamFriends.FriendMsgCallback>(OnMsgRecieved);
            callBackManager.Subscribe<SteamUser.AccountInfoCallback>(OnAccountInfo);
            callBackManager.Subscribe<SteamFriends.FriendsListCallback>(OnFriendsList);
            callBackManager.Subscribe<SteamFriends.FriendAddedCallback>(OnFriendAdded);
            callBackManager.Subscribe<SteamFriends.PersonaStateCallback>(OnFriendPersonaChange);

            SteamDirectory.Initialize().Wait();
            steamClient.Connect();

            isRunning = true;

            while (isRunning)
            {
                callBackManager.RunWaitCallbacks(TimeSpan.FromSeconds(0.5));
            }

            Console.ReadKey();
        }
开发者ID:anthony-y,项目名称:bot-anthony,代码行数:29,代码来源:BOT.cs

示例4: CheckVote

        /// <summary>
        /// Checks if what a person typed was a vote and counts them.
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="args"></param>
        public void CheckVote(SteamFriends.ChatMsgCallback callback, string[] args)
        {
            var name = SteamNerd.ChatterNames[callback.ChatterID];
            var message = callback.Message.ToLower();

            if (!_voting || _voters.Contains(callback.ChatterID))
            {
                return;
            }

            if (message == "aye")
            {
                _ayes++;
                SteamNerd.SendMessage(string.Format("{0} voted aye", name), callback.ChatRoomID);
            }
            else if (message == "nay")
            {
                _nays++;
                SteamNerd.SendMessage(string.Format("{0} voted nay", name), callback.ChatRoomID);
            }
            else
            {
                return;
            }

            _voters.Add(callback.ChatterID);

            if (_voters.Count == SteamNerd.ChatterNames.Count - 1)
            {
                _voteTimer.Stop();
                TallyVotes(callback);
            }
        }
开发者ID:bakerj76,项目名称:SteamNerd,代码行数:38,代码来源:Democracy.cs

示例5: GetHelp

        public void GetHelp(SteamFriends.ChatMsgCallback callback, string[] args)
        {
            //var chat = callback.ChatRoomID;

            //if (args.Length == 1)
            //{
            //    var message = "Help is here to help you.\nModules:\n";

            //    foreach (var module in SteamNerd.Modules)
            //    {
            //        if (module.Name != null && module.Name != "")
            //        {
            //            message += module.Name + "\n";
            //        }
            //    }

            //    message += "\nIf you would like more help on a certain module, type {0}help [module]";

            //    SteamNerd.SendMessage(string.Format(message, SteamNerd.CommandChar), chat);
            //}
            //else
            //{
            //    var modString = args.Skip(1).Aggregate((mod, next) => mod + " " + next);

            //    var module = SteamNerd.GetModule(modString);

            //    if (module == null)
            //    {
            //        SteamNerd.SendMessage(string.Format("Module {0} not found!", args[1]), chat);
            //        return;
            //    }

            //    ModuleHelp(module, chat);
            //}
        }
开发者ID:bakerj76,项目名称:SteamNerd,代码行数:35,代码来源:Help.cs

示例6: GroupRun

 public void GroupRun(SteamFriends.ChatMsgCallback callback, Bot bot, object[] args = null)
 {
     List<string> strings = new List<string>(callback.Message.Split(' '));
     strings.RemoveAt(0);
     string company = String.Join(" ", strings.ToArray());
     bot.ChatroomMessage(bot.chatRoomID, Util.GetYahooStocks(company));
 }
开发者ID:nukeop,项目名称:SteamRelayBot,代码行数:7,代码来源:Stock.cs

示例7: FriendRun

 public void FriendRun(SteamFriends.FriendMsgCallback callback, Bot bot, object[] args = null)
 {
     List<string> strings = new List<string>(callback.Message.Split(' '));
     strings.RemoveAt(0);
     string company = String.Join(" ", strings.ToArray());
     bot.FriendMessage(callback.Sender, Util.GetYahooStocks(company));
 }
开发者ID:nukeop,项目名称:SteamRelayBot,代码行数:7,代码来源:Stock.cs

示例8: LogIn

        static void LogIn()
        {
            steamClient = new SteamClient();
            callbackManager = new CallbackManager(steamClient);
            steamUser = steamClient.GetHandler<SteamUser>();
            steamFriends = steamClient.GetHandler<SteamFriends>();
            steamTrading = steamClient.GetHandler<SteamTrading>();
            new Callback<SteamClient.ConnectedCallback>(OnConnect,callbackManager);
            new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, callbackManager);
            new Callback<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth, callbackManager);
            new Callback<SteamClient.DisconnectedCallback>(OnDisconnected, callbackManager);
            new Callback<SteamUser.AccountInfoCallback>(OnAccountInfo, callbackManager);
            new Callback<SteamFriends.FriendMsgCallback>(OnChatMessage, callbackManager);
            new Callback<SteamFriends.FriendsListCallback>(OnFriendInvite, callbackManager);
            new Callback<SteamTrading.TradeProposedCallback>(OnTradeOffer, callbackManager);
            new Callback<SteamTrading.SessionStartCallback>(OnTradeWindow, callbackManager);
            new Callback<SteamTrading.TradeResultCallback>(OnTradeResult, callbackManager);

            isRunning = true;

            Console.WriteLine("Attempting to connect to steam...");

            steamClient.Connect();

            while(isRunning)
            {
                callbackManager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
            }
            Console.ReadKey();
        }
开发者ID:Hydromaniaccat,项目名称:SteamBot,代码行数:30,代码来源:Program.cs

示例9: CheckForLetter

 public void CheckForLetter(SteamFriends.ChatMsgCallback callback, string[] args)
 {
     if (_inProgress && callback.Message.Contains(_bannedLetter.ToString()))
     {
         SteamNerd.SteamFriends.KickChatMember(callback.ChatRoomID, callback.ChatterID);
     }
 }
开发者ID:bakerj76,项目名称:SteamNerd,代码行数:7,代码来源:LetterGames.cs

示例10: Bot

		public Bot(Configuration.BotInfo config, string apiKey, bool debug = false) {
			sql = new Sql();

			Username = config.Username;
			Password = config.Password;
			DisplayName = config.DisplayName;
			Admins = config.Admins;
			id = config.Id;
			this.apiKey = apiKey;

			TradeListener = new ScrapTrade(this);
			TradeListenerInternal = new ExchangeTrade(this);
			TradeListenerAdmin = new AdminTrade(this);

			List<object[]> result = sql.query("SELECT text, response FROM responses");
			foreach (object[] row in result) {
				responses.Add(((string) row[0]).ToLower(), (string) row[1]);
			}

			// Hacking around https
			ServicePointManager.ServerCertificateValidationCallback += SteamWeb.ValidateRemoteCertificate;

			SteamClient = new SteamClient();
			SteamTrade = SteamClient.GetHandler<SteamTrading>();
			SteamUser = SteamClient.GetHandler<SteamUser>();
			SteamFriends = SteamClient.GetHandler<SteamFriends>();
			queueHandler = new QueueHandler(this);

			SteamClient.Connect();

			while (true) {
				Update();
			}
		}
开发者ID:Top-Cat,项目名称:SteamBot,代码行数:34,代码来源:Bot.cs

示例11: EnterDuel

        public void EnterDuel(SteamFriends.ChatMsgCallback callback, string[] args)
        {
            var dueler = callback.ChatterID;
            var chat = callback.ChatRoomID;
            var name = SteamNerd.ChatterNames[dueler];

            if (_inProgress || _players.Contains(dueler)) return;

            _players.Add(dueler);

            if (_players.Count == 1)
            {
                SteamNerd.SendMessage(string.Format("{0} wants to duel someone! Bring it on!", name),
                    chat);
            }
            else if (_players.Count == 2)
            {
                var challengerName = SteamNerd.ChatterNames[_players[0]];

                _inProgress = true;
                SteamNerd.SendMessage(string.Format("{0} is dueling {1}! D-d-d-d-d-duel.", challengerName, name), chat);

                var countdown = new Countdown(SteamNerd, chat, (src, e) => StartDuel(callback), 4f, 3);

                var webRequest = WebRequest.Create("http://randomword.setgetgo.com/get.php");
                var webResponse = webRequest.GetResponse();
                var buffer = new StringBuilder();

                using (var stream = new StreamReader(webResponse.GetResponseStream()))
                {
                    _word = stream.ReadToEnd().ToLower().Trim();
                }
            }
        }
开发者ID:bakerj76,项目名称:SteamNerd,代码行数:34,代码来源:Duel.cs

示例12: GetTodo

        public void GetTodo(SteamFriends.ChatMsgCallback callback, string[] args)
        {
            if (args.Length == 1)
            {
                PrintTodo(callback);
            }
            else
            {
                var subcommand = args[1];

                switch (subcommand)
                {
                    case "add":
                        AddTodo(callback.ChatRoomID, args);
                        break;
                    case "remove":
                        RemoveTodo(callback.ChatRoomID, args);
                        break;
                    default:
                        var message = string.Format("Unknown subcommand. Use {0}help for help.", SteamNerd.CommandChar);
                        SteamNerd.SendMessage(message, callback.ChatRoomID);
                        break;
                }
            }
        }
开发者ID:bakerj76,项目名称:SteamNerd,代码行数:25,代码来源:Todo.cs

示例13: OnFriendChatEnter

 public override void OnFriendChatEnter(SteamFriends.PersonaStateCallback callback)
 {
     if (!_cooldowns.Keys.Contains(callback.FriendID))
     {
         _cooldowns[callback.FriendID] = new Stopwatch();
     }
 }
开发者ID:bakerj76,项目名称:SteamNerd,代码行数:7,代码来源:TrollSlayer.cs

示例14: DoTheBet

        public void DoTheBet(SteamFriends.ChatMsgCallback callback, string[] args)
        {
            var chat = callback.ChatRoomID;
            var chatter = callback.ChatterID;
            var name = SteamNerd.ChatterNames[chatter];

            // If someone bets early
            if (!_inProgress)
            {
                SteamNerd.SendMessage(string.Format("There's no match to bet on, {0}. Good job, idiot.", name), chat);
            }
            else if (!_betTimerOver)
            {
                if (args.Length < 3)
                {
                    SteamNerd.SendMessage(string.Format("Usage: {0}bet [player] [money]", SteamNerd.CommandChar), chat);
                    return;
                }

                int bet;

                if (!int.TryParse(args[2], out bet))
                {
                    SteamNerd.SendMessage(string.Format("Usage: {0}bet [player] [money]", SteamNerd.CommandChar), chat);
                    return;
                }

                AddBet(callback.ChatterID, callback.ChatRoomID, args[1], bet);
            }
        }
开发者ID:bakerj76,项目名称:SteamNerd,代码行数:30,代码来源:Roulette.cs

示例15: PrivateCommands

        public static void PrivateCommands(string chatMessage, SteamFriends.FriendMsgCallback callback)
        {
            privateActor = callback;

            if(callback.Sender != 76561197993698595) {
                return;
            }

            ChatCommander chatCommander = new ChatCommander();
            MethodInfo mi;
            GroupCollection paramList = null;

            Dictionary<string, string> rouletteCommands = new Dictionary<string, string>{
                {@"^!addAlias (.+) ([0-9]+)$","AddNewAlias"},
                {@"^!aliasList$","ListAliases"}
            };

            foreach(KeyValuePair<string, string> entry in rouletteCommands) {

                Regex rgx = new Regex(entry.Key);

                Match m = rgx.Match(chatMessage);

                if(m.Success) {

                    paramList = m.Groups;

                    mi = chatCommander.GetType().GetMethod(entry.Value);
                    mi.Invoke(chatCommander, new object[] { paramList });
                    return;

                }

            }
        }
开发者ID:ZacMillionaire,项目名称:RapscallionSharp,代码行数:35,代码来源:ChatCommander.cs


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