turnage / graw

Golang Reddit API Wrapper
MIT License
288 stars 49 forks source link

How to stream mentions? #60

Closed brianardiles closed 4 years ago

brianardiles commented 4 years ago

Hi I trying use this package to stream all mentions of one user

package main

import (
    "fmt"
    "log"

    "github.com/turnage/graw/reddit"
    "github.com/turnage/graw/streams"
)

func main() {
    bot, err := reddit.NewBotFromAgentFile("file.bot", 0)
    if err != nil {
        fmt.Println("Failed to create bot handle: ", err)
        return
    }

    kill := make(chan bool)
    errorChanel := make(chan error)

    resp, err := streams.Mentions(bot, kill, errorChanel)
    comment := <-resp
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("%s", comment.Body)
}

This code works to get the mention but dont stream all the news whow can make that? I search for documentation and cant found

Thanks

brianardiles commented 4 years ago

Already figured out. I needed use the Run function and pass the mention interface