Ejemplo n.º 1
0
        public void setBotMode()
        {
            bot = true;
            string base_path = Path.Combine(FriendList.accountsPath, Base58Check.Base58CheckEncoding.EncodePlain(walletAddress));

            users = new BotUsers(Path.Combine(base_path, "contacts.dat"), null, true);
            users.loadContactsFromFile();
            groups = new BotGroups(Path.Combine(base_path, "groups.dat"));
            groups.loadGroupsFromFile();
            channels = new BotChannels(Path.Combine(base_path, "channels.dat"));
            channels.loadChannelsFromFile();
        }
Ejemplo n.º 2
0
        // Perform basic initialization of node
        private void init()
        {
            running = true;

            CoreConfig.maximumServerMasterNodes = Config.maximumStreamClients;
            CoreConfig.maximumServerClients     = Config.maximumStreamClients;

            UpdateVerify.init(Config.checkVersionUrl, Config.checkVersionSeconds);

            // Network configuration
            NetworkUtils.configureNetwork(Config.externalIp, Config.serverPort);

            // Load or Generate the wallet
            if (!initWallet())
            {
                running = false;
                SpixiBot.Program.noStart = true;
                return;
            }

            // Setup the stats console
            statsConsoleScreen = new StatsConsoleScreen();

            PeerStorage.init("");

            // Init TIV
            tiv = new TransactionInclusion();

            string avatarPath = Path.Combine(Config.dataDirectory, "Avatars");

            users = new BotUsers(Path.Combine(Config.dataDirectory, "contacts.dat"), avatarPath, false);
            users.loadContactsFromFile();

            groups = new BotGroups(Path.Combine(Config.dataDirectory, "groups.dat"));
            groups.loadGroupsFromFile();

            channels = new BotChannels(Path.Combine(Config.dataDirectory, "channels.dat"));
            channels.loadChannelsFromFile();

            StreamProcessor.init(Path.Combine(Config.dataDirectory, "Messages"));
        }
Ejemplo n.º 3
0
    public static async Task <HttpResponseMessage> HandleInvoke(Activity activity)
    {
        // these are the values specified in manifest.json
        string COMMANDID = "searchCmd";
        string PARAMNAME = "searchText";

        var unrecognizedResponse = new HttpResponseMessage(HttpStatusCode.BadRequest);

        unrecognizedResponse.Content = new StringContent("Invoke request was not recognized.");

        if (!activity.IsComposeExtensionQuery())
        {
            return(unrecognizedResponse);
        }

        // This helper method gets the query as an object.
        var query = activity.GetComposeExtensionQueryData();

        if (query.CommandId == null || query.Parameters == null)
        {
            return(unrecognizedResponse);
        }


        if (query.CommandId != COMMANDID)
        {
            return(unrecognizedResponse);
        }

        var param = query.Parameters.FirstOrDefault(p => p.Name.Equals(PARAMNAME)).Value.ToString();

        if (String.IsNullOrEmpty(param))
        {
            return(unrecognizedResponse);
        }

        // This is the response object that will get sent back to the compose extension request.
        ComposeExtensionResponse invokeResponse = new ComposeExtensionResponse();

        // search our data
        var resultData = BotChannels.GetBotChannels().FindAll(t => t.Title.ToLowerInvariant().Contains(param.ToLowerInvariant()));

        // format the results
        var results = new ComposeExtensionResult()
        {
            AttachmentLayout = "list",
            Type             = "result",
            Attachments      = new List <ComposeExtensionAttachment>(),
        };

        foreach (var resultDataItem in resultData)
        {
            var card = new ThumbnailCard()
            {
                Title  = resultDataItem.Title,
                Images = new List <CardImage>()
                {
                    new CardImage()
                    {
                        Url = resultDataItem.LogoUrl
                    }
                }
            };

            var composeExtensionAttachment = card.ToAttachment().ToComposeExtensionAttachment();
            results.Attachments.Add(composeExtensionAttachment);
        }

        invokeResponse.ComposeExtension = results;

        // Return the response
        StringContent stringContent;

        try
        {
            stringContent = new StringContent(JsonConvert.SerializeObject(invokeResponse));
        }
        catch (Exception ex)
        {
            stringContent = new StringContent(ex.ToString());
        }
        var response = new HttpResponseMessage(HttpStatusCode.OK);

        response.Content = stringContent;
        return(response);
    }