本文整理汇总了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("/", "");
//.........这里部分代码省略.........
示例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