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


C# SteamFriends.GetFriendRelationship方法代码示例

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


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

示例1: Main


//.........这里部分代码省略.........
                                case "trade":
                                    //Send a trade
                                    trade.RequestTrade(callback.Sender);
                                    printConsole("Trade requested by " + callback.Sender + " (" + steamFriends.GetFriendPersonaName(callback.Sender) + ")", ConsoleColor.Green);
                                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "initiated a trade request.");
                                    break;
                                case "remove":
                                    //Remove Friend
                                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Thank you for using the Steam TradeBot BETA.");
                                    steamFriends.RemoveFriend(callback.Sender);
                                    printConsole("[Friend] Friend Removed: " + callback.Sender + " (" + steamFriends.GetFriendPersonaName(callback.Sender) + ")", ConsoleColor.Yellow);
                                    break;
                                case "status":
                                    //get status (nothing)
                                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "is Online and working good.");
                                    break;
                                case "hi":
                                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "says hello.");
                                    break;
                                case "help":
                                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "\nList Of Commands:\n/trade - Start a trade.\n/remove - Remove TradeBot from your friends.\n/hi - say hello");
                                    break;
                                case "name":
                                    if(checkAdmin(sid))
                                        steamFriends.SetPersonaName(words[1]);
                                    break;
                                case "send":
                                    string[] wrds = message.Split(new char[] { ' ' }, 3);

                                    int index = int.Parse(wrds[1]);

                                    if(index<clients.Count() && index>=0)
                                        steamFriends.SendChatMessage(clients[index], EChatEntryType.ChatMsg, wrds[2]);
                                    else
                                        steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "Error: index out of bounds.");

                                    break;
                                default:
                                    printConsole("[Error]Unknown command from " + callback.Sender + ": " + callback.Message, ConsoleColor.Red);
                                    steamFriends.SendChatMessage(callback.Sender, EChatEntryType.Emote, "doesn't know that command.");
                                    break;
                            }
                        }
                        else
                        {
                            printConsole("[Chat][" + getIndex(sid) + "]" + callback.Sender + ": " + " (" + steamFriends.GetFriendPersonaName(callback.Sender) + ")" + callback.Message, ConsoleColor.Magenta);
                            if ((callback.Message != "hi" || callback.Message != "hello") && clients.Contains(callback.Sender))
                            {
                                steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "You Said: " + callback.Message);
                            }

                        }
                    }
                    else if (type == EChatEntryType.Emote)
                    {
                        printConsole("[Emote]" + callback.Sender + ": " + callback.Message, ConsoleColor.DarkMagenta);
                    }
                });

                msg.Handle<SteamTrading.TradeProposedCallback>(callback =>
                {
                    SteamID sid = callback.Other;
                    //trade.RespondTradeRequest(callback.TradeRequestId, sid, true);
                    //trade.HandleMsg((IPacketMsg)EMsg.EconTrading_InitiateTradeProposed);

                });

                msg.Handle<SteamTrading.TradeRequestCallback>(callback =>
                {
                    printConsole("[Trade] Trade Status with " + callback.Other + " (" + steamFriends.GetFriendPersonaName(callback.Other) + "): " + callback.Status.ToString(), ConsoleColor.Green);
                    if (callback.Status == ETradeStatus.Rejected)
                    {
                        printConsole("[Trade] Trade rejected by " + callback.Other + " (" + steamFriends.GetFriendPersonaName(callback.Other) + ")", ConsoleColor.DarkRed);
                        steamFriends.SendChatMessage(callback.Other, EChatEntryType.Emote, "detected that you rejected that trade.");
                    }
                    //trade.RespondTradeRequest(callback.TradeRequestId, callback.Other, true);
                    
                });

                msg.Handle<SteamTrading.TradeStartSessionCallback>(callback =>
                {
                    //callback.Other
                });

                msg.Handle<SteamFriends.PersonaStateCallback>(callback =>
                {
                    if (callback.FriendID == steamUser.SteamID)
                        return;

                    EFriendRelationship relationship = steamFriends.GetFriendRelationship(callback.FriendID);
                    if (!(relationship == EFriendRelationship.RequestRecipient))
                        return;

                    printConsole("[Friend] Added Friend: " + callback.FriendID + "(" + steamFriends.GetFriendPersonaName(callback.FriendID) + ")", ConsoleColor.Yellow);
                    steamFriends.AddFriend(callback.FriendID);
                });

            }

        }
开发者ID:ampped101,项目名称:SteamBot,代码行数:101,代码来源:Program.cs

示例2: Main


//.........这里部分代码省略.........
				#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);
					
				});
				#endregion

				msg.Handle<SteamFriends.PersonaStateCallback>(callback =>
                {
                    if (callback.FriendID == steamUser.SteamID)
                        return;

                    EFriendRelationship relationship = steamFriends.GetFriendRelationship(callback.FriendID);
                    if (!(relationship == EFriendRelationship.RequestRecipient))
                        return;


					if(steamFriends.GetFriendRelationship(callback.FriendID)==EFriendRelationship.PendingInvitee){
						printConsole("[Friend] Friend Request Pending: " + callback.FriendID + "(" + steamFriends.GetFriendPersonaName(callback.FriendID) + ") - Accepted", ConsoleColor.Yellow);
						steamFriends.AddFriend(callback.FriendID);
					}
                });
				
				
				#region Steam Chat Handler
				/**
				 * 
				 * Steam Chat Handler
				 * 
				 */
				msg.Handle<SteamFriends.FriendMsgCallback>(callback =>
                {
					//Type (emote or chat)
                    EChatEntryType type = callback.EntryType;
					
					if(type == EChatEntryType.ChatMsg){
						//Message is a chat message
						
						//Reply with the same message
						steamFriends.SendChatMessage(callback.Sender,EChatEntryType.ChatMsg,callback.Message);
						
						//Chat API coming soon
						
					}else if(type == EChatEntryType.Emote){
						//Message is emote
						
						//Do nothing yet
					}

                });
				#endregion
				
		
			} //end while loop
			
			
		} //end Main method
开发者ID:ampped101,项目名称:SteamBot,代码行数:101,代码来源:Main.cs


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