Beispiel #1
0
        private async Task SaveRawPayload(DateTimeOffset timestamp, JsonDocument doc)
        {
            var update = new RawUpdate(timestamp, doc.RootElement);
            await _db.WriteRaw(update);

            Log.Information("Saved raw event {PayloadHash} at {Timestamp}", update.Id, timestamp);
        }
Beispiel #2
0
        public async Task Debug()
        {
            var update = RawUpdate.ToJson(indented: true);

            var htmlStr = new HtmlString()
                          .Bold("Debug Message").Br()
                          .Code(update).Br();

            await SendMessageTextAsync(htmlStr);
        }
Beispiel #3
0
 public ActionResult <bool> UpdateInventoryPrice(RawUpdate obj)
 {
     if (!ModelState.IsValid)
     {
         return(StatusCode(400, "Failed to create models"));
     }
     else
     {
         if (storeLogic.UpdateDatabase(obj))
         {
             return(StatusCode(201, "Everything updated successfully"));
         }
         else
         {
             return(StatusCode(500, "One or more items may have failed to update."));
         }
     }
 }
Beispiel #4
0
        public async Task CmdAllMember()
        {
            var update = RawUpdate.ToJson(indented: true);

            // var client = await _iWTelegramApiService.CreateClient();
            // client.CollectAccessHash = true;
            // var accessHash = client.GetAccessHashFor<Channel>(ChatId);
            // var chats = await client.Messages_GetAllChats(null);
            // var chat = chats.chats.Values.First(x => x.ID == cid);
            // var channel = (Channel) chats.chats[cid];
            // var channels = await client.Channels_GetParticipants(channel, null, 0, 1000, 0);
            // var cid = ChatId.ReduceChatId();
            // var channels = await client.Channels_GetParticipants(new InputChannel()
            // {
            // access_hash =  client.GetAccessHashFor<Channel>(cid),
            // channel_id = cid
            // }, null, 0, 1000, 0);

            // var fullChat = await client.Messages_GetFullChat(chat.ID);
            // var fullChat = await client.Channels_GetFullChannel(new InputChannel()
            // {
            // access_hash = client.GetAccessHashFor<Channel>(cid),
            // channel_id = cid
            // });

            // var users = fullChat.users.Take(200);

            var channels = await _iWTelegramApiService.GetAllParticipants(ChatId);

            var htmlStr = new HtmlString();

            foreach (var(id, userBase) in channels.users)
            // foreach (var user in channels.users)
            {
                var user = (User)userBase;
                // htmlStr.Text(user.ID.ToString()).Text(" - ").Text(u.first_name).Br();
                // var u = (User)user;
                htmlStr.Text(user.id.ToString()).Text(" - ").Text(user.first_name).Br();
            }

            htmlStr.Br();

            await SendMessageTextAsync(htmlStr);
        }
        public bool UpdateDatabase(RawUpdate obj)
        {
            foreach (RawComp rc in obj.CrustList)
            {
                storeRepo.UpdateCrustInventory(obj.ID, rc.Name, rc.Inventory);
                storeRepo.UpdateCrustPrice(obj.ID, rc.Name, rc.Price);
            }
            foreach (RawComp rc in obj.SizeList)
            {
                storeRepo.UpdateSizeInventory(obj.ID, rc.Name, rc.Inventory);
                storeRepo.UpdateSizePrice(obj.ID, rc.Name, rc.Price);
            }
            foreach (RawComp rc in obj.ToppingList)
            {
                storeRepo.UpdateToppingInventory(obj.ID, rc.Name, rc.Inventory);
                storeRepo.UpdateToppingPrice(obj.ID, rc.Name, rc.Price);
            }

            return(true);
        }
Beispiel #6
0
 public void RawUpdate(RawUpdate n) => Dispatcher.UIThread.InvokeAsync(() => {
     SetColor(LaunchpadGrid.SignalToGrid(n.Index), n.Color.ToScreenBrush());
 });
