コード例 #1
0
ファイル: Program.cs プロジェクト: Homesweethome/SwagCore
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            Configuration = builder.Build();

            SwagContainer.Init();
            SwagContainer.Resolve <IDialogflow>().Connect(Configuration["DialogflowKey"]);
            SwagContainer.Resolve <IPluginContainer>().LoadPlugins();
            SwagContainer.Resolve <IIrcBot>().Connect(Configuration["Irc:Server"], new IrcUserRegistrationInfo()
            {
                NickName = Configuration["Irc:UserName"],
                Password = Configuration["Irc:Password"],
                RealName = Configuration["Irc:UserName"],
                UserName = Configuration["Irc:UserName"]
            });
            SwagContainer.Resolve <IIrcBot>().NewMessageRecieved += Program_NewMessageRecieved;

            System.Threading.Thread.Sleep(5000);

            SwagContainer.Resolve <IIrcBot>().JoinChannel("#test");

            System.Threading.Thread.Sleep(2000);

            foreach (var ircChannel in SwagContainer.Resolve <IIrcBot>().GetChannels())
            {
                SwagContainer.Resolve <IIrcBot>().SendMessageToChannel(ircChannel, "!д");
                SwagContainer.Resolve <IIrcBot>().SendMessageToChannel(ircChannel, "Прочитала " +
                                                                       SwagContainer.Resolve <IPluginContainer>().Plugins.Count + " плагинов");
            }

            SwagContainer.Resolve <IIrcBot>().GetChannels();

            while (true)
            {
                System.Threading.Thread.Sleep(50);
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Homesweethome/SwagCore
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("appsettings.json");

            Configuration = builder.Build();

            SwagContainer.Init();
            SwagContainer.Resolve <IDialogflow>().Connect(Configuration["DialogflowKey"]);
            SwagContainer.Resolve <PluginContainer>().LoadPlugins();

            SwagContainer.Resolve <WeatherPlugin>().Init(new Dictionary <string, string>()
            {
                { "apiKey", Configuration["Plugins:Weather:apiKey"] }
            });

            var p    = new Program();
            var line = Console.ReadLine();

            p.Do(line);

            Console.ReadKey();
        }