public MainForm() { //UnprotectConfig(); settings = Properties.Settings.Default; InitializeComponent(); currentChat = EndPoint.TwitchTV; lastMessageSent = new Message("", EndPoint.Console); adminCommands = new List<AdminCommand>(); chatAliases = new List<ChatAlias>(); lastMessagePerEndpoint = new List<Message>(); adminCommands.Add(new AdminCommand(@"^/r\s*([^\s]*)\s*(.*)", ReplyCommand)); chatAliases.Add(new ChatAlias(settings.twitchChatAlias, EndPoint.TwitchTV)); chatAliases.Add(new ChatAlias(settings.sc2tvChatAlias, EndPoint.Sc2Tv)); chatAliases.Add(new ChatAlias(settings.steamChatAlias, EndPoint.Steam)); chatAliases.Add(new ChatAlias(settings.skypeChatAlias, EndPoint.Skype)); chatAliases.Add(new ChatAlias(settings.battlelogChatAlias, EndPoint.Battlelog)); chatAliases.Add(new ChatAlias(settings.gohaChatAlias, EndPoint.Gohatv)); chatAliases.Add(new ChatAlias(settings.empireAlias, EndPoint.Empiretv)); chatAliases.Add(new ChatAlias(settings.goodgameChatAlias, EndPoint.Goodgame)); chatAliases.Add(new ChatAlias("@all", EndPoint.All)); sc2tv = new Sc2Chat(settings.sc2LoadHistory); sc2tv.Logon += OnSc2TvLogin; sc2tv.ChannelList += OnSc2TvChannelList; sc2tv.MessageReceived += OnSc2TvMessageReceived; sc2tv.channelList = new Channels(); sc2ChannelId = 0; twitchIrc = new IrcClient(); twitchIrc.Connected += OnTwitchConnect; twitchIrc.Registered += OnTwitchRegister; twitchIrc.Disconnected += OnTwitchDisconnect; gohaIrc = new IrcClient(); gohaIrc.Connected += OnGohaConnect; gohaIrc.Registered += OnGohaRegister; gohaIrc.Disconnected += OnGohaDisconnect; log = new Log(textMessages); checkMark = new StatusImage(Properties.Resources.checkMarkGreen, Properties.Resources.checkMarkRed); streamStatus = new StatusImage(Properties.Resources.streamOnline, Properties.Resources.streamOffline); steamBot = new SteamAPISession(); steamBot.Logon += OnSteamLogin; steamBot.NewMessage += OnNewSteamMessage; steamBot.FriendStateChange += OnSteamFriendStatusChange; steamBot.Typing += OnSteamTyping; statusServer = new StatusServer(); battlelog = new Battlelog(); steamBW = new BGWorker(ConnectSteamBot, null); sc2BW = new BGWorker(ConnectSc2tv, null); twitchBW = new BGWorker(ConnectTwitchIRC, null); gohaBW = new BGWorker(ConnectGohaIRC, null); twitchTV = new BGWorker(ConnectTwitchChannel, null); skypeBW = new BGWorker(ConnectSkype, null); goodgameBW = new BGWorker(ConnectGoodgame, null); battlelogBW = new BGWorker(ConnectBattlelog, null); if (settings.enableXSplitStats) { xsplit = new XSplit(); xsplit.OnFrameDrops += OnXSplitFrameDrops; xsplit.OnStatusRefresh += OnXSplitStatusRefresh; } if (settings.enableStatusServer) { statusServer.Start(); } gohaTVstream = new GohaTV(); gohaStreamBW = new BGWorker(ConnectGohaStream, null); empireTV = new EmpireTV(); empireBW = new BGWorker(ConnectEmpireTV, null); }
private void OnNewSteamMessage(object sender, SteamAPISession.SteamEvent e) { // Message or command from admin. Route it to chat or execute specified action if (e.update.origin == steamAdmin.steamid) { SendMessage( new Message(String.Format("{0}", e.update.message), EndPoint.SteamAdmin, currentChat) ); } }
private void OnSteamFriendStatusChange(object sender, SteamAPISession.SteamEvent e) { if (e.update.origin == steamAdmin.steamid) { if (e.update.status == SteamAPISession.UserStatus.Offline) { checkMark.SetOff(pictureSteamAdmin); steamAdmin.status = SteamAPISession.UserStatus.Offline; } else { checkMark.SetOn(pictureSteamAdmin); steamAdmin.status = SteamAPISession.UserStatus.Online; } } }
private void OnSteamTyping(object sender, SteamAPISession.SteamEvent e) { SendMessage( new Message(String.Format("Replying to {0}", currentChat.ToString() ), EndPoint.Steam, EndPoint.SteamAdmin)); }
private void OnSteamLogin(object sender, SteamAPISession.SteamEvent e) { checkMark.SetOn(pictureSteamBot); //Get Steam Admin ID if (settings.SteamAdminId.Length <= 0) { List<SteamAPISession.Friend> friends = steamBot.GetFriends(); foreach (SteamAPISession.Friend f in friends) { SteamAPISession.User user = steamBot.GetUserInfo(f.steamid); if (user.nickname == settings.SteamAdmin) { steamAdmin = user; settings.SteamAdminId = steamAdmin.steamid; settings.Save(); break; } } } else { steamAdmin = steamBot.GetUserInfo(settings.SteamAdminId); } if (steamAdmin != null) { SteamAPISession.User ui = steamBot.GetUserInfo(steamAdmin.steamid); if (ui.status != SteamAPISession.UserStatus.Offline) { checkMark.SetOn(pictureSteamAdmin); steamAdmin.status = SteamAPISession.UserStatus.Online; } } else SendMessage(new Message(String.Format("Can't find {0} in your friends! Check settings or add that account into friend list for bot!", settings.SteamAdmin), EndPoint.Steam, EndPoint.Console)); bWorkerSteamPoll.RunWorkerAsync(); }
private void OnSteamFriendStatusChange(object sender, SteamAPISession.SteamEvent e) { if (steamAdmin == null) return; if (e.update.origin == steamAdmin.steamid) { if (e.update.status == SteamAPISession.UserStatus.Offline) { chatStatusSteamAdmin.On = false; steamAdmin.status = SteamAPISession.UserStatus.Offline; } else { chatStatusSteamAdmin.On = true; steamAdmin.status = SteamAPISession.UserStatus.Online; } } }
private void OnSteamLogin(object sender, SteamAPISession.SteamEvent e) { chatStatusSteamBot.On = true; //Get Steam Admin ID if (String.IsNullOrEmpty(settings.SteamAdminId)) { List<SteamAPISession.Friend> friends = steamBot.GetFriends(); foreach (SteamAPISession.Friend f in friends) { SteamAPISession.User user = steamBot.GetUserInfo(f.steamid); if (user.nickname == settings.SteamAdmin) { steamAdmin = user; settings.SteamAdminId = steamAdmin.steamid; settings.Save(); break; } } } else { steamAdmin = steamBot.GetUserInfo(settings.SteamAdminId); } if (steamAdmin != null) { SteamAPISession.User ui = steamBot.GetUserInfo(steamAdmin.steamid); if (ui.status != SteamAPISession.UserStatus.Offline) { chatStatusSteamAdmin.On = true; steamAdmin.status = SteamAPISession.UserStatus.Online; } } else SendMessage(new UbiMessage(String.Format("Can't find {0} in your friends! Check settings or add that account into friend list for bot!", settings.SteamAdmin), EndPoint.Steam, EndPoint.Error)); if( !bWorkerSteamPoll.IsBusy ) bWorkerSteamPoll.RunWorkerAsync(); }
private void OnSteamTyping(object sender, SteamAPISession.SteamEvent e) { if( settings.steamCurrentChatNotify ) SendMessage(new UbiMessage(String.Format("Replying to {0}", currentChat.ToString()), EndPoint.Steam, EndPoint.Notice)); }
void steamBot_SteamGuard(object sender, SteamAPISession.SteamEvent e) { string code = InputBox.Show("Check email and enter Steam Guard code:"); steamBot.SteamGuardKey = code; }
private void ConnectSteamBot() { if (isClosing) return; string user = settings.SteamBot; var steamEnabled = settings.steamEnabled; if (String.IsNullOrEmpty(user) || !steamEnabled) return; steamBot = new SteamAPISession(); steamBot.Logon += OnSteamLogin; steamBot.NewMessage += OnNewSteamMessage; steamBot.FriendStateChange += OnSteamFriendStatusChange; steamBot.Typing += OnSteamTyping; steamBot.SteamGuard += new EventHandler<SteamAPISession.SteamEvent>(steamBot_SteamGuard); chatStatusSteamBot.On = true; string password = settings.SteamBotPassword; string token = settings.SteamBotAccessToken; if (String.IsNullOrEmpty(token)) token = steamBot.RSALogin(user, password); status = steamBot.Authenticate(token); if (status == SteamAPISession.LoginStatus.LoginSuccessful) { SendMessage(new UbiMessage(String.Format("Steam: logged in!"), EndPoint.Steam, EndPoint.Notice)); settings.SteamBotAccessToken = steamBot.accessToken; } else { SendMessage(new UbiMessage(String.Format("Steam: login failed"), EndPoint.Steam, EndPoint.Error)); } settings.Save(); }