Exemplo n.º 1
0
        private static bool AddGroupToDb2(ChatJson chat, DateTime?lastUpdateLinkTime, bool?we_are_admin,
                                          int botIdWhoInsertedThem)
        {
            try
            {
                const string q1 = "INSERT INTO Groups (id, bot_id, type, title, link, last_update_link, valid) " +
                                  " VALUES " +
                                  " (@id, @botid, @type, @title, @link, @lul, @valid)";
                SqLite.Execute(q1, new Dictionary <string, object>
                {
                    { "@id", chat.id },
                    { "@botid", botIdWhoInsertedThem },
                    { "@type", chat.type },
                    { "@title", chat.title },
                    { "@link", chat.invite_link },
                    { "@lul", lastUpdateLinkTime },
                    { "@valid", we_are_admin }
                });
            }
            catch
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 2
0
        private static Tuple <bool, List <Exception> > AddGroupToDb(JEnumerable <JToken> r1, int botIdWhoInsertedThem)
        {
            ;

            ChatJson chat = null;
            DateTime?lastUpdateLinkTime = null;
            bool?    we_are_admin       = null;

            var exceptions = new List <Exception>();

            foreach (var r2 in r1)
            {
                ;
                if (r2 is JProperty r3)
                {
                    ;
                    if (r3.Name == "Chat")
                    {
                        chat = GetChatFromJson(r3);
                    }
                    else if (r3.Name == "LastUpdateInviteLinkTime")
                    {
                        var d1 = GetLastUpdateLinkTimeFromJson(r3);
                        if (d1.HasValue())
                        {
                            lastUpdateLinkTime = d1.GetValue();
                        }
                        else
                        {
                            exceptions.AddRange(d1.GetExceptions());
                        }
                    }
                    else if (r3.Name == "we_are_admin")
                    {
                        we_are_admin = GetWeAreAdminFromJson(r3);
                    }
                }
            }

            var d2 = AddGroupToDb2(chat, lastUpdateLinkTime, we_are_admin, botIdWhoInsertedThem);

            return(new Tuple <bool, List <Exception> >(d2, exceptions));
        }