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


C# SteamFriends.SetPersonaName方法代码示例

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


在下文中一共展示了SteamFriends.SetPersonaName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


//.........这里部分代码省略.........
						if(WebCookies!=null){
							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
开发者ID:ampped101,项目名称:SteamBot,代码行数:67,代码来源:Main.cs


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