aboutsummaryrefslogtreecommitdiff
path: root/telegram/handlers.go
diff options
context:
space:
mode:
Diffstat (limited to 'telegram/handlers.go')
-rw-r--r--telegram/handlers.go38
1 files changed, 4 insertions, 34 deletions
diff --git a/telegram/handlers.go b/telegram/handlers.go
index fe4540c..62afd67 100644
--- a/telegram/handlers.go
+++ b/telegram/handlers.go
@@ -2,8 +2,6 @@ package telegram
import (
"fmt"
- "os"
- "path/filepath"
"strconv"
"strings"
"sync"
@@ -107,13 +105,6 @@ func (c *Client) updateHandler() {
uhOh()
}
c.updateDeleteMessages(typedUpdate)
- case client.TypeUpdateFile:
- typedUpdate, ok := update.(*client.UpdateFile)
- if !ok {
- uhOh()
- }
- c.updateFile(typedUpdate)
- log.Debugf("%#v", typedUpdate.File)
case client.TypeUpdateAuthorizationState:
typedUpdate, ok := update.(*client.UpdateAuthorizationState)
if !ok {
@@ -214,10 +205,10 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
}
} else {
text = c.messageToText(update.Message, false)
- file, filename := c.contentToFilename(content)
+ file := c.contentToFile(content)
- // download file(s)
- if file != nil && !file.Local.IsDownloadingCompleted {
+ // download file (if one)
+ if file != nil {
newFile, err := c.DownloadFile(file.Id, 1, true)
if err == nil {
file = newFile
@@ -226,7 +217,7 @@ func (c *Client) updateNewMessage(update *client.UpdateNewMessage) {
// OTR support (I do not know why would you need it, seriously)
if !(strings.HasPrefix(text, "?OTR") || c.Session.RawMessages) {
var prefix strings.Builder
- prefix.WriteString(c.messageToPrefix(update.Message, c.formatContent(file, filename)))
+ prefix.WriteString(c.messageToPrefix(update.Message, c.formatFile(file)))
if text != "" {
// \n if it is groupchat and message is not empty
if chatId < 0 {
@@ -275,27 +266,6 @@ func (c *Client) updateDeleteMessages(update *client.UpdateDeleteMessages) {
}
}
-// file downloaded
-func (c *Client) updateFile(update *client.UpdateFile) {
- // not really
- if !update.File.Local.IsDownloadingCompleted {
- return
- }
-
- err := os.Symlink(
- update.File.Local.Path,
- c.formatFilePath(c.content.Path, update.File.Remote.UniqueId, filepath.Ext(update.File.Local.Path)),
- )
- if err != nil {
- linkErr := err.(*os.LinkError)
- if linkErr.Err.Error() == "file exists" {
- log.Warn(err.Error())
- } else {
- log.Errorf("Error creating symlink: %v", err)
- }
- }
-}
-
func (c *Client) updateAuthorizationState(update *client.UpdateAuthorizationState) {
switch update.AuthorizationState.AuthorizationStateType() {
case client.TypeAuthorizationStateClosing: