コード例 #1
0
        public FormMailTrigger()
        {
            InitializeComponent();
            this.Show();
            fmtl = new FormMailTriggerLogic();

            //Act.DataLoginAct.Read();

            UserData.Init().Email = "oleg";
            tb_mail.Text = UserData.GetUserData().Email;

            DataLoginModel dataLogin = new DataLoginModel("*****@*****.**", "1234");

            GLogin.Init();
            GLogin.Glogin.CreateGmailService();
            GMessage gMessage = new GMessage(GLogin.Glogin.GmailService, dataLogin);

            string str = gMessage.GetMessageRaw(gMessage.Find(new GRule("TestTag", "testpath"), gMessage.GetMessages()));



            //UserData.GetUserData().CreateGmailService();
            //UserData.GetUserData().ListMessagesMatchungQuerty(UserData.GetUserData().GmailService, "me", String.Empty);



            //Google.Apis.Gmail.v1.Data.Message mes = UserData.GetMessage(UserData.GetUserData().GmailService, "*****@*****.**", "0");
            //tb_mail.Text = mes.Payload.Headers.ToString();
        }
コード例 #2
0
        private async void FormMailTriggerLogic_Load(object sender, EventArgs e)
        {
            this.notifyIcon.Icon = new Icon(Application.StartupPath + "\\" + "MTP-beta-icon.ico");
            this.notifyIcon.Text = "Mail Trigger Parser";

            if (GLogin.Glogin == null)
            {
                GLogin.Init();
                await GLogin.Glogin.CreateCredential();

                GLogin.Glogin.CreateGmailService();
            }

            gMessage = new GMessage(GLogin.Glogin.GmailService);

            calculate = new Calculate(GLogin.Glogin.GmailService);
            calculate.callbackFileName    += Calculate_callbackFileName;
            calculate.callbackProgressBar += Calculate_callbackProgressBar;
            calculate.callbackAlert       += Calculate_callbackAlert;

            this.Deactivate += FormMailTriggerLogic_Deactivate;

            if (AutoRun.IsEnabled())
            {
                btn_start.Enabled = false;
                btn_stop.Enabled  = true;
                thread            = new Thread(new ThreadStart(calculate.Run));
                thread.Start();

                cb_autorun.Checked = true;
                this.WindowState   = FormWindowState.Minimized;
                this.ShowInTaskbar = false;
            }
            else
            {
                btn_stop.Enabled   = false;
                cb_autorun.Checked = false;
            }


            dataGridView.Rows.Clear();

            l_version.Text = /* "Version : " + */ "beta " + Application.ProductVersion.ToString();
            var data = await GLogin.Glogin.GmailService.Users.GetProfile("me").ExecuteAsync();

            l_mail.Text              = data.EmailAddress;
            l_status.Text            = "tap start";
            l_processedMessages.Text = "0";

            foreach (string str in GRule.GetFiles())
            {
                RowAdd(FileParser.Reads <GRule>(str));
            }
            GRule.SetChange(false);

            this.Select();
        }
