Provides information used by an IrcClient for registering the connection as a user.
Inheritance: IrcRegistrationInfo
Exemple #1
0
        public override void JoinServer(string server, string nickName, string userName, string realName, string password)
        {
            ServerInfo.Server = server;
            ServerInfo.NickName = nickName;
            ServerInfo.UserName = userName;
            ServerInfo.RealName = realName;
            ServerInfo.Password = password;

            Client = new StandardIrcClient();
            Client.Connected += Client_Connected;
            Client.Disconnected += Client_Disconnected;
            Client.Registered += Client_Registered;
            Client.RawMessageReceived += Client_RawMessageReceived;

            var ri = new IrcUserRegistrationInfo();
            ri.NickName = nickName;
            ri.UserName = userName;
            ri.RealName = realName;
            ri.Password = password;

            using (var connectedEvent = new ManualResetEventSlim(false))
            {
                Client.Connected += (sender2, e2) => connectedEvent.Set();
                Client.Connect(server, false, ri);
                if (!connectedEvent.Wait(10000))
                {
                    Client.Dispose();
                    return;
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            this.messageField.KeyDown += textBoxEnter;

            //Instantiate an IRC client session
            irc = new StandardIrcClient();
            IrcRegistrationInfo info = new IrcUserRegistrationInfo()
            {
                NickName = Environment.UserName, // "NerdChat",
                UserName = Environment.UserName + "NerdChat",
                RealName = "NerdChat"
            };

            //Open IRC client connection
            irc.Connect("irc.freenode.net", false, info);
            irc.RawMessageReceived += IrcClient_Receive;

            // Add server to treeview
            TreeViewItem serverTreeItem = new TreeViewItem();
            serverTreeItem.Header = "irc.freenode.net";
            channelTree.Items.Add(serverTreeItem);

            // Add some dummy channels for testing
            for (int i = 0; i < 10; i++) {
                TreeViewItem dummyItem = new TreeViewItem();
                dummyItem.Header = "#dummy" + i;
                serverTreeItem.Items.Add(dummyItem);
            }
        }
Exemple #3
0
        private void findClientConfs()
        {
            regInfo = new IrcUserRegistrationInfo();
            var conf = server.channels[0].config;

            regInfo.NickName = conf["nickname"];
            regInfo.Password = conf["password"];
            regInfo.RealName = conf["realname"];
            regInfo.UserName = conf["username"];
            regInfo.UserModes = new char[] { };
        }
Exemple #4
0
        public void Connect(IPEndPoint ipEndPoint, IrcUserRegistrationInfo registrationInfo)
        {
            Connect(registrationInfo);

            if (Client == null) {
                Client = new Tcp(Loop);
            }

            Client.Connect(ipEndPoint, (ex) => {
                isConnected = true;
                HandleClientConnected(registrationInfo);
                Client.Data += OnRead;
                Client.Resume();
            });

            HandleClientConnecting();
        }
Exemple #5
0
        public void Start()
        {
            lock (_startLock)
            {
                if (!IsRunning)
                {
                    var commandQueue = PluginStore.Container.GetExport<ICommandQueue>();
                    var config = PluginStore.Container.GetExport<IConfig>().Value;
                    _autoResetEvent = new AutoResetEvent(false);

                    commandQueue.Value.CommandQueued += (sender, args) =>
                    {
                        _autoResetEvent.Set();
                    };

                    var registrationInfo = new IrcUserRegistrationInfo()
                    {
                        NickName = config.Nickname,
                        Password = config.Password,
                        UserName = config.Nickname
                    };

                    _connection = new Connection();
                    _connection.Connect(IrcTwitchTv, registrationInfo);

                    foreach (var channel in config.Channels)
                    {
                        commandQueue.Value.EnqueueCommand("JOIN " + channel);
                    }

                    _loop = new EventLoop(_autoResetEvent);
                    var thread = new Thread(() =>
                    {
                        _loop.Start(_connection.Client, commandQueue.Value);
                    });
                    thread.SetApartmentState(ApartmentState.STA);
                    thread.IsBackground = true;
                    thread.Start();

                    IsRunning = true;
                }
            }
        }
Exemple #6
0
 static void Main(string[] args)
 {
     client = new IrcClient();
     var reg = new IrcUserRegistrationInfo();
     reg.NickName = "botctgn";
     reg.UserName = "******";
     reg.RealName = "botctgn";
     client.Connect("irc.freenode.net",6667,false,reg);
     client.Disconnected += ClientOnDisconnected;
     client.Connected += ClientOnConnected;
     client.ErrorMessageReceived += ClientOnErrorMessageReceived;
     client.MotdReceived += ClientOnMotdReceived;
     client.RawMessageReceived += ClientOnRawMessageReceived;
     client.ChannelListReceived += ClientOnChannelListReceived;
     client.ProtocolError += ClientOnProtocolError;
     while (!closingTime)
     {
         Thread.Sleep(10);
     }
 }
Exemple #7
0
 public void Connect(IPAddress ipAddress, int port, IrcUserRegistrationInfo registrationInfo)
 {
     Connect(new IPEndPoint(ipAddress, port), registrationInfo);
 }
Exemple #8
0
 public void Connect(IPAddress ipAddress, IrcUserRegistrationInfo registrationInfo)
 {
     Connect(ipAddress, DefaultPort, registrationInfo);
 }
Exemple #9
0
 public void Connect(string ipAddress, int port, IrcUserRegistrationInfo registrationInfo)
 {
     Connect(IPAddress.Parse(ipAddress), port, registrationInfo);
 }
Exemple #10
0
        public Task Connect()
        {
            connectingTaskCompletionSource = new TaskCompletionSource<object>();
            client.Connected += OnConnectedCallback;
            client.ConnectFailed += OnConnectFailedCallback;

            var registrationInfo = new IrcUserRegistrationInfo
            {
                NickName = serverConfig.UserName,
                Password = serverConfig.Password,
                RealName = "Relays messages between chat rooms on different services.",
                UserName = serverConfig.UserName
            };
            client.Connect(serverConfig.ServerAddress, false, registrationInfo);

            return connectingTaskCompletionSource.Task;
        }
Exemple #11
0
        bool connect()
        {
            if ( irc != null && irc.IsConnected )
            {
                app.WarnAll("IRC is already connected");
                Log.Warn(Name, "Rejecting connection attempt; already connected");
                return true;
            }

            if ( irc != null )
                disconnect();

            app.NotifyAll("Establishing bridge between {0} and {1} on {2}", app.World, channel, host);
            Log.Info(Name, "Creating and establishing IRC bridge...");

            irc = new IrcClient();
            var reg = new IrcUserRegistrationInfo
            {
                NickName = config.Get("Nickname", "VPBridgeBot"),
                RealName = config.Get("Realname", "VPBridge Admin"),
                UserName = config.Get("Username", "VPBridgeAdmin"),
            };

            irc.Error                += (o, e) => { Log.Warn(Name, e.Error.ToString()); };
            irc.ErrorMessageReceived += (o, e) => { Log.Warn(Name, "IRC error: {0}", e.Message); };
            irc.ProtocolError        += (o, e) => { Log.Warn(Name, "Protocol error: {0} {1}", e.Code, e.Message); };
            irc.RawMessageReceived   += onIRCMessage;

            irc.Connect(host, port, false, reg);
            irc.Registered   += onIRCConnected;
            irc.Disconnected += onIRCDisconnected;
            return true;
        }
		public void renderSettingsUI() {
			//if (!drawGUI) {
				//return;
			//}

			//GUILayout.BeginArea(uiRect);
			//GUI.Box(new Rect(0, 0, uiRect.width, uiRect.height), "");
			//scrollPosition = GUILayout.BeginScrollView(scrollPosition);

			GUILayout.BeginHorizontal();
			if (GUILayout.Button("Status")) {
				page = Page.STATUS;
			}

			if (GUILayout.Button("Settings")) {
				page = Page.SETTINGS;
			}
			GUILayout.EndHorizontal();

			GUILayout.Space(20);

			if (page == Page.STATUS) {
				if (string.IsNullOrEmpty(settings.twitchUsername)) {
					GUILayout.Label("You need to enter a twitch username on the settings tab");
				}
				else if (string.IsNullOrEmpty(settings.twitchChannelName)) {
					GUILayout.Label("You need to enter a twitch channel on the settings tab");
				}
				else if (string.IsNullOrEmpty(settings.twitchOAuthToken)) {
					GUILayout.Label("You need to enter a twitch auth token on the settings tab");
				}
				else {
					if (!ircClient.IsConnected && GUILayout.Button("Connect")) {
						IrcUserRegistrationInfo botUser = new IrcUserRegistrationInfo();
						botUser.NickName = settings.twitchUsername.ToLower();
						botUser.UserName = botUser.NickName;
						botUser.Password = "******" + settings.twitchOAuthToken;
					
						ircClient.Connect(twitchIrcServer, twitchIrcPort, false, botUser);
					} else if (ircClient.IsConnected && GUILayout.Button("Disconnect")) {
						ircClient.Disconnect();
					}

					foreach (Guest guest in twitchUserGuestAssoc.Values) {
						if (GUILayout.Button(guest.getName())) {
							GameController.Instance.cameraController.lockOnto(guest.gameObject);
						}
					}

					GUILayout.Label(ircLogString);
				}
			}
			else if (page == Page.SETTINGS) {
				GUILayout.Label("!alert: Sending notifications");
				drawAuthToggleGroup(ref settings.authPostAlerts);
				GUILayout.Space(20);

				GUILayout.Label("!spawn: Spawning a guest");
				drawAuthToggleGroup(ref settings.authSpawnGuests);
				GUILayout.Space(20);

				GUILayout.Label("Twitch user name");
				settings.twitchUsername = GUILayout.TextField(settings.twitchUsername);
				GUILayout.Space(20);

				GUILayout.Label("Twitch channel name");
				settings.twitchChannelName = GUILayout.TextField(settings.twitchChannelName);
				GUILayout.Space(20);

				GUILayout.Label("Twitch auth token");
				settings.twitchOAuthToken = GUILayout.PasswordField(settings.twitchOAuthToken, '*');

				if (GUILayout.Button("Request an auth token")) {
					Application.OpenURL(string.Format("https://api.twitch.tv/kraken/oauth2/authorize?response_type=token&client_id={0}&redirect_uri={1}&scope=chat_login+channel_check_subscription",
					                                  twitchClientID, twitchRedirectUri));
				}
			}
			
			//GUILayout.EndScrollView();
			//GUILayout.EndArea();
		}