private void connectGohaTV(){ ircClient = new IrcClient(); Random random = new Random(); string strNickname = "guest" + random.Next(99999999); string strPassword = ""; ircClientConnect(ircAdress, ircPort, strNickname, strPassword); ircChannelConnect(channelName); setEvents(); }
private bool connectTwitch() { ircClient = new IrcClient(); Random random = new Random(); string strNickname = "justinfan"+random.Next(99999999); string strPassword = "******"; ircClientConnect(ircUrl, port, strNickname, strPassword); ircChannelConnect(channelName); setEvents(); return true; }
private void Reconnect() { if (IrcClient != null) { IrcClient.Disconnect(); IrcClient = null; } IrcClient = new IrcClient(); IrcClient.Connected += IrcClient_Connected; IrcClient.ProtocolError += IrcClient_ProtocolError; IrcClient.Error += IrcClient_Error; IrcClient.Disconnected += IrcClient_Disconnected; IrcClient.RawMessageReceived += IrcClient_RawMessageReceived; IrcClient.ConnectFailed += IrcClient_ConnectFailed; Random rnd = new Random(); string s = "justinfan" + rnd.Next(100000000); regInfo = new IrcUserRegistrationInfo() { NickName = s, UserName = s, Password = "******", RealName = s }; Header = "http://twitch.tv, Подключаемся к " + StreamerNick; if (!string.IsNullOrEmpty(_directAdress)) { string[] dat = _directAdress.Split(':'); try { int port = int.Parse(dat[1]); IrcClient.Connect(dat[0], port, false, regInfo); } catch { Header = "http://twitch.tv, Ошибка " + StreamerNick; } } else { IrcClient.Connect(StreamerNick + ".jtvirc.com", 6667, false, regInfo); } }
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); }
internal IrcChannelCollection(IrcClient client, IList <IrcChannel> list) : base(list) { this.client = client; }
public void EndWork() { if (IrcClient != null) { IrcClient.Disconnect(); IrcClient = null; Header = "http://twitch.tv, Не подключен"; } }
private void ConnectTwitchIRC() { lock (lockTwitchConnect) { if (isClosing) return; //twitchIrc.FloodPreventer = new IrcStandardFloodPreventer(4, 1000); if (settings.TwitchUser.Length <= 0 || !settings.twitchEnabled) return; try { if (twitchIrc != null) { if (twitchIrc.IsConnected) return; twitchIrc.Disconnect(); twitchIrc = null; } } catch { Debug.Print("Exception in ConnectTwitchIRC()"); } //TwitchAPI ttvApi = new TwitchAPI(); //ttvApi.GetToken( settings.TwitchUser.ToLower(), settings.TwitchPassword); twitchPing = new System.Threading.Timer(new TimerCallback(TwitchPingTick), null, Timeout.Infinite, Timeout.Infinite); twitchDisconnect = new System.Threading.Timer(new TimerCallback(TwitchDisconnectNoPong), null, Timeout.Infinite, Timeout.Infinite); twitchIrc = new IrcClient(); twitchIrc.Connected += OnTwitchConnect; twitchIrc.Registered += OnTwitchRegister; twitchIrc.Disconnected += OnTwitchDisconnect; twitchIrc.Error += new EventHandler<IrcErrorEventArgs>(twitchIrc_Error); twitchIrc.RawMessageReceived += new EventHandler<IrcRawMessageEventArgs>(twitchIrc_RawMessageReceived); var twitchDnsName = settings.TwitchUser.ToLower() + "." + twitchIRCDomain; try { twitchServers = Dns.GetHostEntry("irc.twitch.tv"); } catch { SendMessage(new UbiMessage("Twitch: error resolving twitch hostname. Using harcoded list of IPs", EndPoint.TwitchTV, EndPoint.Error)); twitchServers = new IPHostEntry() { AddressList = new IPAddress[] { IPAddress.Parse("199.9.253.199"), IPAddress.Parse("199.9.253.210"), IPAddress.Parse("199.9.250.239"), IPAddress.Parse("199.9.250.229") } }; } using (var connectedEvent = new ManualResetEventSlim(false)) { twitchIrc.Connected += (sender2, e2) => connectedEvent.Set(); var tmpNextServer = twitchServers.AddressList.SkipWhile(p => p.ToString() == nextTwitchIP.ToString()).FirstOrDefault(); if (tmpNextServer == null) tmpNextServer = twitchServers.AddressList.FirstOrDefault(); if (nextTwitchIP.Address != 0) SendMessage(new UbiMessage("Twitch: cycling to the next server " + tmpNextServer.ToString(), EndPoint.TwitchTV, EndPoint.Error)); nextTwitchIP = tmpNextServer; if (!settings.TwitchPassword.ToLower().Contains("oauth:")) { twitchWeb = new TwitchWeb(settings.TwitchUser.ToLower(), settings.TwitchPassword); twitchWeb.OnDescriptionSetError += new EventHandler<EventArgs>(twitchWeb_OnDescriptionSetError); if (twitchWeb.Login()) { settings.twitchOAuthKey = twitchWeb.ChatOAuthKey; twitchWeb.GetDescription(); if( String.IsNullOrEmpty( settings.twitch_ShortDescription ) ) settings.twitch_ShortDescription = twitchWeb.ShortDescription; if( String.IsNullOrEmpty( settings.twitch_Game )) settings.twitch_Game = twitchWeb.Game; } } else { settings.twitchOAuthKey = settings.TwitchPassword; } if (!String.IsNullOrEmpty(settings.twitchOAuthKey)) { twitchIrc.Connect(nextTwitchIP, false, new IrcUserRegistrationInfo() { NickName = settings.TwitchUser.ToLower(), UserName = settings.TwitchUser.ToLower(), RealName = "Twitch bot of " + settings.TwitchUser.ToLower(), Password = settings.twitchOAuthKey }); if (!connectedEvent.Wait(60000)) { SendMessage(new UbiMessage("Twitch: connection timeout!", EndPoint.TwitchTV, EndPoint.Error)); return; } } } } }
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 }
internal IrcUserCollection(IrcClient client, IList <IrcUser> list) : base(list) { this.client = client; }
/// <summary> /// Initializes a new instance of the <see cref="IrcMessage"/> structure. /// </summary> /// <param name="client">A client object that has sent/will receive the message.</param> /// <param name="prefix">The message prefix that represents the source of the message.</param> /// <param name="command">The command name; either an alphabetic word or 3-digit number.</param> /// <param name="parameters">A list of the parameters to the message. Can contain a maximum of 15 items. /// </param> public IrcMessage(IrcClient client, string prefix, string command, IList<string> parameters) { this.Prefix = prefix; this.Command = command; this.Parameters = parameters; this.Source = client.GetSourceFromPrefix(prefix); }
public static void WriteIrcRawLine(IrcClient client, string line) { #if DEBUG WriteEvent("({0}) {1}", client.ClientId, line); #endif }
/// <summary> /// Initializes a new instance of the <see cref="IrcRawMessageEventArgs"/> class. /// </summary> /// <param name="message">The message that was sent/received.</param> /// <param name="rawContent">The raw content of the message.</param> public IrcRawMessageEventArgs(IrcClient.IrcMessage message, string rawContent) : base() { this.Message = message; this.RawContent = rawContent; }