Skip to content

Commit

Permalink
add basic support for selecting and sending photos. Videos and other …
Browse files Browse the repository at this point in the history
…documents broken
  • Loading branch information
Elia Doumerc committed Jun 19, 2024
1 parent 972abbf commit 58570e6
Show file tree
Hide file tree
Showing 179 changed files with 135 additions and 1,379 deletions.
Binary file modified assets/playbutton.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions packages/TelegramClient-Core.package/.squot-contents

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sending
sendDocumentMessage: aDocumentPath

self core send: (TCCRequest newSendDocumentMessage: aDocumentPath to: self id).
self selectedReplyToMessageId: self class defaultSelectedReplyToMessageId.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sending
sendPhotoMessage: aPhotoPath

self core send: (TCCRequest newSendPhotoMessage: aPhotoPath to: self id).
self selectedReplyToMessageId: self class defaultSelectedReplyToMessageId.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sending
sendVideoMessage: aVideoPath

self core send: (TCCRequest newSendVideoMessage: aVideoPath to: self id).
self selectedReplyToMessageId: self class defaultSelectedReplyToMessageId.
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,11 @@
"requestedMessages:" : "aka 6/15/2022 11:52",
"selectedReplyToMessageId" : "JS 5/20/2022 09:50",
"selectedReplyToMessageId:" : "ek 8/4/2022 11:36",
"sendDocumentMessage:" : "ED 6/19/2024 13:53",
"sendMessage:" : "JK 5/28/2024 09:53",
"sendPhotoMessage:" : "ED 6/19/2024 12:11",
"sendStickerMessage:" : "JK 5/28/2024 10:26",
"sendVideoMessage:" : "ED 6/19/2024 12:23",
"stillRequestedMessages" : "ek 8/4/2022 11:38",
"title" : "rs 6/7/2020 22:24",
"title:" : "5/11/2021 10:09:15",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
instance creation
newSendDocumentMessage: aDocumentPath to: aChatId

