Compare commits

..

5 Commits
master ... dev

Author SHA1 Message Date
pyed
a396f698a1 Add new line to the error messages 2017-04-09 00:55:03 +03:00
pyed
a47d0ac378 Add the ability to pass the bot token via env variable 2017-04-09 00:44:32 +03:00
pyed
cf54f5d7f6 Fix usage message 2017-04-09 00:09:06 +03:00
pyed
69a0968036 Get rid of 'vendor' as we are no longer using hpcloud/tail 2017-04-02 11:14:58 +03:00
pyed
6c72760e84 Use pyed/tailer instead of hpcloud/tail 2017-04-02 11:13:13 +03:00
4 changed files with 81 additions and 164 deletions

View File

@ -1,3 +0,0 @@
# ignore .git and .cache folders
.git
README.md

View File

@ -1,26 +0,0 @@
FROM golang:alpine as build
ENV GOOS=linux \
GOARCH=amd64
RUN apk add --no-cache git
WORKDIR /go/src/transmission-telegram
COPY . .
RUN go mod init transmission-telegram
RUN go mod tidy
RUN go get -d -v ./...
RUN go install -v ./...
RUN go build -o main .
FROM alpine:latest as certs
RUN apk --update add ca-certificates
FROM bash:latest
COPY --from=certs /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=build /go/bin/transmission-telegram /
RUN chmod 777 transmission-telegram
ENTRYPOINT ["/transmission-telegram"]

View File

