コード例 #1
0
ファイル: Program.cs プロジェクト: frankhaugen/Frank.Apps
    static void Main(string[] args)
    {
        var irc = new IRC(1024);

        var ipAddress = IPAddress.Parse("127.0.0.1");
        var port      = 6666;
        var result    = irc.Connect(ipAddress, port);

        Console.WriteLine(result);
        irc.Message.ServerReplyEvent += (sender, reply) => Console.WriteLine(reply.Message);

        irc.Login("apophis.ch", new Nick()
        {
            Nickname = "frank"
        });

        irc.Command.SendInfo("apophis.ch");
        irc.Command.SendStats(ServerStat.l);
        irc.Command.SendConnect(ipAddress.ToString());


        var channels = irc.Channels.ToArray();

        Console.WriteLine(channels);
        Console.ReadLine();
    }
コード例 #2
0
        public override async Task Run(object prm)
        {
            if (IsRunning)
            {
                return;
            }
            IsRunning = true;
            try
            {
                if (IRC?.IsWorking ?? false)
                {
                    return;
                }
                await LogHelper.LogModule("Inititalizing IRC module...", Category);

                IRC               = new IRC();
                IRC.Message      += IRC_Message;
                IRC.ErrorOutput  += IRC_ErrorOutput;
                IRC.UserJoined   += IRC_UserJoined;
                IRC.Disconnected += IRC_Disconnected;
                _messagePool.Clear();
                await IRC.Connect().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                await LogHelper.LogEx($"IRC connect error: {ex.Message}", ex, Category);
            }
            finally
            {
                IsRunning = false;
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: Royathe/CIRCB
        private cIRC()
        {
            IrcObject = new IRC();
            Messager  = new BotMessager();

            // Assign events
            IrcObject.eventReceiving          += new CommandReceived(IrcCommandReceived);
            IrcObject.eventTopicSet           += new TopicSet(IrcTopicSet);
            IrcObject.eventTopicOwner         += new TopicOwner(IrcTopicOwner);
            IrcObject.eventNamesList          += new NamesList(IrcNamesList);
            IrcObject.eventServerMessage      += new ServerMessage(IrcServerMessage);
            IrcObject.eventJoin               += new Join(IrcJoin);
            IrcObject.eventPart               += new Part(IrcPart);
            IrcObject.eventMode               += new Mode(IrcMode);
            IrcObject.eventNickChange         += new NickChange(IrcNickChange);
            IrcObject.eventKick               += new Kick(IrcKick);
            IrcObject.eventQuit               += new Quit(IrcQuit);
            IrcObject.eventConnectedToServer  += new ConnectedToServer(IrcConnectedToServer);
            IrcObject.eventConnectedToChannel += new ConnectedToChannel(IrcConnectedToChannel);
            IrcObject.eventNickInUse          += new NickInUse(IrcBotChangeNick);
            IrcObject.eventBanned             += new Banned(IrcBotBanned);
            IrcObject.eventError              += new Error(IrcBotError);

            Messager.eventSay    += new BotSay(IrcBotSay);
            Messager.eventAction += new BotAction(IrcBotAction);
            Messager.eventNotice += new BotNotice(IrcBotNotice);

            Executor = new MasterExecutor(Messager);

            // Connect to server
            IrcObject.Connect();
        } /* cIRC */
コード例 #4
0
        public async Task Connect()
        {
            if (IsRunning)
            {
                return;
            }
            IsRunning = true;

            if (IRC?.IsWorking ?? false)
            {
                return;
            }
            try
            {
                Settings = IRCSettings.Load(SettingsManager.FileSettingsPath);

                IRC               = new IRC(Settings);
                IRC.Message      += IRC_Message;
                IRC.ErrorOutput  += IRC_ErrorOutput;
                IRC.UserJoined   += IRC_UserJoined;
                IRC.Disconnected += IRC_Disconnected;
                _messagePool.Clear();
                await IRC.Connect().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                await LogHelper.LogEx($"IRC connect error: {ex.Message}", ex, Category);
            }
            finally
            {
                IsRunning = false;
            }
        }
コード例 #5
0
ファイル: BotsModule.cs プロジェクト: mlapaglia/BTNster
        public BotsModule(IRC.Bot ircBot)
        {
            Get["/Bots"] = parameters =>
            {
                BotsModel model = new BotsModel();

                model.Bots.Add(new Web.Models.Bots.Bot()
                {
                    BotID = 1,
                    Errors = 0,
                    IsConnected = true,
                    IsConnecting = false,
                    SiteName = "BTN",
                });

                return View["Index", model];
            };

            Get["/Bots/Connect"] = parameters =>
            {
                string site = "irc.what-network.org";
                int port = 6697;
                bool useSSL = true;
                ircBot.Connect(site, port, useSSL);

                return true;
            };
        }
コード例 #6
0
        public void LoginChat(Action listBox)
        {
            TwitchApi.Authenticate((t) =>
            {
                IRC.OnSubReceived += Irc_OnSubReceived1;
#if DEBUG
                IRC.Connect("summit1g");// TwitchApi.Name);
#else
                IRC.Connect(TwitchApi.Name);
#endif
                IRC.IRC_Client.ConnectionComplete += (o, e) =>
                {
                    listBox?.Invoke();
                    timer = new LXTimer(WorkQueue, 100, LXTimer.Infinite);
                };
            });
        }
コード例 #7
0
        public Main(IRC irc)
        {
            InitializeComponent();
            irc.Connect();
            lblServerName.Text  = irc.Server;
            lblChannelName.Text = irc.Channel;


            //event handlers from the IRC object
            irc.Received        += OnMessageReceived;
            irc.Connected       += OnConnected;
            irc.UserList        += OnUserList;
            irc.UserJoined      += OnUserJoined;
            irc.UserQuit        += OnUserQuit;
            irc.NicknameChanged += OnNicknameChanged;
            irc.Quit            += OnQuit;
            irc.ServerMessage   += OnServerMessageReceived;
            Connection           = irc;
        }
コード例 #8
0
ファイル: cIRC.cs プロジェクト: td1994/Twitch-Wars
        } /* Main */

        private cIRC(string IrcServer, int IrcPort, string IrcUser, string IrcChan, string IrcPass)
        {
            //IrcObject = new IRC("CumpsD", "#mypreciousss");
            IrcObject = new IRC(IrcUser, IrcChan);

            // Assign events
            IrcObject.eventReceiving += new CommandReceived(IrcCommandReceived);
            IrcObject.eventTopicSet += new TopicSet(IrcTopicSet);
            IrcObject.eventTopicOwner += new TopicOwner(IrcTopicOwner);
            IrcObject.eventNamesList += new NamesList(IrcNamesList);
            IrcObject.eventServerMessage += new ServerMessage(IrcServerMessage);
            IrcObject.eventJoin += new Join(IrcJoin);
            IrcObject.eventPart += new Part(IrcPart);
            IrcObject.eventMode += new Mode(IrcMode);
            IrcObject.eventNickChange += new NickChange(IrcNickChange);
            IrcObject.eventKick += new Kick(IrcKick);
            IrcObject.eventQuit += new Quit(IrcQuit);

            // Connect to server
            //IrcObject.Connect("efnet.xs4all.nl", 6667);	
            IrcObject.Connect(IrcServer, IrcPort, IrcPass);
        } /* cIRC */
コード例 #9
0
ファイル: Core.cs プロジェクト: atdt/wikimedia-bot
 /// <summary>
 /// Connect to network
 /// </summary>
 public static void Connect()
 {
     irc = new IRC(config.network, config.username, config.name, config.name);
     irc.Connect();
 }
コード例 #10
0
ファイル: Main.cs プロジェクト: xwcg/SpawnBot
        private Bot()
        {
            // Load Plugins
            Logger.WriteLine("* Loading Plugins...", ConsoleColor.Green);

            plugins.FindPlugins(Environment.CurrentDirectory + "\\Plugins\\");

            // Load Plugins first
            foreach (AvailablePlugin p in plugins.AvailablePlugins)
            {
                Logger.WriteLine("* Loaded Plugin: " + p.Instance.PluginName + " - v" + p.Instance.Version, ConsoleColor.DarkGreen);
            }

            try
            {
            UserManager = (SBUserPlugin)plugins.AvailablePlugins.FindUserManager().Instance;
                TimeGiver = (SBTimePlugin)plugins.AvailablePlugins.FindTimeGiver().Instance;
            }
            catch (Exception) { }

            if (UserManager == null)
            {
                Logger.WriteLine("**** User Manager: NOT FOUND. Exiting.", ConsoleColor.DarkRed);
                Environment.Exit(1);
            }

            if (TimeGiver == null)
            {
                Logger.WriteLine("**** Timegiver: NOT FOUND.", ConsoleColor.DarkRed);
            }
            else
            {
                Logger.WriteLine("* Timegiver: " + TimeGiver.PluginName, ConsoleColor.Green);
            }

            Logger.WriteLine("* User Manager: " + UserManager.PluginName, ConsoleColor.Green);

            // Initialize plugins later
            foreach (AvailablePlugin p in plugins.AvailablePlugins)
            {
                p.Instance.PluginHost = this;
                Logger.WriteLine("* Started Plugin: " + p.Instance.PluginName + " - v" + p.Instance.Version, ConsoleColor.DarkGreen);
            }

            // Start Service

            Logger.WriteLine("* Starting Bot...", ConsoleColor.DarkYellow);

            IrcService = new IRC(Botname, ServerPassword, "SpawnBot", "Spawnbot", ServerAddress, ServerPort);

            IrcService.eventNameListReceived += new IrcNameListReceived(IrcService_eventNameListReceived);
            IrcService.eventTopicReceived += new IrcTopicReceived(IrcService_eventTopicReceived);
            IrcService.eventTopicOwnerReceived += new IrcTopicOwnerRecevied(IrcService_eventTopicOwnerReceived);

            IrcService.eventUserJoined += new IrcUserJoin(IrcService_eventUserJoined);
            IrcService.eventUserJoinedHostname += new IrcUserJoinHostname(IrcService_eventUserJoinedHostname);
            IrcService.eventUserKicked += new IrcUserKicked(IrcService_eventUserKicked);
            IrcService.eventUserChangedNick += new IrcUserChange(IrcService_eventUserChangedNick);
            IrcService.eventUserModeChanged += new IrcUserMode(IrcService_eventUserModeChanged);
            IrcService.eventUserPart += new IrcUserPart(IrcService_eventUserPart);
            IrcService.eventUserQuit += new IrcUserQuit(IrcService_eventUserQuit);

            IrcService.eventRawBotModeReceived += new IrcRawBotModeGet(IrcService_eventRawBotModeReceived);

            IrcService.eventMessageReceived += new IrcMessage(IrcService_eventMessageReceived);
            IrcService.eventActionReceived += new IrcAction(IrcService_eventActionReceived);
            IrcService.eventNoticeReceived += new IrcNotice(IrcService_eventNoticeReceived);

            IrcService.eventDisconnected += new IrcDisconnected(IrcService_eventDisconnected);
            IrcService.eventConnectingError += new IrcConnectingError(IrcService_eventConnectingError);
            IrcService.eventConnected += new IrcConnected(IrcService_eventConnected);

            IrcService.eventServerPingReceived += new IrcServerPingReceived(IrcService_eventServerPingReceived);
            IrcService.eventServerPongReceived += new IrcServerPongReceived(IrcService_eventServerPongReceived);

            IrcService.eventCommandReceived += new IrcCommandReceived(IrcService_eventCommandReceived);
            IrcService.eventUnhandled += new IrcCommandReceived(IrcService_eventUnhandled);

            Logger.WriteLine("* Connecting to " + IrcService.Server + " on port " + IrcService.Port.ToString(), ConsoleColor.White);
            IrcService.Connect();
        }