Пример #1
0
        public BotForm()
        {
            //  @GreenIT_bot    -   1238975566:AAFltoIrHNZIOz-Z57hdqTTnHCJJHhWKUjE
            try
            {
                InitializeComponent();

                botLinq = new BotLinq();
                if (string.IsNullOrWhiteSpace(Properties.Settings.Default.Proxy))
                {
                    botClient = new TelegramBotClient(Properties.Settings.Default.BotToken);
                }
                else
                {
                    string[] proxyParts = Properties.Settings.Default.Proxy.Split(new[] { ':' }, 2);
                    WebProxy httpProxy  = new WebProxy(proxyParts[0], int.Parse(proxyParts[1]));
                    botClient = new TelegramBotClient(Properties.Settings.Default.BotToken, httpProxy);
                }

                botClient.OnMessage            += BotClient_OnMessageReceived;
                botClient.OnMessageEdited      += BotClient_OnMessageReceived;
                botClient.OnCallbackQuery      += BotOnCallbackQueryReceived;
                botClient.OnInlineQuery        += BotOnInlineQueryReceived;
                botClient.OnInlineResultChosen += BotOnChosenInlineResultReceived;
                botClient.OnReceiveError       += BotOnReceiveError;

                botClient.StartReceiving(Array.Empty <UpdateType>());

                host = new ServiceHost(typeof(TestBotService), baseAddress);
                ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
                smb.HttpGetEnabled = true;
                smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
                host.Description.Behaviors.Add(smb);
                host.Open();
            }
            catch (Exception ex)
            {
                botLinq.AddToBotErrorLog("BotForm ctor exception - " + ex.Message);
            }
        }
Пример #2
0
 internal Question(BotLinq botLinq)
 {
     BotLnq      = botLinq;
     AskNumbLst  = botLinq.GetAskList();
     FactNumbLst = botLinq.GetFactList();
 }