當前位置: 首頁>>代碼示例>>C#>>正文


C# SteamFriends.SetPersonaState方法代碼示例

本文整理匯總了C#中SteamKit2.SteamFriends.SetPersonaState方法的典型用法代碼示例。如果您正苦於以下問題:C# SteamFriends.SetPersonaState方法的具體用法?C# SteamFriends.SetPersonaState怎麽用?C# SteamFriends.SetPersonaState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SteamKit2.SteamFriends的用法示例。


在下文中一共展示了SteamFriends.SetPersonaState方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

        static void Main(string[] args)
        {


            

            Console.ForegroundColor = ConsoleColor.DarkCyan;

            System.Console.Title = "TradeBot";
            System.Console.WriteLine("Welcome to TradeBot!\nCreated by Jessecar.\nTurn of Steam Guard before loggin in!\n\n");

            Console.ForegroundColor = ConsoleColor.White;

            printConsole("Steam Username:");
            String username = "jessecar96"; //Console.ReadLine();

            System.Console.WriteLine("Steam Password: ");

            //heckey
            Console.ForegroundColor = Console.BackgroundColor;

            String password = Console.ReadLine();

            Console.ForegroundColor = ConsoleColor.White;

            SteamClient steamClient = new SteamClient(); // initialize our client
            SteamUser steamUser = steamClient.GetHandler<SteamUser>();
            steamFriends = steamClient.GetHandler<SteamFriends>();
            SteamTrading trade = steamClient.GetHandler<SteamTrading>();

            steamClient.Connect(); // connect to the steam network

            while (true)
            {

                if (Console.KeyAvailable)
                {
                    printConsole(Console.ReadLine(), ConsoleColor.Yellow);
                }

                CallbackMsg msg = steamClient.WaitForCallback(true); // block and wait until a callback is posted

                //Print out callbacks
                //printConsole(msg.ToString());


                //Steam Connection
                msg.Handle<SteamClient.ConnectedCallback>(callback =>
                {
                    if (callback.Result != EResult.OK)
                    {
                        printConsole("Sorry, could not connect to Steam.");
                    }
                    steamUser.LogOn(new SteamUser.LogOnDetails
                    {
                        Username = username,
                        Password = password,
                    });
                });


                //Login Callback
                msg.Handle<SteamUser.LoggedOnCallback>(callback =>
                {
                    if (callback.Result != EResult.OK)
                    {
                        printConsole("Incorrect username or Password. Make sure you have disabled steam guard!");
                    }
                    else
                    {
                        printConsole("Connected to Steam!\nWelcome "+steamUser.SteamID);
                        steamFriends.SetPersonaName("ChatBot Beta (Say hi)");
                        steamFriends.SetPersonaState((EPersonaState)6);
                    }
                });

                //Chat Messages
                msg.Handle<SteamFriends.FriendMsgCallback>(callback =>
                {
                    EChatEntryType type = callback.EntryType;

                    

                    if (type == EChatEntryType.ChatMsg)
                    {

                        SteamID sid = callback.Sender;

                        if (!clients.Contains(callback.Sender))
                        {
                            printConsole("[New Client]" + callback.Sender, ConsoleColor.Magenta);
                            clients.Add(callback.Sender);

                            steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Welcome to TradeBot created by Jessecar.  To see a list of commands type /help");
                        }

                        if (callback.Message.StartsWith("/"))
                        {
                            
                            string message = callback.Message.Replace("/", "");
//.........這裏部分代碼省略.........
開發者ID:ampped101,項目名稱:SteamBot,代碼行數:101,代碼來源:Program.cs

示例2: Main

 static void Main(string[] args)
 {
     Console.WriteLine("Steam Trading Card Farmer\n");
     if (!STCFNet.CheckForInternetConnection())
     {
         STCFNet.WriteError("No internet connection!");
     }
     Console.WriteLine("Username:");
     user = Console.ReadLine();
     Console.WriteLine("Password:");
     pass = Console.ReadLine();
     steamClient = new SteamClient();
     manager = new CallbackManager(steamClient);
     steamUser = steamClient.GetHandler<SteamUser>();
     steamFriends = steamClient.GetHandler<SteamFriends>();
     new Callback<SteamClient.ConnectedCallback>(OnConnected, manager);
     new Callback<SteamClient.DisconnectedCallback>(OnDisconnected, manager);
     new Callback<SteamUser.LoggedOnCallback>(OnLoggedOn, manager);
     new Callback<SteamUser.LoggedOffCallback>(OnLoggedOff, manager);
     new JobCallback<SteamUser.UpdateMachineAuthCallback>(OnMachineAuth, manager);
     isRunning = true;
     STCFNet.WriteInfo("Connecting to Steam...");
     steamClient.Connect();
     steamFriends.SetPersonaState(EPersonaState.Online);
     while (isRunning)
     {
         manager.RunWaitCallbacks(TimeSpan.FromSeconds(1));
     }
 }
開發者ID:Easimer,項目名稱:SteamTradingCardFarmer,代碼行數:29,代碼來源:src.cs

示例3: Main


//.........這裏部分代碼省略.........
							printConsole ("SteamWeb Cookies retrived.",ConsoleColor.Green);
							//Do Login
							steamUser.LogOn (new SteamUser.LogOnDetails{
								Username = user,
								Password = pass
							});
						}else{
							printConsole ("Error while getting SteamWeb Cookies.",ConsoleColor.Red);
						}
						
					}else{
						
						//Failure
						printConsole ("Failed to Connect to steam.",ConsoleColor.Red);	
					}
					
				});
				#endregion
				
				
				#region Steam Login Handler
				//Logged in (or not)
				msg.Handle<SteamUser.LoggedOnCallback>( callback =>
        		{
					printConsole("Logged on callback: "+callback.Result, ConsoleColor.Cyan);
					
					if(callback.Result != EResult.OK){
						printConsole("Login Failed!",ConsoleColor.Red);
					}else{
						printConsole("Successfulyl Logged In!\nWelcome "+steamUser.SteamID,ConsoleColor.Green);
						
						//Set community status
						steamFriends.SetPersonaName(BotPersonaName);
						steamFriends.SetPersonaState(BotPersonaState);
					}
					
        		});
				#endregion
				
				
				#region Steam Trade Start
				/**
				 * 
				 * Steam Trading Handler
				 *  
				 */
				msg.Handle<SteamTrading.TradeStartSessionCallback>(call =>
				{
					
					//Trading
					trade = null;
					trade = new TradeSystem();
					trade.initTrade(steamUser.SteamID,call.Other,WebCookies);
					
				});
				#endregion
				
				#region Trade Requested Handler
				//Don't modify this
				msg.Handle<SteamTrading.TradeProposedCallback>( thing =>
				{
					//Trade Callback
					printConsole ("Trade Proposed Callback. Other: "+thing.Other+"\n");
					
					//Accept It
					steamTrade.RequestTrade(thing.Other);
開發者ID:ampped101,項目名稱:SteamBot,代碼行數:67,代碼來源:Main.cs


注:本文中的SteamKit2.SteamFriends.SetPersonaState方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。