Version 1.0

This commit is contained in:
pyed 2016-07-20 14:48:10 +03:00
parent 26d831d8aa
commit 865347225f
3 changed files with 23 additions and 9 deletions

View File

@ -1,2 +1,15 @@
# transmission-telegram
Not ready yet!
#### Manage your transmission through Telegram.
<img src="https://raw.github.com/pyed/transmission-telegram/master/demo.gif" width="400" />
## 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.
Or if you have `Go` installed: `go get -u github.com/pyed/transmission-telegram`
## Usage
[Wiki](https://github.com/pyed/transmission-telegram/wiki)

BIN
demo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 990 KiB

View File

@ -19,7 +19,7 @@ import (
)
const (
VERSION = "0.0"
VERSION = "1.0"
HELP = `
*list* or *li*
@ -176,7 +176,7 @@ func init() {
var err error
Client, err = transmission.New(RpcUrl, Username, Password)
if err != nil {
log.Print("[ERROR] Transmission: Make sure you have the right URL, Username and Password")
fmt.Fprintf(os.Stderr, "[ERROR] Transmission: Make sure you have the right URL, Username and Password")
os.Exit(1)
}
@ -188,18 +188,17 @@ func init() {
var err error
Bot, err = tgbotapi.NewBotAPI(BotToken)
if err != nil {
log.Printf("[ERROR] Telegram: %s", err)
fmt.Fprintf(os.Stderr, "[ERROR] Telegram: %s", err)
os.Exit(1)
}
log.Printf("[INFO] Authorized: %s", Bot.Self.UserName)
// get a channel and sign it to 'Updates'
u := tgbotapi.NewUpdate(0)
u.Timeout = 60
Updates, err = Bot.GetUpdatesChan(u)
if err != nil {
log.Printf("[ERROR] Telegram: %s", err)
fmt.Fprintf(os.Stderr, "[ERROR] Telegram: %s", err)
os.Exit(1)
}
}
@ -310,6 +309,8 @@ func main() {
}
// list will form and send a list of all the torrents
// takes an optional argument which is a query to match against trackers
// to list only torrents that has a tracker that matchs.
func list(ud tgbotapi.Update, tokens []string) {
torrents, err := Client.GetTorrents()
if err != nil {
@ -848,7 +849,9 @@ func receiveTorrent(ud tgbotapi.Update) {
}
// get the file ID and make the config
fconfig := tgbotapi.FileConfig{ud.Message.Document.FileID}
fconfig := tgbotapi.FileConfig{
FileID: ud.Message.Document.FileID,
}
file, err := Bot.GetFile(fconfig)
if err != nil {
send("receiver: "+err.Error(), ud.Message.Chat.ID, false)
@ -1292,8 +1295,6 @@ func deldata(ud tgbotapi.Update, tokens []string) {
}
}
// help
// version sends transmission version + transmission-telegram version
func version(ud tgbotapi.Update) {
send(fmt.Sprintf("Transmission *%s*\nTransmission-telegram *%s*", Client.Version(), VERSION), ud.Message.Chat.ID, true)