Beispiel #7
0
 public void Render(RawUpdate n) => Grid.RawUpdate(n);
Beispiel #8
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var tokens = JToken.ReadFrom(reader).ToList();
            var type   = (VKLongPollUpdateType)tokens[0].Value <byte>();

            switch (type)
            {
            case VKLongPollUpdateType.MessageDeleted:
                return(new MessageDeletedUpdate {
                    MessageID = tokens[1].Value <ulong>()
                });

            case VKLongPollUpdateType.MessageFlagsReplaced:
                return(new MessageFlagsReplacedUpdate
                {
                    MessageID = tokens[1].Value <ulong>(),
                    Flags = (VKMessageFlags)tokens[2].Value <ushort>()
                });

            case VKLongPollUpdateType.MessageFlagsSetted:
                return(new MessageFlagsSettedUpdate
                {
                    MessageID = tokens[1].Value <ulong>(),
                    Mask = (VKMessageFlags)tokens[2].Value <ushort>(),
                    UserID = tokens.Count == 4 ? tokens[3].Value <long>() : 0
                });

            case VKLongPollUpdateType.MessageFlagsResetted:
                return(new MessageFlagsResettedUpdate
                {
                    MessageID = tokens[1].Value <ulong>(),
                    Mask = (VKMessageFlags)tokens[2].Value <ushort>(),
                    UserID = tokens.Count == 4 ? tokens[3].Value <long>() : 0
                });

            case VKLongPollUpdateType.MessageReceived:
                var received = new MessageReceivedUpdate
                {
                    MessageID = tokens[1].Value <ulong>(),
                    Flags     = (VKMessageFlags)tokens[2].Value <ushort>(),
                    Timestamp = JsonConvert.DeserializeObject <DateTime>(tokens[4].ToString(), new UnixtimeToDateTimeConverter()),
                    Subject   = tokens[5].ToString(),
                    Text      = tokens[6].ToString()
                };

                long fromID = tokens[3].Value <long>();
                if (fromID > 2000000000)
                {
                    received.ChatID = (uint)(fromID - 2000000000);
                }
                else
                {
                    received.UserID = fromID;
                }

                return(received);

            case VKLongPollUpdateType.ReceivedMessagesReaded:
                break;

            case VKLongPollUpdateType.SentMessagesReaded:
                break;

            case VKLongPollUpdateType.UserOnline:
                break;

            case VKLongPollUpdateType.UserOffline:
                break;

            case VKLongPollUpdateType.FolderFilterFlagsResetted:
                break;

            case VKLongPollUpdateType.FolderFilterFlagsReplaced:
                break;

            case VKLongPollUpdateType.FolderFilterFlagsSetted:
                break;

            case VKLongPollUpdateType.PeerMessagesFlagsReplaced:
                break;

            case VKLongPollUpdateType.PeerMessagesFlagsSetted:
                break;

            case VKLongPollUpdateType.PeerMessagesFlagsResetted:
                break;

            case VKLongPollUpdateType.ChatParametersChanged:
                break;

            case VKLongPollUpdateType.UserIsTypingInDialog:
                return(new UserIsTypingInDialogUpdate {
                    UserID = tokens[1].Value <long>()
                });

            case VKLongPollUpdateType.UserIsTypingInChat:
                return(new UserIsTypingInChatUpdate
                {
                    UserID = tokens[1].Value <long>(),
                    ChatID = tokens[2].Value <uint>()
                });

            case VKLongPollUpdateType.UserMakesACall:
                break;

            case VKLongPollUpdateType.MessagesCounterChanged:
                return(new MessagesCounterChangedUpdate {
                    Number = tokens[1].Value <uint>()
                });

            case VKLongPollUpdateType.NotificationsSettingsChanged:
                break;
            }

            var raw = new RawUpdate {
                Type = type
            };

            raw.UpdateInfo = new object[tokens.Count];

            for (int i = 0; i < tokens.Count; i++)
            {
                raw.UpdateInfo[i] = tokens[i].Value <object>();
            }

            return(raw);
        }