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); }
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); }
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); //} }
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(); }
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(); } }
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)); }
void OnClanState( SteamFriends.ClanStateCallback callback ) { string clanName = callback.ClanName; if ( string.IsNullOrWhiteSpace( clanName ) ) clanName = Steam.Instance.Friends.GetClanName( callback.ClanID ); if ( string.IsNullOrWhiteSpace( clanName ) || clanName == "[unknown]" ) // god this sucks. why on earth did i make steamkit follow steamclient to the letter clanName = "Group"; foreach ( var announcement in callback.Announcements ) { string announceUrl = string.Format( "http://steamcommunity.com/gid/{0}/announcements/detail/{1}", callback.ClanID.ConvertToUInt64(), announcement.ID.Value ); IRC.Instance.SendToTag( "steam-news", "{0} announcement: {1} - {2}", clanName, announcement.Headline, announceUrl ); } foreach ( var clanEvent in callback.Events ) { if ( !clanEvent.JustPosted ) continue; // we're only interested in recent clan events string eventUrl = string.Format( "http://steamcommunity.com/gid/{0}/events/{1}", callback.ClanID.ConvertToUInt64(), clanEvent.ID.Value ); IRC.Instance.SendToTag( "steam-news", "{0} event: {1} - {2}", clanName, clanEvent.Headline, eventUrl ); } }
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)); }
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); } }
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(); } } }
public override void OnFriendChatEnter(SteamFriends.PersonaStateCallback callback) { if (!_cooldowns.Keys.Contains(callback.FriendID)) { _cooldowns[callback.FriendID] = new Stopwatch(); } }
public void LogIn(string username, string password) { Username = username; Password = password; client = new SK.SteamClient(); CurrentUser = new SteamUser(); manager = new SK.CallbackManager(client); steamUser = client.GetHandler <SK.SteamUser>(); community = client.GetHandler <SK.SteamFriends>(); manager.Subscribe <SK.SteamClient.ConnectedCallback>(OnConnected); manager.Subscribe <SK.SteamClient.DisconnectedCallback>(OnDisconnected); manager.Subscribe <SK.SteamUser.LoggedOnCallback>(OnLoggedOn); manager.Subscribe <SK.SteamUser.LoggedOffCallback>(OnLoggedOff); manager.Subscribe <SK.SteamUser.AccountInfoCallback>(OnAccountInfo); manager.Subscribe <SK.SteamFriends.FriendsListCallback>(OnCommunityLoaded); manager.Subscribe <SK.SteamFriends.PersonaStateCallback>(OnPersonaState); manager.Subscribe <SK.SteamFriends.FriendAddedCallback>(OnFriendAdded); IsConnected = true; client.Connect(); Task.Run(() => { while (IsConnected) { manager.RunWaitCallbacks(TimeSpan.FromSeconds(1)); } }); }
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; } } }
public void CheckForLetter(SteamFriends.ChatMsgCallback callback, string[] args) { if (_inProgress && callback.Message.Contains(_bannedLetter.ToString())) { SteamNerd.SteamFriends.KickChatMember(callback.ChatRoomID, callback.ChatterID); } }
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; } } }
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(); }
/// <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); } }
public void FriendRun(SteamFriends.FriendMsgCallback callback, Bot bot, object[] args = null) { Random rnd = new Random(); string result = Util.RandomChoice<string>(Util.eightballAnswers); bot.FriendMessage(callback.Sender, result); }
public void Recommend(SteamFriends.ChatMsgCallback callback, string[] args) { if (args.Length > 1) { return; } var name = SteamNerd.ChatterNames[callback.ChatterID]; var randomAnime = _animes[_rand.Next(_animes.Count)]; SteamNerd.SendMessage(string.Format("{0}, watch {1}!", name, randomAnime), callback.ChatRoomID); }
public override void OnFriendMsg(SteamFriends.FriendMsgCallback callback) { if (SteamNerd.Chatrooms.Count != 0) { var chat = SteamNerd.Chatrooms.First(); SteamNerd.SteamFriends.InviteUserToChat(callback.Sender, chat.Key); } }
public override void OnChatMsg(SteamFriends.ChatMsgCallback callback) { Console.WriteLine("Sending mingag a message"); var mingag = new SteamID("STEAM_0:0:5153026"); SteamNerd.SendMessage(string.Format("{0}: {1}", SteamNerd.ChatterNames[callback.ChatterID], callback.Message), mingag); }
public void GroupRun(SteamFriends.ChatMsgCallback callback, Bot bot, object[] args = null) { List<string> strings = new List<string>(callback.Message.Split(' ')); strings.RemoveAt(0); string term = String.Join(" ", strings.ToArray()); bot.ChatroomMessage(bot.chatRoomID, GetNews(term)); }
static void OnChatMessage(SteamFriends.FriendMsgCallback callback) { if (callback.EntryType == EChatEntryType.ChatMsg) { steamFriends.SendChatMessage(callback.Sender, EChatEntryType.ChatMsg, "Hello"); steamTrading.Trade(callback.Sender); } }
public void FriendRun(SteamFriends.FriendMsgCallback callback, Bot bot, object[] args = null) { List<string> strings = new List<string>(callback.Message.Split(' ')); strings.RemoveAt(0); string term = String.Join(" ", strings.ToArray()); bot.FriendMessage(callback.Sender, GetNews(term)); }
public SteamConnection(IntPtr ic) { this.ic = ic; client = new SteamClient(); friends = client.GetHandler<SteamFriends>(); user = client.GetHandler<SteamUser>(); }
static void Main(string[] args) { // Print program information. Console.WriteLine("SteamIdler, 'run' games without steam.\n(C) No STEAMGUARD Support"); // Check for username and password arguments from stdin. if (args.Length < 3) { // Print usage and quit. Console.WriteLine("usage: <username> <password> <appID> [...]"); return; } // Set username and password from stdin. Username = args[0]; Password = args[1]; // Add all game application IDs to list. foreach (string GameAppID in args) { int AppID; if (int.TryParse(GameAppID, out AppID)) { AppIDs.Add(Convert.ToInt32(GameAppID)); } } // Create SteamClient interface and CallbackManager. steamClient = new SteamClient(System.Net.Sockets.ProtocolType.Tcp); manager = new CallbackManager(steamClient); // Get the steamuser handler, which is used for logging on after successfully connecting. steamUser = steamClient.GetHandler<SteamUser>(); // Get the steam friends handler, which is used for interacting with friends on the network after logging on. steamFriends = steamClient.GetHandler<SteamFriends>(); // Register Steam callbacks. 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 Callback<SteamUser.AccountInfoCallback>(OnAccountInfo, manager); // Set the program as running. Console.WriteLine(":: Connecting to Steam.."); isRunning = true; // Connect to Steam. steamClient.Connect(); // Create our callback handling loop. while (isRunning) { // In order for the callbacks to get routed, they need to be handled by the manager. manager.RunWaitCallbacks(TimeSpan.FromSeconds(1)); } }
public Bot(Configuration.BotInfo config, string apiKey, bool debug = false) { Username = config.Username; Password = config.Password; DisplayName = config.DisplayName; ChatResponse = config.ChatResponse; Admins = config.Admins; this.apiKey = apiKey; AuthCode = null; TradeListener = new TradeEnterTradeListener(this); // Hacking around https ServicePointManager.ServerCertificateValidationCallback += SteamWeb.ValidateRemoteCertificate; SteamClient = new SteamClient(); SteamTrade = SteamClient.GetHandler<SteamTrading>(); SteamUser = SteamClient.GetHandler<SteamUser>(); SteamFriends = SteamClient.GetHandler<SteamFriends>(); SteamClient.Connect(); Thread CallbackThread = new Thread(() => // Callback Handling { while (true) { CallbackMsg msg = SteamClient.WaitForCallback (true); HandleSteamMessage (msg); } }); new Thread(() => // Trade Polling if needed { while (true) { Thread.Sleep (800); if (CurrentTrade != null) { try { CurrentTrade.Poll (); } catch (Exception e) { Console.Write ("Error polling the trade: "); Console.WriteLine (e); } } } }).Start (); CallbackThread.Start(); CallbackThread.Join(); }
public static void OnChatMessage(SteamFriends.ChatMsgCallback callback) { string chatMessage = callback.Message.ToString(); ulong chatUserAsID = callback.ChatterID.ConvertToUInt64(); string chatUserAsName = Globals.steamFriends.GetFriendPersonaName(callback.ChatterID); ConsoleLog.Output(Globals.prefixes["log"],String.Format("{0}: {1}", chatUserAsName, chatMessage),ConsoleColor.DarkGreen); ChatCommander.TestForCommands(chatMessage, callback); }
static void Main(string[] args) { Logger.filename = "RelayBot.log"; log = Logger.GetLogger(); steamClient = new SteamClient(System.Net.Sockets.ProtocolType.Tcp); manager = new CallbackManager(steamClient); steamUser = steamClient.GetHandler<SteamUser>(); steamFriends = steamClient.GetHandler<SteamFriends>(); bot = new Bot(steamUser, steamFriends, steamClient); manager.Subscribe<SteamClient.ConnectedCallback>(bot.OnConnected); manager.Subscribe<SteamClient.DisconnectedCallback>(bot.OnDisconnected); manager.Subscribe<SteamUser.LoggedOnCallback>(bot.OnLoggedOn); manager.Subscribe<SteamUser.LoggedOffCallback>(bot.OnLoggedOff); manager.Subscribe<SteamUser.AccountInfoCallback>(bot.OnAccountInfo); manager.Subscribe<SteamFriends.FriendsListCallback>(bot.OnFriendsList); manager.Subscribe<SteamFriends.FriendAddedCallback>(bot.OnFriendAdded); manager.Subscribe<SteamFriends.ChatInviteCallback>(bot.OnChatInvite); manager.Subscribe<SteamFriends.ChatEnterCallback>(bot.OnChatEnter); manager.Subscribe<SteamFriends.FriendMsgCallback>(bot.OnFriendMessage); manager.Subscribe<SteamFriends.ChatMsgCallback>(bot.OnChatroomMessage); manager.Subscribe<SteamFriends.ChatMemberInfoCallback>(bot.OnMemberInfo); manager.Subscribe<SteamUser.UpdateMachineAuthCallback>(bot.OnMachineAuth); bot.isRunning = true; log.Info("Connecting to Steam..."); steamClient.Connect(); //callback loop while (bot.isRunning) { try { manager.RunWaitCallbacks(TimeSpan.FromSeconds(1)); } catch (Exception e) { Logger.filename = "RelayBot.log"; log.Error(String.Format("Caught exception: {0}\nMessage: {1}\nStack trace: {2}", e.GetType().ToString(), e.Message, e.StackTrace)); } } }
internal static void OnStateUpdated(Bot bot, SteamFriends.PersonaStateCallback callback) { if ((bot == null) || (callback == null)) { Logging.LogNullError(nameof(bot) + " || " + nameof(callback)); return; } BotStatusForm form; if (!BotStatusForm.BotForms.TryGetValue(bot.BotName, out form)) { return; } form.OnStateUpdated(callback); }
internal void OnStateUpdated(SteamFriends.PersonaStateCallback callback) { if (callback == null) { Logging.LogNullError(nameof(callback)); return; } if (callback.AvatarHash != null) { string avatarHash = BitConverter.ToString(callback.AvatarHash).Replace("-", "").ToLowerInvariant(); string avatarURL = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/" + avatarHash.Substring(0, 2) + "/" + avatarHash + "_full.jpg"; AvatarPictureBox.ImageLocation = avatarURL; AvatarPictureBox.LoadAsync(); } }