コード例 #3
0
ファイル: Calculate.cs プロジェクト: cast98/GMailParser
        public void Run()
        {
            while (true)
            {
                try
                {
                    GRule    gRule = null;
                    string[] files = GRule.GetFiles();
                    for (int i = 0; i < files.Length; i++)
                    {
                        gRule = FileParser.Reads <GRule>(files[i]);
                        callbackProgressBar(0.0);
                        Stack <string> messagesId = null;
                        messagesId = gMessage.GetMessages(GMessage.Query(gRule), ref gRule.lastMesId);
                        //callbackAlert(false);
                        if (messagesId.Count > 0)
                        {
                            foreach (string id in messagesId)
                            {
                                gMessage.GetFile(id, ref gRule, callbackFileName, callbackProgressBar);
                                FileParser.Write(gRule.GetFilePath(), gRule);
                            }
                        }
                        gMessage.ResetParametres();
                    }
                }
                catch (Exception)
                {
                    //if (MessageBox.Show("Message download error!!!! pidr sykkkkaaaa", "Exception") == DialogResult.OK) { };

                    /*
                     * if (!System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
                     *  callbackAlert(true);
                     */
                }
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: ByteLaw5/Guilded.NET
        static void Main(string[] args)
        {
            // Read JSON "config.json"
            JObject obj = JObject.Parse(File.ReadAllText("./config.json"));
            // Get login info
            string email    = obj["email"].Value <string>(),
                   password = obj["password"].Value <string>(),
                   prefix   = obj["prefix"].Value <string>();

            Console.WriteLine($"Starting bot with prefix '{prefix}'");
            // Create new client
            using (GuildedUserClient client = new GuildedUserClient(email, password)) {
                // Assigns a lambda to message creation event
                client.MessageCreated += async(o, e) => {
                    // If bot itself posted this message, ignore the message
                    if (e.Message.AuthorId == client.CurrentUser.Id)
                    {
                        return;
                    }
                    Console.WriteLine("Someone posted a message!");
                    // Turn message to string and get its content in markdown-style
                    string content = e.Message.ToString();
                    // Check if content starts with prefix
                    if (!content.StartsWith(prefix))
                    {
                        return;
                    }
                    // Remove the prefix and split the message by space
                    string[] split = content.Substring(prefix.Length, content.Length - prefix.Length).Split(' ');
                    // Get first argument, which is a command
                    string command = split[0];
                    // Get rest of the arguments, which are command arguments
                    IEnumerable <string> args = split.Skip(1);
                    switch (command)
                    {
                    case "ping":
                        // Responds with `Pong!`
                        await client.SendMessageAsync(e.ChannelId,
                                                      // Generates new message
                                                      GMessage.Generate(new List <GNode>()
                        {
                            // Generates paragraph with leaf containing content `Pong!`
                            GParagraphNode.Generate(GLeaf.Generate("Pong!"))
                        })
                                                      );

                        break;

                    default:
                        // Same like with pong, but also adds multiple leaves
                        await client.SendMessageAsync(e.ChannelId,
                                                      GMessage.Generate(new List <GNode>()
                        {
                            // Generate it with paragraph and leaves
                            GParagraphNode.Generate(
                                GLeaf.Generate("Uh oh! Could not find a command "),
                                // Add GMarkType.InlineCode, which tells Guilded that it's inline code
                                GLeaf.Generate(command, GMarkType.InlineCode),
                                GLeaf.Generate(". Make sure you did not misspell it.")
                                )
                        })
                                                      );

                        break;
                    }
                };
                // When client connects
                client.Connected += (o, e) => Console.WriteLine("I successfully logged in!");
                // Starts the bot
                MainAsync(client).GetAwaiter().GetResult();
            }
        }
コード例 #5
0
ファイル: MessageReceivedEvent.cs プロジェクト: ThrDev/GVAPI
 public MessageReceivedEvent(GMessage msg)
 {
     this.g = msg;
 }
コード例 #6
0
 public MessageReceivedEvent(GMessage msg)
 {
     this.g = msg;
 }
コード例 #7
0
        internal Object GetValue()
        {
            if (HasParent)
            {
                ParentMeasure parent = (ParentMeasure)Plugin.Measures[ParentID];

                double countItem = 0;
                if (parent.Name == "mGcal" && parent.lastEvents != null)
                {
                    countItem = parent.lastEvents.Count;
                }
                else if (parent.lastMessages != null)
                {
                    countItem = parent.lastMessages.Count;
                }
                else
                {
                    return("");
                }

                if (countItem > ndx)
                {
                    try
                    {
                        object value = null;
                        if (parent.Name == "mGcal")
                        {
                            GCalEvent ge = parent.lastEvents[ndx];
                            value = Tools.getObjectProperty(ge, property);
                            if (value == null)
                            {
                                return("");
                            }

                            if (value is DateTime)
                            {
                                DateTime dt = (DateTime)value;

                                if (Tools.IsToday(dt))
                                {
                                    return(dt.ToString(todayDateFormat));
                                }

                                else if (Tools.IsInWeek(dt))
                                {
                                    return(dt.ToString(weekDateFormat));
                                }

                                else
                                {
                                    return(dt.ToString(dateFormat));
                                }
                            }

                            else if (value is Boolean)
                            {
                                return(((Boolean)value) ? "1" : "0"); // See Update
                            }

                            else
                            {
                                return(value.ToString());
                            }
                        }
                        else
                        {
                            GMessage gm = parent.lastMessages[ndx];
                            if (this.property == "EmailDate")
                            {
                                return(gm.EmailDate.ToShortDateString() + " " + gm.EmailDate.ToShortTimeString());
                            }
                            else
                            {
                                value = Tools.getObjectProperty(gm, property);
                                return(value.ToString());
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        API.Log(API.LogType.Error, "RainGoo.dll: Exception : " + e.Message);
                    }
                }
            }



            //  API.Log(API.LogType.Warning, "RainGoo.dll: Cannot get value with index [" + ndx + "] and property [" + property + "]");



            return("");
        }
コード例 #8
0
        internal Boolean UpdateGmail()
        {
            try
            {
                long now = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;


                if (now - lastUpdategmail < MIN_INTERVALGMAIL)
                {
                    //API.Log(API.LogType.Notice, "RainGoo.dll: Update interval too short ! ("+ MIN_INTERVALGMAIL + ")");
                    return(false);
                }

                List <GMessage> mess = null;
                if (googleClientId == null || googleClientId == "" || googleClientId == "#GoogleAccountID#" || googleClientSecret == null || googleClientSecret == "" || googleClientSecret == "#GoogleAccountSecret#" || googleUserName == null || googleUserName == "" || googleUserName == "#GmailUserName#")
                {
                    mess = new List <GMessage>();
                    if (googleClientId == null || googleClientId == "" || googleClientId == "#GoogleAccountID#" || googleClientSecret == null || googleClientSecret == "" || googleClientSecret == "#GoogleAccountSecret#")
                    {
                        GMessage fakeMess = new GMessage();
                        fakeMess.EmailDate = DateTime.Now;
                        fakeMess.Link      = "https://console.cloud.google.com";
                        fakeMess.Subject   = "No google ID/Secret provided";
                        fakeMess.Snipet    = "Click here to create one and then please use config button to setup your google account.";
                        fakeMess.Id        = "fake123456";
                        fakeMess.Sender    = "Google API Setup not done";
                        mess.Add(fakeMess);
                    }
                    if (googleUserName == null || googleUserName == "" || googleUserName == "#GmailUserName#")
                    {
                        GMessage fakeMess = new GMessage();
                        fakeMess.EmailDate = DateTime.Now;
                        fakeMess.Link      = "https://gmail.com";
                        fakeMess.Subject   = "No Gmail User name provided";
                        fakeMess.Snipet    = "Please use config button to setup your Gmail account.";
                        fakeMess.Id        = "fake123456b";
                        fakeMess.Sender    = "Gmail Setup not done";
                        mess.Add(fakeMess);
                    }
                }
                else
                {
                    GmailAPI gm = new GmailAPI(googleClientId, googleClientSecret, googleUserName);
                    mess = gm.getMessages("IN:INBOX IS:UNREAD");
                }

                int maxMessage = mess.Count;
                if (mess.Count > maxGmail)
                {
                    maxMessage = maxGmail;
                }
                if (lastMessages == null || lastMessages.Count != mess.Count)
                {
                    if (!String.IsNullOrEmpty(gmailPath))
                    {
                        //API.Log(API.LogType.Notice, "RainGoo.dll: building inc file for " + maxMessage + " lines");
                        Tools.GenerateIncFile(maxMessage
                                              , Path.Combine(gmailPath, "TMeasuresGmail.inc")
                                              , Path.Combine(gmailPath, "Measures.inc"));

                        Tools.GenerateIncFile(maxMessage
                                              , Path.Combine(gmailPath, "TMetersGmail.inc")
                                              , Path.Combine(gmailPath, "Meters.inc"));
                    }
                }



                lastMessages    = mess;
                lastUpdategmail = now;


                return(true);
            }
            catch (Exception e)
            {
                API.Log(API.LogType.Error, "RainGoo.dll: Cannot read messages : " + e.Message);
            }

            return(false);
        }
コード例 #9
0
ファイル: Calculate.cs プロジェクト: cast98/GMailParser
 public Calculate(Google.Apis.Gmail.v1.GmailService service)
 {
     gMessage = new GMessage(service);
 }