Exemplo n.º 1
0
 private void Start()
 {
     m_trelloAPI               = new TrelloAPI(this, m_formSettings.TrelloAppKey, m_formSettings.TrelloAccessToken);
     m_imgurAPI                = new ImgurAPI(this, m_formSettings.ImgurClientID);
     m_stringBuilder           = new StringBuilder();
     m_feedbackUI.FeedbackForm = this;
 }
Exemplo n.º 2
0
        private void OnDestroy()
        {
            if (m_feedbackUI != null && m_feedbackUI.FeedbackForm == (IFeedbackForm)this)
            {
                m_feedbackUI.FeedbackForm = null;
            }

            m_trelloAPI.Dispose();
            m_trelloAPI = null;

            m_imgurAPI.Dispose();
            m_imgurAPI = null;
        }
Exemplo n.º 3
0
 protected override object Gather()
 {
     return(ImgurAPI.HasBeenAuthorized());
 }
Exemplo n.º 4
0
        public void TestAPI_Random()
        {
            ImgurAPI api = new ImgurAPI("3f640d9fa88b1d2", "a36a20ec9ac4cbe0f4e164c51ad2e81bc05570db");

            api.GetRandomGalleryAsync().Wait();
        }
Exemplo n.º 5
0
        public void TestAPI_Search()
        {
            ImgurAPI api = new ImgurAPI("3f640d9fa88b1d2", "a36a20ec9ac4cbe0f4e164c51ad2e81bc05570db");

            api.SearchGalleryAsync("Test").Wait();
        }
Exemplo n.º 6
0
        public Images(FileSystemFile settings, IList <Admin> admins)
        {
            this.admins = admins;
            command     = "pics";
            //gets token and starts an Imgur connection
            imgur         = new ImgurAPI(settings);
            methods       = new Dictionary <string, Func <CommandEventArgs, Task> >();
            queuesRunning = new Dictionary <string, Queue>();
            methods.Add("search", async(command) => {
                List <picture> pics = imgur.querySearch(command.GetArg(1));
                await command.Channel.SendMessage(command.User.Name + " searched for " + command.GetArg(1) + " has " + pics.Count + " results");
                if (pics.Count > 0)
                {
                    string link = pics[(new Random()).Next(pics.Count)].link;
                    await command.Channel.SendMessage(link);
                    await command.Message.Delete();
                }
                else
                {
                    await command.Message.Delete();
                }

                return;
            });
            methods.Add("queues", async(command) =>
            {
                await command.Message.Delete();
                await command.Channel.SendMessage(command.Message.User.NicknameMention + " current queues playing are");
                StringBuilder output = new StringBuilder("```\r\n");
                if (queuesRunning.Keys.Count == 0)
                {
                    output.Append("No queues running");
                }
                foreach (string s in queuesRunning.Keys.ToArray())
                {
                    output.Append(s + " every " + queuesRunning[s].getDelay() + "\r\n");
                }
                output.Append("```");
                await command.Channel.SendMessage(output.ToString());
            });
            methods.Add("queue", async(command) => {
                int delay;
                string query = command.GetArg(1);
                if (command.GetArg(2) == null || !Int32.TryParse(command.GetArg(2), out delay))
                {
                    await command.Channel.SendMessage("!pics queue <search> <delay in mins>");
                    return;
                }
                await command.Message.Delete();
                if (!queuesRunning.ContainsKey(query))
                {
                    await command.Channel.SendMessage(query + " queue has been started");
                    queuesRunning.Add(query, new ImgurQueue(query, new TimeSpan(0, delay, 0), false, command, imgur));



                    queuesRunning[query].Start();
                }
                else
                {
                    await command.Channel.SendMessage(query + " queue has already been started");
                }
            });
            methods.Add("stopqueue", async(command) =>
            {
                string query = command.GetArg(1);
                await command.Message.Delete();
                if (queuesRunning.ContainsKey(query))
                {
                    queuesRunning[query].Stop();
                    queuesRunning.Remove(query);
                    await command.Channel.SendMessage(query + " queue stopped");
                }
                else
                {
                    await command.Channel.SendMessage(query + " queue not found");
                }
            });
            methods.Add("stopqueues", async(command) =>
            {
                lock (queuesRunning)
                {
                    foreach (string entry in queuesRunning.Keys.ToArray())
                    {
                        command.Channel.SendMessage(entry + " queue stopped");
                        if (queuesRunning.ContainsKey(entry))
                        {
                            queuesRunning[entry].Stop();
                            queuesRunning.Remove(entry);
                        }
                        else
                        {
                            command.Channel.SendMessage("huh where did it go? " + entry);
                        }
                    }
                }
                await command.Message.Delete();
                await command.Channel.SendMessage("All Image queues stopped");
            });
            methods.Add("help", async(command) =>
            {
                await command.Channel.SendMessage(getHelp());
                await command.Message.Delete();
            });
        }