^ TCCRequest
newWithType: 'sendMessage'
from: {
'chat_id' -> aChatId.
'input_message_content' -> (Dictionary newFrom: {
'@type' -> 'inputMessageDocument'.
'photo' -> (Dictionary newFrom: {
'@type' -> 'inputFileLocal'.
'path' -> aDocumentPath.
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
instance creation
newSendFileMessage: aPhotoPath to: aChatId

^ TCCRequest
newWithType: 'sendMessage'
from: {
'chat_id' -> aChatId.
'input_message_content' -> (Dictionary newFrom: {
'@type' -> 'inputMessagePhoto'.
'photo' -> (Dictionary newFrom: {
'@type' -> 'inputFileLocal'.
'path' -> aPhotoPath.
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
instance creation
newSendPhotoMessage: aPhotoPath to: aChatId

^ TCCRequest
newWithType: 'sendMessage'
from: {
'chat_id' -> aChatId.
'input_message_content' -> (Dictionary newFrom: {
'@type' -> 'inputMessagePhoto'.
'photo' -> (Dictionary newFrom: {
'@type' -> 'inputFileLocal'.
'path' -> aPhotoPath.
})
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
instance creation
newSendVideoMessage: aVideoPath to: aChatId

^ TCCRequest
newWithType: 'sendMessage'
from: {
'chat_id' -> aChatId.
'input_message_content' -> (Dictionary newFrom: {
'@type' -> 'inputMessageVideo'.
'video' -> (Dictionary newFrom: {
'@type' -> 'inputFileLocal'.
'path' -> aVideoPath.
})
})
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,14 @@
"newRequestFile:" : "JB 8/1/2021 11:35",
"newRequestSticker:" : "JK 5/16/2024 21:39",
"newSearchChatFrom:" : "RS 6/23/2021 16:38",
"newSendDocumentMessage:to:" : "ED 6/19/2024 13:52",
"newSendFileMessage:to:" : "ED 6/19/2024 13:51",
"newSendMessage:to:" : "6/7/2024 09:02:10",
"newSendMessage:to:asReplyTo:" : "JS 5/20/2022 10:02",
"newSendPhoneNumber:" : "RS 6/23/2021 16:34",
"newSendPhotoMessage:to:" : "ED 6/19/2024 12:10",
"newSendStickerMessage:to:" : "JK 5/28/2024 10:52",
"newSendVideoMessage:to:" : "ED 6/19/2024 12:22",
"newSetPollAnswer:message:options:" : "TU 6/6/2024 01:15",
"newUser:" : "JB 8/1/2021 11:55",
"newWithType:from:" : "rs 6/6/2020 16:21" },
Expand Down
5 changes: 0 additions & 5 deletions packages/TelegramClient-UI.package/.squot-contents

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
drawing
addFileButton

self fileButton: (TCUButton new
text: 'Select File';
on: #mouseUp send: #buttonFileSelectPressed to: self;
name: 'selectFile';
yourself).
self inputBar addMorph: self fileButton.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
event handling
buttonFileSelectPressed

| fileEnding fileObject videoEndings photoEndings|

photoEndings := #('jpg' 'jpeg' 'png' 'webp' 'gif' 'bmp').
videoEndings := #('mp4' 'webm' 'mov' 'avi').

fileObject := (FileChooser new initializeAsDialogBox open).
fileObject isNil ifFalse: [
fileEnding := fileObject fullName.
(fileObject fullName endsWithAnyOf: photoEndings) ifTrue: [
self selectedChat sendPhotoMessage: (fileObject fullName)
] ifFalse: [
(fileObject fullName endsWithAnyOf: videoEndings) ifTrue: [
self selectedChat sendVideoMessage: (fileObject fullName).
] ifFalse: [
self selectedChat sendDocumentMessage: (fileObject fullName).
]
]

].
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
fileButton: aTelegramButton

fileButton := aTelegramButton
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
accessing
fileButton

^ fileButton
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ newChatSelected: aChat
self inputBar submorphsDo: #abandon.
self addStickerButton.
self addPollButton.
self addFileButton.
self addSendButton.
self addTextInputField.
self inputBar show.
Expand All @@ -15,6 +16,6 @@ newChatSelected: aChat
addTitleBar;
addHiddenInfoPage;
addHiddenPollEditor.

self chatMessageList show.
self chatMessageList show.
self chatMessageList displayChat: aChat.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ updateReplyMessage
inputFieldText := self textInputField contents asString.
self inputBar submorphsDo: #abandon.
self addStickerButton.
self addPollButton.
self addFileButton.
self addSendButton.
self addTextInputField.
self selectedChat selectedReplyToMessageId = self selectedChat class defaultSelectedReplyToMessageId ifFalse: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
"instance" : {
"addChatMessageList" : "JB 7/6/2021 14:03",
"addChatTitle" : "RK 8/4/2021 12:06",
"addFileButton" : "ED 6/19/2024 10:59",
"addHiddenInfoPage" : "per 6/15/2021 09:02",
"addHiddenPollEditor" : "jkon 6/17/2024 10:25",
"addInputBar" : "jkon 6/17/2024 09:54",
"addInputBar" : "ED 6/19/2024 12:20",
"addMemberCount" : "RK 8/4/2021 12:06",
"addPollButton" : "jkon 6/17/2024 10:19",
"addReplyMessage" : "JS 5/22/2022 19:39",
Expand All @@ -17,6 +18,7 @@
"addTextInputField" : "jkon 6/17/2024 09:58",
"addTitleBar" : "RS 5/29/2021 18:12",
"addWelcomeMessage" : "RK 8/4/2021 12:07",
"buttonFileSelectPressed" : "ED 6/19/2024 13:54",
"buttonSendPressed" : "ek 6/19/2022 19:07",
"buttonStickerPressed" : "JK 6/5/2024 11:12",
"chatMessageList" : "JB 7/6/2021 14:02",
Expand All @@ -25,12 +27,14 @@
"core" : "js 8/2/2020 22:11",
"createInputBar" : "jkon 6/17/2024 09:59",
"createTitleBar" : "ek 6/19/2022 19:08",
"fileButton" : "ED 6/19/2024 11:00",
"fileButton:" : "ED 6/19/2024 10:59",
"infoPage" : "RS 5/20/2021 21:14",
"infoPage:" : "RS 5/20/2021 21:14",
"initialize" : "RS 5/20/2021 19:29",
"inputBar" : "rs 6/13/2020 10:38",
"inputBar:" : "RK 8/4/2021 10:48",
"newChatSelected:" : "jkon 6/17/2024 10:27",
"newChatSelected:" : "ED 6/19/2024 11:16",
"pollButton" : "jkon 6/17/2024 09:51",
"pollButton:" : "jkon 6/17/2024 09:52",
"pollEditor" : "jkon 6/17/2024 10:03",
Expand All @@ -51,6 +55,6 @@
"titleBar:" : "sp 8/2/2020 15:04",
"titleBarEntered" : "ek 6/19/2022 19:08",
"titleBarLeft" : "ek 6/19/2022 19:09",
"updateReplyMessage" : "JK 5/23/2024 20:03",
"updateReplyMessage" : "ED 6/19/2024 12:27",
"welcomeMessage" : "rs 6/13/2020 09:36",
"welcomeMessage:" : "RK 8/4/2021 10:49" } }
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"stickerButton",
"stickerWindow",
"pollButton",
"pollEditor" ],
"pollEditor",
"fileButton" ],
"name" : "TCUChatWindow",
"pools" : [
],
Expand Down
5 changes: 0 additions & 5 deletions packages/TelegramClientTests-UI.package/.squot-contents

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 58570e6

Please sign in to comment.