@ -4,9 +4,7 @@
<img src="https://raw.github.com/pyed/transmission-telegram/master/demo.gif" width="400" />
## CLI
### Install
## Install
Just [download](https://github.com/pyed/transmission-telegram/releases) the appropriate binary for your OS, place `transmission-telegram` in your `$PATH` and you are good to go.
@ -15,47 +13,3 @@ Or if you have `Go` installed: `go get -u github.com/pyed/transmission-telegram`
## Usage
[Wiki](https://github.com/pyed/transmission-telegram/wiki)
## Docker Alternate Installation Route
### Standalone
```
docker run -d --name transmission-telegram \
kevinhalpin/transmission-telegram:latest \
-token=<Your Bot Token> \
-master=<Your Username> \
-url=<Transmission RPC> \
-username=<Transmission If Needed> \
-password=<Transmissions If Needed>
```
### docker-compose Example
```
version: '2.4'
services:
transmission:
container_name: transmission
environment:
- PUID=${PUID_DOCKUSER}
- PGID=${PGID_APPZ}
image: linuxserver/transmission
network_mode: 'host'
hostname: 'transmission'
volumes:
- ${CONFIG}/transmission:/config
- ${DATA}/transmission/downloads:/downloads
telegram-transmission-bot:
container_name: telegram-transmission-bot
restart: on-failure
depends_on:
- transmission
- plex
- emby
network_mode: 'host'
image: kevinhalpin/transmission-telegram:latest
command: '-token=${TELEGRAM_TRANSMISSION_BOT} -master=${TELEGRAM_USERNAME} -url=${TRANSMISSION_URL} - username=${TRANSMISSION_USERNAME} -password=${PASS}'
```

166
main.go
View File

@ -19,10 +19,10 @@ import (
)
const (
VERSION = "v1.4.1"
VERSION = "v1.4"
HELP = `
*list* or *li* or *ls*
*list* or *li*
Lists all the torrents, takes an optional argument which is a query to list only torrents that has a tracker matches the query, or some of it.
*head* or *he*
@ -32,16 +32,16 @@ const (
Lists the last n number of torrents, n defaults to 5 if no argument is provided.
*down* or *dl*
Lists torrents with the status of _Downloading_ or in the queue to download.
Lists torrents with the status of Downloading or in the queue to download.
*seeding* or *sd*
Lists torrents with the status of _Seeding_ or in the queue to seed.
Lists torrents with the status of Seeding or in the queue to seed.
*paused* or *pa*
Lists _Paused_ torrents.
Lists Paused torrents.
*checking* or *ch*
Lists torrents with the status of _Verifying_ or in the queue to verify.
Lists torrents with the status of Verifying or in the queue to verify.
*active* or *ac*
Lists torrents that are actively uploading or downloading.
@ -50,13 +50,13 @@ const (
Lists torrents with with errors along with the error message.
*sort* or *so*
Manipulate the sorting of the aforementioned commands. Call it without arguments for more.
Manipulate the sorting of the aforementioned commands, Call it without arguments for more.
*trackers* or *tr*
Lists all the trackers along with the number of torrents.
*add* or *ad*
Takes one or many URLs or magnets to add them. You can send a ".torrent" file via Telegram to add it.
Takes one or many URLs or magnets to add them, You can send a .torrent file via Telegram to add it.
*search* or *se*
Takes a query and lists torrents with matching names.
@ -76,7 +76,7 @@ const (
*check* or *ck*
Takes one or more torrent's IDs to verify them, or _all_ to verify all torrents.
*del* or *rm*
*del*
Takes one or more torrent's IDs to delete them.
*deldata*
@ -94,7 +94,7 @@ const (
*help*
Shows this help message.
*version* or *ver*
*version*
Shows version numbers.
- Prefix commands with '/' if you want to talk to your bot in a group.
@ -312,18 +312,10 @@ func main() {
// tokenize the update
tokens := strings.Split(update.Message.Text, " ")
// preprocess message based on URL schema
// in case those were added from the mobile via "Share..." option
// when it is not possible to easily prepend it with "add" command
if strings.HasPrefix(tokens[0], "magnet") || strings.HasPrefix(tokens[0], "http") {
tokens = append([]string{"add"}, tokens...)
}
command := strings.ToLower(tokens[0])
switch command {
case "list", "/list", "li", "/li", "/ls", "ls":
case "list", "/list", "li", "/li":
go list(update, tokens[1:])
case "head", "/head", "he", "/he":
@ -386,7 +378,7 @@ func main() {
case "count", "/count", "co", "/co":
go count(update)
case "del", "/del", "rm", "/rm":
case "del", "/del":
go del(update, tokens[1:])
case "deldata", "/deldata":
@ -395,7 +387,7 @@ func main() {
case "help", "/help":
go send(HELP, update.Message.Chat.ID, true)
case "version", "/version", "ver", "/ver":
case "version", "/version":
go getVersion(update)
case "":
@ -404,7 +396,7 @@ func main() {
default:
// no such command, try help
go send("No such command, try /help", update.Message.Chat.ID, false)
go send("no such command, try /help", update.Message.Chat.ID, false)
}
}
@ -416,7 +408,7 @@ func main() {
func list(ud tgbotapi.Update, tokens []string) {
torrents, err := Client.GetTorrents()
if err != nil {
send("*list:* "+err.Error(), ud.Message.Chat.ID, false)
send("list: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -426,7 +418,7 @@ func list(ud tgbotapi.Update, tokens []string) {
// (?i) for case insensitivity
regx, err := regexp.Compile("(?i)" + tokens[0])
if err != nil {
send("*list:* "+err.Error(), ud.Message.Chat.ID, false)
send("list: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -444,10 +436,10 @@ func list(ud tgbotapi.Update, tokens []string) {
if buf.Len() == 0 {
// if we got a tracker query show different message
if len(tokens) != 0 {
send(fmt.Sprintf("*list:* No tracker matches: *%s*", tokens[0]), ud.Message.Chat.ID, true)
send(fmt.Sprintf("list: No tracker matches: *%s*", tokens[0]), ud.Message.Chat.ID, true)
return
}
send("*list:* no torrents", ud.Message.Chat.ID, false)
send("list: No torrents", ud.Message.Chat.ID, false)
return
}
@ -464,14 +456,14 @@ func head(ud tgbotapi.Update, tokens []string) {
if len(tokens) > 0 {
n, err = strconv.Atoi(tokens[0])
if err != nil {
send("*head:* argument must be a number", ud.Message.Chat.ID, false)
send("head: argument must be a number", ud.Message.Chat.ID, false)
return
}
}
torrents, err := Client.GetTorrents()
if err != nil {
send("*head:* "+err.Error(), ud.Message.Chat.ID, false)
send("head: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -490,7 +482,7 @@ func head(ud tgbotapi.Update, tokens []string) {
}
if buf.Len() == 0 {
send("*head:* no torrents", ud.Message.Chat.ID, false)
send("head: No torrents", ud.Message.Chat.ID, false)
return
}
@ -545,14 +537,14 @@ func tail(ud tgbotapi.Update, tokens []string) {
if len(tokens) > 0 {
n, err = strconv.Atoi(tokens[0])
if err != nil {
send("*tail:* argument must be a number", ud.Message.Chat.ID, false)
send("tail: argument must be a number", ud.Message.Chat.ID, false)
return
}
}
torrents, err := Client.GetTorrents()
if err != nil {
send("*tail:* "+err.Error(), ud.Message.Chat.ID, false)
send("tail: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -571,7 +563,7 @@ func tail(ud tgbotapi.Update, tokens []string) {
}
if buf.Len() == 0 {
send("*tail:* no torrents", ud.Message.Chat.ID, false)
send("tail: No torrents", ud.Message.Chat.ID, false)
return
}
@ -620,7 +612,7 @@ func tail(ud tgbotapi.Update, tokens []string) {
func downs(ud tgbotapi.Update) {
torrents, err := Client.GetTorrents()
if err != nil {
send("*downs:* "+err.Error(), ud.Message.Chat.ID, false)
send("downs: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -644,7 +636,7 @@ func downs(ud tgbotapi.Update) {
func seeding(ud tgbotapi.Update) {
torrents, err := Client.GetTorrents()
if err != nil {
send("*seeding:* "+err.Error(), ud.Message.Chat.ID, false)
send("seeding: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -669,7 +661,7 @@ func seeding(ud tgbotapi.Update) {
func paused(ud tgbotapi.Update) {
torrents, err := Client.GetTorrents()
if err != nil {
send("*paused:* "+err.Error(), ud.Message.Chat.ID, false)
send("paused: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -695,7 +687,7 @@ func paused(ud tgbotapi.Update) {
func checking(ud tgbotapi.Update) {
torrents, err := Client.GetTorrents()
if err != nil {
send("*checking:* "+err.Error(), ud.Message.Chat.ID, false)
send("checking: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -722,7 +714,7 @@ func checking(ud tgbotapi.Update) {
func active(ud tgbotapi.Update) {
torrents, err := Client.GetTorrents()
if err != nil {
send("*active:* "+err.Error(), ud.Message.Chat.ID, false)
send("active: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -804,7 +796,7 @@ func active(ud tgbotapi.Update) {
func errors(ud tgbotapi.Update) {
torrents, err := Client.GetTorrents()
if err != nil {
send("*errors:* "+err.Error(), ud.Message.Chat.ID, false)
send("errors: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -825,7 +817,7 @@ func errors(ud tgbotapi.Update) {
// sort changes torrents sorting
func sort(ud tgbotapi.Update, tokens []string) {
if len(tokens) == 0 {
send(`*sort* takes one of:
send(`sort takes one of:
(*id, name, age, size, progress, downspeed, upspeed, download, upload, ratio*)
optionally start with (*rev*) for reversed order
e.g. "*sort rev size*" to get biggest torrents first.`, ud.Message.Chat.ID, true)
@ -905,10 +897,10 @@ func sort(ud tgbotapi.Update, tokens []string) {
}
if reversed {
send("*sort:* reversed "+tokens[0], ud.Message.Chat.ID, false)
send("sort: reversed "+tokens[0], ud.Message.Chat.ID, false)
return
}
send("*sort:* "+tokens[0], ud.Message.Chat.ID, false)
send("sort: "+tokens[0], ud.Message.Chat.ID, false)
}
var trackerRegex = regexp.MustCompile(`[https?|udp]://([^:/]*)`)
@ -917,7 +909,7 @@ var trackerRegex = regexp.MustCompile(`[https?|udp]://([^:/]*)`)
func trackers(ud tgbotapi.Update) {
torrents, err := Client.GetTorrents()
if err != nil {
send("*trackers:* "+err.Error(), ud.Message.Chat.ID, false)
send("trackers: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -953,7 +945,7 @@ func trackers(ud tgbotapi.Update) {
// add takes an URL to a .torrent file to add it to transmission
func add(ud tgbotapi.Update, tokens []string) {
if len(tokens) == 0 {
send("*add:* needs at least one URL", ud.Message.Chat.ID, false)
send("add: needs atleast one URL", ud.Message.Chat.ID, false)
return
}
@ -963,16 +955,16 @@ func add(ud tgbotapi.Update, tokens []string) {
torrent, err := Client.ExecuteAddCommand(cmd)
if err != nil {
send("*add:* "+err.Error(), ud.Message.Chat.ID, false)
send("add: "+err.Error(), ud.Message.Chat.ID, false)
continue
}
// check if torrent.Name is empty, then an error happened
if torrent.Name == "" {
send("*add:* error adding "+url, ud.Message.Chat.ID, false)
send("add: error adding "+url, ud.Message.Chat.ID, false)
continue
}
send(fmt.Sprintf("*Added:* <%d> %s", torrent.ID, torrent.Name), ud.Message.Chat.ID, false)
send(fmt.Sprintf("Added: <%d> %s", torrent.ID, torrent.Name), ud.Message.Chat.ID, false)
}
}
@ -988,7 +980,7 @@ func receiveTorrent(ud tgbotapi.Update) {
}
file, err := Bot.GetFile(fconfig)
if err != nil {
send("*receiver:* "+err.Error(), ud.Message.Chat.ID, false)
send("receiver: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -1000,7 +992,7 @@ func receiveTorrent(ud tgbotapi.Update) {
func search(ud tgbotapi.Update, tokens []string) {
// make sure that we got a query
if len(tokens) == 0 {
send("*search:* needs an argument", ud.Message.Chat.ID, false)
send("search: needs an argument", ud.Message.Chat.ID, false)
return
}
@ -1008,13 +1000,13 @@ func search(ud tgbotapi.Update, tokens []string) {
// "(?i)" for case insensitivity
regx, err := regexp.Compile("(?i)" + query)
if err != nil {
send("*search:* "+err.Error(), ud.Message.Chat.ID, false)
send("search: "+err.Error(), ud.Message.Chat.ID, false)
return
}
torrents, err := Client.GetTorrents()
if err != nil {
send("*search:* "+err.Error(), ud.Message.Chat.ID, false)
send("search: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -1041,14 +1033,14 @@ func latest(ud tgbotapi.Update, tokens []string) {
if len(tokens) > 0 {
n, err = strconv.Atoi(tokens[0])
if err != nil {
send("*latest:* argument must be a number", ud.Message.Chat.ID, false)
send("latest: argument must be a number", ud.Message.Chat.ID, false)
return
}
}
torrents, err := Client.GetTorrents()
if err != nil {
send("*latest:* "+err.Error(), ud.Message.Chat.ID, false)
send("latest: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -1065,7 +1057,7 @@ func latest(ud tgbotapi.Update, tokens []string) {
buf.WriteString(fmt.Sprintf("<%d> %s\n", torrents[i].ID, torrents[i].Name))
}
if buf.Len() == 0 {
send("*latest:* No torrents", ud.Message.Chat.ID, false)
send("latest: No torrents", ud.Message.Chat.ID, false)
return
}
send(buf.String(), ud.Message.Chat.ID, false)
@ -1074,21 +1066,21 @@ func latest(ud tgbotapi.Update, tokens []string) {
// info takes an id of a torrent and returns some info about it
func info(ud tgbotapi.Update, tokens []string) {
if len(tokens) == 0 {
send("*info:* needs a torrent ID number", ud.Message.Chat.ID, false)
send("info: needs a torrent ID number", ud.Message.Chat.ID, false)
return
}
for _, id := range tokens {
torrentID, err := strconv.Atoi(id)
if err != nil {
send(fmt.Sprintf("*info:* %s is not a number", id), ud.Message.Chat.ID, false)
send(fmt.Sprintf("info: %s is not a number", id), ud.Message.Chat.ID, false)
continue
}
// get the torrent
torrent, err := Client.GetTorrent(torrentID)
if err != nil {
send(fmt.Sprintf("*info:* Can't find a torrent with an ID of %d", torrentID), ud.Message.Chat.ID, false)
send(fmt.Sprintf("info: Can't find a torrent with an ID of %d", torrentID), ud.Message.Chat.ID, false)
continue
}
@ -1159,38 +1151,38 @@ func info(ud tgbotapi.Update, tokens []string) {
func stop(ud tgbotapi.Update, tokens []string) {
// make sure that we got at least one argument
if len(tokens) == 0 {
send("*stop:* needs an argument", ud.Message.Chat.ID, false)
send("stop: needs an argument", ud.Message.Chat.ID, false)
return
}
// if the first argument is 'all' then stop all torrents
if tokens[0] == "all" {
if err := Client.StopAll(); err != nil {
send("*stop:* error occurred while stopping some torrents", ud.Message.Chat.ID, false)
send("stop: error occurred while stopping some torrents", ud.Message.Chat.ID, false)
return
}
send("Stopped all torrents", ud.Message.Chat.ID, false)
send("stopped all torrents", ud.Message.Chat.ID, false)
return
}
for _, id := range tokens {
num, err := strconv.Atoi(id)
if err != nil {
send(fmt.Sprintf("*stop:* %s is not a number", id), ud.Message.Chat.ID, false)
send(fmt.Sprintf("stop: %s is not a number", id), ud.Message.Chat.ID, false)
continue
}
status, err := Client.StopTorrent(num)
if err != nil {
send("*stop:* "+err.Error(), ud.Message.Chat.ID, false)
send("stop: "+err.Error(), ud.Message.Chat.ID, false)
continue
}
torrent, err := Client.GetTorrent(num)
if err != nil {
send(fmt.Sprintf("[fail] *stop:* No torrent with an ID of %d", num), ud.Message.Chat.ID, false)
send(fmt.Sprintf("[fail] stop: No torrent with an ID of %d", num), ud.Message.Chat.ID, false)
return
}
send(fmt.Sprintf("[%s] *stop:* %s", status, torrent.Name), ud.Message.Chat.ID, false)
send(fmt.Sprintf("[%s] stop: %s", status, torrent.Name), ud.Message.Chat.ID, false)
}
}
@ -1198,17 +1190,17 @@ func stop(ud tgbotapi.Update, tokens []string) {
func start(ud tgbotapi.Update, tokens []string) {
// make sure that we got at least one argument
if len(tokens) == 0 {
send("*start:* needs an argument", ud.Message.Chat.ID, false)
send("start: needs an argument", ud.Message.Chat.ID, false)
return
}
// if the first argument is 'all' then start all torrents
if tokens[0] == "all" {
if err := Client.StartAll(); err != nil {
send("*start:* error occurred while starting some torrents", ud.Message.Chat.ID, false)
send("start: error occurred while starting some torrents", ud.Message.Chat.ID, false)
return
}
send("Started all torrents", ud.Message.Chat.ID, false)
send("started all torrents", ud.Message.Chat.ID, false)
return
}
@ -1216,21 +1208,21 @@ func start(ud tgbotapi.Update, tokens []string) {
for _, id := range tokens {
num, err := strconv.Atoi(id)
if err != nil {
send(fmt.Sprintf("*start:* %s is not a number", id), ud.Message.Chat.ID, false)
send(fmt.Sprintf("start: %s is not a number", id), ud.Message.Chat.ID, false)
continue
}
status, err := Client.StartTorrent(num)
if err != nil {
send("*start:* "+err.Error(), ud.Message.Chat.ID, false)
send("stop: "+err.Error(), ud.Message.Chat.ID, false)
continue
}
torrent, err := Client.GetTorrent(num)
if err != nil {
send(fmt.Sprintf("[fail] *start:* No torrent with an ID of %d", num), ud.Message.Chat.ID, false)
send(fmt.Sprintf("[fail] start: No torrent with an ID of %d", num), ud.Message.Chat.ID, false)
return
}
send(fmt.Sprintf("[%s] *start:* %s", status, torrent.Name), ud.Message.Chat.ID, false)
send(fmt.Sprintf("[%s] start: %s", status, torrent.Name), ud.Message.Chat.ID, false)
}
}
@ -1238,17 +1230,17 @@ func start(ud tgbotapi.Update, tokens []string) {
func check(ud tgbotapi.Update, tokens []string) {
// make sure that we got at least one argument
if len(tokens) == 0 {
send("*check:* needs an argument", ud.Message.Chat.ID, false)
send("check: needs an argument", ud.Message.Chat.ID, false)
return
}
// if the first argument is 'all' then start all torrents
if tokens[0] == "all" {
if err := Client.VerifyAll(); err != nil {
send("*check:* error occurred while verifying some torrents", ud.Message.Chat.ID, false)
send("check: error occurred while verifying some torrents", ud.Message.Chat.ID, false)
return
}
send("Verifying all torrents", ud.Message.Chat.ID, false)
send("verifying all torrents", ud.Message.Chat.ID, false)
return
}
@ -1256,21 +1248,21 @@ func check(ud tgbotapi.Update, tokens []string) {
for _, id := range tokens {
num, err := strconv.Atoi(id)
if err != nil {
send(fmt.Sprintf("*check:* %s is not a number", id), ud.Message.Chat.ID, false)
send(fmt.Sprintf("check: %s is not a number", id), ud.Message.Chat.ID, false)
continue
}
status, err := Client.VerifyTorrent(num)
if err != nil {
send("*check:* "+err.Error(), ud.Message.Chat.ID, false)
send("stop: "+err.Error(), ud.Message.Chat.ID, false)
continue
}
torrent, err := Client.GetTorrent(num)
if err != nil {
send(fmt.Sprintf("[fail] *check:* No torrent with an ID of %d", num), ud.Message.Chat.ID, false)
send(fmt.Sprintf("[fail] check: No torrent with an ID of %d", num), ud.Message.Chat.ID, false)
return
}
send(fmt.Sprintf("[%s] *check:* %s", status, torrent.Name), ud.Message.Chat.ID, false)
send(fmt.Sprintf("[%s] check: %s", status, torrent.Name), ud.Message.Chat.ID, false)
}
}
@ -1279,7 +1271,7 @@ func check(ud tgbotapi.Update, tokens []string) {
func stats(ud tgbotapi.Update) {
stats, err := Client.GetStats()
if err != nil {
send("*stats:* "+err.Error(), ud.Message.Chat.ID, false)
send("stats: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -1320,7 +1312,7 @@ func stats(ud tgbotapi.Update) {
func speed(ud tgbotapi.Update) {
stats, err := Client.GetStats()
if err != nil {
send("*speed:* "+err.Error(), ud.Message.Chat.ID, false)
send("speed: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -1357,7 +1349,7 @@ func speed(ud tgbotapi.Update) {
func count(ud tgbotapi.Update) {
torrents, err := Client.GetTorrents()
if err != nil {
send("*count:* "+err.Error(), ud.Message.Chat.ID, false)
send("count: "+err.Error(), ud.Message.Chat.ID, false)
return
}
@ -1393,7 +1385,7 @@ func count(ud tgbotapi.Update) {
func del(ud tgbotapi.Update, tokens []string) {
// make sure that we got an argument
if len(tokens) == 0 {
send("*del:* needs an ID", ud.Message.Chat.ID, false)
send("del: needs an ID", ud.Message.Chat.ID, false)
return
}
@ -1401,17 +1393,17 @@ func del(ud tgbotapi.Update, tokens []string) {
for _, id := range tokens {
num, err := strconv.Atoi(id)
if err != nil {
send(fmt.Sprintf("*del:* %s is not an ID", id), ud.Message.Chat.ID, false)
send(fmt.Sprintf("del: %s is not an ID", id), ud.Message.Chat.ID, false)
return
}
name, err := Client.DeleteTorrent(num, false)
if err != nil {
send("*del:* "+err.Error(), ud.Message.Chat.ID, false)
send("del: "+err.Error(), ud.Message.Chat.ID, false)
return
}
send("*Deleted:* "+name, ud.Message.Chat.ID, false)
send("Deleted: "+name, ud.Message.Chat.ID, false)
}
}
@ -1419,20 +1411,20 @@ func del(ud tgbotapi.Update, tokens []string) {
func deldata(ud tgbotapi.Update, tokens []string) {
// make sure that we got an argument
if len(tokens) == 0 {
send("*deldata:* needs an ID", ud.Message.Chat.ID, false)
send("deldata: needs an ID", ud.Message.Chat.ID, false)
return
}
// loop over tokens to read each potential id
for _, id := range tokens {
num, err := strconv.Atoi(id)
if err != nil {
send(fmt.Sprintf("*deldata:* %s is not an ID", id), ud.Message.Chat.ID, false)
send(fmt.Sprintf("deldata: %s is not an ID", id), ud.Message.Chat.ID, false)
return
}
name, err := Client.DeleteTorrent(num, true)
if err != nil {
send("*deldata:* "+err.Error(), ud.Message.Chat.ID, false)
send("deldata: "+err.Error(), ud.Message.Chat.ID, false)
return
}