Beispiel #1
0
 public BotHandler()
 {
     try
     {
         AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
         installationFolderPath = GetConfigFilePath();
         File.Delete( installationFolderPath+"err.txt" );
         File.Delete( installationFolderPath+"out.txt" );
         File.Delete( installationFolderPath+"log.txt" );
         StreamWriter swerr = new StreamWriter( installationFolderPath+"err.txt", true, System.Text.Encoding.Default );
         swerr.AutoFlush = true;
         StreamWriter swout = new StreamWriter( installationFolderPath+"out.txt", true, System.Text.Encoding.Default );
         swout.AutoFlush = true;
         Console.SetError( swerr );
         Console.SetOut( swout );
         log.Debug("Initiating fnordbot with path: "+installationFolderPath);
         bot = new NielsRask.FnordBot.FnordBot( installationFolderPath );
         //			bot.OnLogMessage +=new NielsRask.FnordBot.FnordBot.LogMessageHandler(WriteLogMessage);
         bot.Init();
         log.Debug("initiating thread");
         thread = new Thread( new ThreadStart( bot.Connect ) );
         thread.IsBackground = false;
         thread.Name = "FnordBotThread";
     }
     catch (Exception e)
     {
         log.Error("Error in bothandler constructor", e);
     }
 }
Beispiel #2
0
 public void Attach(NielsRask.FnordBot.FnordBot bot)
 {
     log.Info("Attaching stat plugin");
     try
     {
         this.bot = bot;
         bot.OnPublicMessage += new NielsRask.FnordBot.FnordBot.MessageHandler(bot_OnPublicMessage);
         bot.OnPrivateMessage += new NielsRask.FnordBot.FnordBot.MessageHandler(bot_OnPrivateMessage);
     }
     catch (Exception e)
     {
         log.Error("Error in Statplugin.attach", e);
     }
 }
Beispiel #3
0
 public void Attach(FnordBot.FnordBot bot)
 {
     this.bot = bot;
     bot.OnPublicMessage += new FnordBot.FnordBot.MessageHandler(bot_OnPublicMessage);
     bot.OnPrivateMessage += new FnordBot.FnordBot.MessageHandler(bot_OnPrivateMessage);
 }
Beispiel #4
0
        public void Attach(NielsRask.FnordBot.FnordBot bot)
        {
            log.Info("Attaching logger plugin");
            try
            {
                this.bot = bot;

                bot.OnPublicMessage +=new NielsRask.FnordBot.FnordBot.MessageHandler(bot_OnPublicMessage);
                bot.OnPrivateMessage += new NielsRask.FnordBot.FnordBot.MessageHandler(bot_OnPrivateMessage);
                bot.OnChannelJoin += new NielsRask.FnordBot.FnordBot.ChannelActionHandler(bot_OnChannelJoin);
                bot.OnChannelPart += new NielsRask.FnordBot.FnordBot.ChannelActionHandler(bot_OnChannelPart);
                bot.OnChannelMode += new NielsRask.FnordBot.FnordBot.ChannelActionHandler(bot_OnChannelMode);
                bot.OnChannelKick += new NielsRask.FnordBot.FnordBot.ChannelActionHandler(bot_OnChannelKick);
                bot.OnServerQuit += new NielsRask.FnordBot.FnordBot.ChannelActionHandler(bot_OnServerQuit);
                bot.OnPrivateNotice += new NielsRask.FnordBot.FnordBot.MessageHandler(bot_OnPrivateNotice);
                bot.OnPublicNotice += new NielsRask.FnordBot.FnordBot.MessageHandler(bot_OnPublicNotice);
                bot.OnTopicChange += new NielsRask.FnordBot.FnordBot.ChannelTopicHandler(bot_OnTopicChange);
                bot.OnPublicAction += new NielsRask.FnordBot.FnordBot.MessageHandler(bot_OnPublicAction);
                bot.OnPrivateAction += new NielsRask.FnordBot.FnordBot.MessageHandler(bot_OnPrivateAction);
                bot.OnSendToChannel += new NielsRask.FnordBot.FnordBot.BotMessageHandler(bot_OnSendToChannel);
                bot.OnSendToUser += new NielsRask.FnordBot.FnordBot.BotMessageHandler(bot_OnSendToUser);
                bot.OnSendNotice +=new NielsRask.FnordBot.FnordBot.BotMessageHandler(bot_OnSendNotice);
                bot.OnSetMode += new NielsRask.FnordBot.FnordBot.BotMessageHandler(bot_OnSetMode);
                alarmClock.AddAlarm( new DelegateCaller(DateTime.Today.AddDays(1), new AlarmMethod( OnMidnight ) ) );
            }
            catch (Exception e)
            {
                log.Error("Failed in Logger.Attach",e);
            }
        }
