Posting messages works! tho the markers are still being set manually
This commit is contained in:
parent
1c1272337c
commit
7de96b524b
1 changed files with 15 additions and 8 deletions
|
@ -40,6 +40,15 @@
|
||||||
(defvar mattermost-websocket nil
|
(defvar mattermost-websocket nil
|
||||||
"The websocket connected to the server")
|
"The websocket connected to the server")
|
||||||
|
|
||||||
|
(defvar-local mattermost-prompt-marker nil
|
||||||
|
"The marker that shows where the prompt starts")
|
||||||
|
|
||||||
|
(defvar-local mattermost-insert-marker nil
|
||||||
|
"The marker that shows where a new message should be inserted")
|
||||||
|
|
||||||
|
(defvar-local mattermost-channel-id nil
|
||||||
|
"The buffer channel ID")
|
||||||
|
|
||||||
;; ToDo: probably not the best way to get a keyword from a string
|
;; ToDo: probably not the best way to get a keyword from a string
|
||||||
(defun mattermost-string->keyword (str)
|
(defun mattermost-string->keyword (str)
|
||||||
"Returns a keyword from a string"
|
"Returns a keyword from a string"
|
||||||
|
@ -156,6 +165,10 @@ if the user is not present"
|
||||||
(let* ((channel (button-get b 'channel)))
|
(let* ((channel (button-get b 'channel)))
|
||||||
(mattermost-show-channel channel))))
|
(mattermost-show-channel channel))))
|
||||||
|
|
||||||
|
(defun mattermost-create-post (message channel-id)
|
||||||
|
"Creates a post on a channel"
|
||||||
|
(mattermost-request "POST" "/posts" `(:channel_id ,channel-id :message ,message)))
|
||||||
|
|
||||||
(defun mattermost-insert-channel (channel)
|
(defun mattermost-insert-channel (channel)
|
||||||
"Inserts a channel button in the current buffer"
|
"Inserts a channel button in the current buffer"
|
||||||
(let* ((channel-display-name (plist-get channel :display_name))
|
(let* ((channel-display-name (plist-get channel :display_name))
|
||||||
|
@ -271,7 +284,7 @@ user to check their status and select between them")
|
||||||
(if (> (point) mattermost-prompt-marker)
|
(if (> (point) mattermost-prompt-marker)
|
||||||
(let ((inhibit-read-only t)
|
(let ((inhibit-read-only t)
|
||||||
(msg (field-string-no-properties (point))))
|
(msg (field-string-no-properties (point))))
|
||||||
(message "Sending: %s" msg)
|
(mattermost-create-post msg mattermost-channel-id)
|
||||||
(delete-field (point)))))
|
(delete-field (point)))))
|
||||||
|
|
||||||
(defvar mattermost-channel-mode-map
|
(defvar mattermost-channel-mode-map
|
||||||
|
@ -300,13 +313,6 @@ user to check their status and select between them")
|
||||||
|
|
||||||
(with-current-buffer chanb
|
(with-current-buffer chanb
|
||||||
(erase-buffer)
|
(erase-buffer)
|
||||||
|
|
||||||
;; ToDo: is this the place to define the variables?
|
|
||||||
(defvar-local mattermost-prompt-marker nil
|
|
||||||
"The marker that shows where the prompt starts")
|
|
||||||
(defvar-local mattermost-insert-marker nil
|
|
||||||
"The marker that shows where a new message should be inserted")
|
|
||||||
|
|
||||||
(let* ((resp (mattermost-get-channel-messages id))
|
(let* ((resp (mattermost-get-channel-messages id))
|
||||||
(order (seq-reverse (plist-get resp :order)))
|
(order (seq-reverse (plist-get resp :order)))
|
||||||
(posts (plist-get resp :posts)))
|
(posts (plist-get resp :posts)))
|
||||||
|
@ -316,6 +322,7 @@ user to check their status and select between them")
|
||||||
(mattermost-prompt)
|
(mattermost-prompt)
|
||||||
(mattermost-channel-mode))
|
(mattermost-channel-mode))
|
||||||
(switch-to-buffer chanb)
|
(switch-to-buffer chanb)
|
||||||
|
(setq mattermost-channel-id id)
|
||||||
(end-of-buffer)))
|
(end-of-buffer)))
|
||||||
|
|
||||||
(defun mattermost ()
|
(defun mattermost ()
|
||||||
|
|
Loading…
Reference in a new issue