public MainForm() { //UnprotectConfig(); settings = Properties.Settings.Default; try { if (String.IsNullOrEmpty(settings.currentProfile)) { settings.currentProfile = "Default"; } if (settings.chatProfiles == null) { settings.chatProfiles = new ChatProfiles(); settings.chatProfiles.WriteProfile(settings.currentProfile, settings); } else if (!settings.chatProfiles.Profiles.Any(p => p.Name.Equals(settings.currentProfile))) { settings.chatProfiles.WriteProfile(settings.currentProfile, settings); } } catch { } InitializeComponent(); endpointList = new ChannelList(); endpointListBS = new BindingSource(); if( settings.globalDebug ) debugForm = new DebugForm(); //RefreshChatProperties(); log = new Log(textMessages); chatUsers = new List<ChatUser>(); Enum.TryParse<EndPoint>(settings.globalDefaultChat, out currentChat); lastMessageSent = new UbiMessage("", EndPoint.Console); adminCommands = new List<AdminCommand>(); chatAliases = new List<ChatAlias>(); lastMessagePerEndpoint = new List<UbiMessage>(); adminCommands.Add(new AdminCommand(@"^/r\s*([^\s]*)\s*(.*)", ReplyCommand)); adminCommands.Add(new AdminCommand(@"^/stream$", StartStopStreamsCommand)); adminCommands.Add(new AdminCommand(@"^/gohaconfirm\s*(.*)", GohaConfirmCommand)); adminCommands.Add(new AdminCommand(@"^/gohasetpass", GohaUpdatePassword)); adminCommands.Add(new AdminCommand(@"^/width\s*(.*)", SetFormWidth)); adminCommands.Add(new AdminCommand(@"^/height\s*(.*)", SetFormHeight)); adminCommands.Add(new AdminCommand(@"^/scene\s*(.*)", SetOBSScene)); chatAliases.Add(new ChatAlias(settings.twitchChatAlias, EndPoint.TwitchTV, ChatIcon.TwitchTv, settings.TwitchUser.ToLower())); chatAliases.Add(new ChatAlias(settings.sc2tvChatAlias, EndPoint.Sc2Tv, ChatIcon.Sc2Tv, settings.Sc2tvUser)); chatAliases.Add(new ChatAlias(settings.steamChatAlias, EndPoint.Steam, ChatIcon.Steam)); chatAliases.Add(new ChatAlias(settings.skypeChatAlias, EndPoint.Skype, ChatIcon.Skype)); // chatAliases.Add(new ChatAlias(settings.battlelogChatAlias, EndPoint.Battlelog, ChatIcon.Battlelog)); chatAliases.Add(new ChatAlias(settings.gohaChatAlias, EndPoint.Gohatv, ChatIcon.Goha, settings.GohaUser)); chatAliases.Add(new ChatAlias(settings.empireAlias, EndPoint.Empiretv, ChatIcon.Empire, settings.empireUser.ToLower())); chatAliases.Add(new ChatAlias(settings.goodgameChatAlias, EndPoint.Goodgame, ChatIcon.Goodgame, settings.goodgameUser.ToLower())); chatAliases.Add(new ChatAlias(settings.cyberAlias, EndPoint.Cybergame, ChatIcon.Cybergame, settings.cyberUser.ToLower())); chatAliases.Add(new ChatAlias(settings.hashdAlias, EndPoint.Hashd, ChatIcon.Hashd, settings.hashdUser.ToLower())); chatAliases.Add(new ChatAlias(settings.youtubeAlias, EndPoint.Youtube, ChatIcon.Youtube)); chatAliases.Add(new ChatAlias(settings.gmtvAlias, EndPoint.GamersTV, ChatIcon.GamersTv)); chatAliases.Add(new ChatAlias(settings.jetsetAlias, EndPoint.JetSet, ChatIcon.JetSet)); chatAliases.Add(new ChatAlias(settings.hitboxAlias, EndPoint.HitBox, ChatIcon.HitBox)); chatAliases.Add(new ChatAlias("@all", EndPoint.All, ChatIcon.Default)); var switchTo = chatAliases.FirstOrDefault( c => c.Endpoint == currentChat ); if( switchTo != null ) SwitchToChat(switchTo.Alias,false); uint.TryParse(settings.Sc2tvId, out sc2ChannelId); Debug.Print(String.Format("Sc2tv Channel ID: {0}",sc2ChannelId)); sc2tv = new Sc2Chat(settings.sc2LastMsgId + 1); sc2tv.Logon += OnSc2TvLogin; sc2tv.ChannelList += OnSc2TvChannelList; sc2tv.MessageReceived += OnSc2TvMessageReceived; sc2tv.channelList = new Channels(); gohaIrc = new IrcClient(); gohaIrc.Connected += OnGohaConnect; gohaIrc.Registered += OnGohaRegister; gohaIrc.Disconnected += OnGohaDisconnect; checkMark = new StatusImage(Properties.Resources.checkMarkGreen, Properties.Resources.checkMarkRed); streamStatus = new StatusImage(Properties.Resources.streamOnline, Properties.Resources.streamOffline); 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); cyberBW = new BGWorker(ConnectCybergame, null); hashdBW = new BGWorker(ConnectHashd, null); youtubeBW = new BGWorker(ConnectYoutube, null); gamerstvBW = new BGWorker(ConnectGamersTV, null ); jetsetBW = new BGWorker(ConnectJetSet, null); hitboxBW = new BGWorker(ConnectHitBox, 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); obsremoteBW = new BGWorker(ConnectOBSRemote, null); settings.PropertyChanged += new PropertyChangedEventHandler(settings_PropertyChanged); settings.SettingsSaving += new SettingsSavingEventHandler(settings_SettingsSaving); fontDialog = new FontDialog(); forceCloseTimer = new System.Threading.Timer(new TimerCallback(ForceClose), null, Timeout.Infinite, Timeout.Infinite); obsChatSourceSwitch = new System.Threading.Timer(new TimerCallback(OBSChatSwitch), null, Timeout.Infinite, Timeout.Infinite); if (settings.webEnable) { int port; int.TryParse(settings.webPort, out port); try { webChat = new WebChat(port); } catch (Exception e) { SendMessage(new UbiMessage("Web server error: " + e.Message, EndPoint.Error)); } } if (settings.lastFmEnable && !String.IsNullOrEmpty(settings.lastFmLogin) && !String.IsNullOrEmpty(settings.lastFmPassword)) { try { lastFm = new ULastFm(); lastFm.OnLogin += new EventHandler<EventArgs>(lastFm_OnLogin); lastFm.OnTrackChange += new EventHandler<LastFmArgs>(lastFm_OnTrackChange); ThreadPool.QueueUserWorkItem(t => lastFm.Authenticate(settings.lastFmLogin, settings.lastFmPassword)); } catch (Exception ex) { Debug.Print(ex.Message + " " + ex.StackTrace); } } //@Debug.Print("Config is here:" + ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath); #region Set tooltips ToolTip fullScreenDblClk = new ToolTip(); fullScreenDblClk.AutoPopDelay = 2000; fullScreenDblClk.InitialDelay = 100; fullScreenDblClk.ReshowDelay = 100; fullScreenDblClk.ShowAlways = false; // Set up the ToolTip text for the Button and Checkbox. fullScreenDblClk.SetToolTip(textMessages, "DblClick - switch mode, Hold RMB - move window"); viewersTooltip = new ToolTip(); viewersTooltip.AutoPopDelay = 2000; viewersTooltip.InitialDelay = 0; viewersTooltip.ReshowDelay = 0; viewersTooltip.ShowAlways = false; viewersTooltip.SetToolTip(labelViewers, String.Format("Twitch.tv: {0}, Cybergame.tv: {0}, Hashd.tv: {0}", 0)); var tooltip = new ToolTip(); tooltip.AutoPopDelay = 2000; tooltip.InitialDelay = 0; tooltip.ReshowDelay = 0; tooltip.ShowAlways = false; tooltip.SetToolTip(buttonStreamStartStop, "Click to start/stop streaming in OBS"); #endregion }
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 chatStatusOBS_Click(object sender, EventArgs e) { if( obsRemote != null ) { if (settings.obsRemoteEnable) { if (obsRemote.Opened) { ThreadPool.QueueUserWorkItem(f => obsRemote.Disconnect()); } else { obsremoteBW = new BGWorker(ConnectOBSRemote, null); } } } }
void gohaIrc_Error(object sender, IrcErrorEventArgs e) { SendMessage(new UbiMessage(String.Format("Goha IRC error: {0}", e.Error.Message), EndPoint.Gohatv, EndPoint.Error)); gohaBW = new BGWorker(ConnectGohaIRC, null); }
private void TwitchDisconnectNoPong(object x) { try { if (twitchIrc != null) twitchIrc.Disconnect(); twitchBW.Stop(); twitchBW = new BGWorker(ConnectTwitchIRC, null); twitchDisconnect.Change(Timeout.Infinite, Timeout.Infinite); twitchPing.Change(Timeout.Infinite, Timeout.Infinite); } catch (Exception ex) { Debug.Print(ex.Message + " " + ex.StackTrace); } }
private void OnTwitchDisconnect(object sender, EventArgs e) { lock (lockTwitchConnect) { if (!settings.twitchEnabled) return; if (!isClosing) { //SendMessage(new Message("Twitch bot disconnected. Trying to reconnect...", EndPoint.TwitchTV, EndPoint.SteamAdmin)); twitchBW.Stop(); twitchBW = new BGWorker(ConnectTwitchIRC, null); } else { SendMessage(new UbiMessage("Twitch bot is disconnecting", EndPoint.TwitchTV, EndPoint.Notice)); twitchIrc.Disconnect(); } } }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { try { if (isClosing) return; //var profiles = new ChatProfiles(); //profiles.Profiles = new List<ChatProfile>(); //profiles.Profiles.Add(new ChatProfile() { Topic = "Test", ChatName = "Chat name", Game = "test", LongDescription = "test2", ShortDescription = "test3"}); //settings.chatProfiles = profiles; isClosing = true; forceCloseTimer.Change(5000, Timeout.Infinite); currentChat = EndPoint.Console; SendMessage(new UbiMessage(String.Format("Leaving chats..."), EndPoint.Console, EndPoint.Notice)); if( settings.globalDebug && debugForm != null) debugForm.Hide(); #region Save settings if (this.WindowState != FormWindowState.Minimized) { settings.mainformWidth = Size.Width; settings.mainformHeight = Size.Height; } if (settings.sc2tvEnabled) { settings.sc2LastMsgId = sc2tv.LastMessageId; } if (settings.youtubeEnable) { settings.youtubeLastTime = youtube.LastTime; } settings.chatProfiles.WriteProfile(settings.currentProfile, settings); settings.Save(); #endregion //this.Visible = false; e.Cancel = true; timerEverySecond.Enabled = false; SwitchPlayersOff( true, true ); var b1 = new BGWorker( StopTwitchIRC, null ); var b2 = new BGWorker( StopGohaIRC, null ); var b3 = new BGWorker( StopSteamBot, null ); var b4 = new BGWorker(StopSc2Chat, null); var b5 = new BGWorker(StopGoodgame, null); if( twitchTV != null ) twitchTV.Stop(); if(empireTV != null ) empireTV.Stop(); if(hashd != null) hashd.Stop(); if(cybergame != null) cybergame.Stop(); if (youtube != null) youtube.Stop(); if (gamerstv != null) gamerstv.Stop(); if (jetset != null) jetset.Stop(); if (hitbox != null) hitbox.Stop(); } catch (Exception ex) { Debug.Print(ex.Message + " " + ex.StackTrace); } }