Beispiel #5
0
 public Referendum( string creator, FnordBot.FnordBot bot )
 {
     this.creator = creator;
     this.bot = bot;
     votes = new Dictionary<string, int>();
 }
Beispiel #6
0
        public void Attach( FnordBot.FnordBot bot )
        {
            log.Info( "Attaching voter plugin" );
            try
            {
                this.bot = bot;
                bot.OnPrivateMessage += bot_OnPrivateMessage;

            }
            catch (Exception e)
            {
                log.Error( "Failed in voter.Attach", e );
            }
        }
Beispiel #7
0
 public void Attach(FnordBot.FnordBot bot)
 {
     this.bot = bot;
     bot.OnPublicMessage +=new NielsRask.FnordBot.FnordBot.MessageHandler(bot_OnPublicMessage);
     log.Info("Wordgame plugin attached");
 }
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Wordgame"/> class.
 /// </summary>
 /// <param name="bot">The bot.</param>
 /// <param name="channel">The channel.</param>
 /// <param name="gameList">The game list.</param>
 public Wordgame(FnordBot.FnordBot bot, string channel, WordgameCollection gameList, string wordListPath)
 {
     this.bot = bot;
     this.channel = channel;
     this.gameList = gameList;
     this.rnd = new Random();
     this.wordListPath = wordListPath;
 }
Beispiel #9
0
        //        private void btnConnect2_Click(object sender, System.EventArgs e)
        //        {
        //            // HACK: There is an unresolved issue concerning finding the config files for the fnordbot assembly,
        //            // when running from within visual studio. The problem is that we're unable to find the directory
        //            // of the FnordBot2 project, as the assembly is copied to the launcher programs /bin directory
        //            // the solution is to edit the following relative path (starts in the launcher directory)
        //            // this should be resolved in the final releases
        //            bot = new NielsRask.FnordBot.FnordBot("..\\..\\..\\FnordBot\\");
        //            bot.Init();
        ////			bot.OnLogMessage += new NielsRask.FnordBot.FnordBot.LogMessageHandler(bot_OnLogMessage);
        //            bot.Connect();
        //        }
        private void btnConnect2_Click(object sender, System.EventArgs e)
        {
            bot = new FnordBot();
            bot.InstallationFolderPath = Path.GetFullPath( "..\\..\\..\\FnordBot\\" );
            bot.Client.Port = 6667;
            bot.Client.Server = "10.0.0.153";
            //bot.Client.Server = "irc.droso.net";
            bot.Client.Username = "******";
            bot.Client.Realname = "B. Imse";
            bot.Client.Nickname = "Bimsebot";
            bot.Client.AlternativeNick = "BimmerBot";

            bot.ChannelsToJoin.Add("#craYon");

            bot.DirectInit();

            System.Collections.Generic.Dictionary<string, string> settings;
            System.Collections.Generic.Dictionary<string, bool> permissions;

            //settings = new Dictionary<string, string>();
            //permissions = new Dictionary<string, bool>();
            ////settings.Add( "wordlist", @"..\..\..\wordgame\wordlist.dat" );
            //settings.Add( "wordlist", @"..\wordgame\wordlist.dat" );
            //permissions.Add( "CanOverrideSendToChannel", true );
            //bot.LoadPlugin( "NielsRask.Wordgame.Plugin", @"..\..\..\wordgame\bin\debug\wordgame.dll", settings, permissions );

            settings = new Dictionary<string, string>();
            permissions = new Dictionary<string, bool>();
            settings.Add( "wordlist", @"..\wordgame\wordlist.dat" );
            permissions.Add( "CanOverrideSendToChannel", true );
            bot.LoadPlugin( "NielsRask.Voter.Voter", @"..\..\..\voter\bin\debug\voter.dll", settings, permissions );

            bot.Connect();
            //System.Threading.Thread.Sleep(5000);
            //bot.SendToChannel("#crayon", "tingeling");
        }