osdc / bots

Bots for OSDC Community Channels.🤖🤖
MIT License
6 stars 23 forks source link

Add an alert for every new tweet from OSDC twitter account. #5

Closed sidntrivedi012 closed 4 years ago

sidntrivedi012 commented 4 years ago

First-time Contributors

If it is the first time that you contribute to the bot, follow these steps:

  1. You need to have git & golang available on your machine.
  2. Write a comment in this issue thread to let other possible contributors know that you are working on this bug. For eg : Hey all, I would like to work on this issue.
  3. Ping Botfather on Telegram and make your instance of OSDC-Bot bot by selecting /newbot from the options it provides.
  4. Copy the TELEGRAM_TOKEN provided by Botfather.
  5. Fork this repo.
  6. Run git clone https://github.com/<YOUR_USERNAME>/bots.git && cd bots/telegram-bot
  7. If you have installed golang, run go build .
  8. Wait ⏳
  9. Run export TELEGRAM_TOKEN=<botfather_token>
  10. Now, run ./telegram-bot. The bot would be running at the user handle provided by you.
  11. Make changes according to the issue. Test the working of the changes.
  12. Commit the changes and then run git push origin master and then open a PR! 🎉
PrimalPimmy commented 4 years ago

I would like to work on this issue.

daemon1024 commented 4 years ago

Hey @PrimalPimmy, Thanks for showing interest in this. If you have any queries regarding setting up or the issue feel free to ask here 😊

daemon1024 commented 4 years ago

Hey @PrimalPimmy Did you progress with the issue? Feel free to ask if you need any help in implementing it :smile:

PrimalPimmy commented 4 years ago

Hey @PrimalPimmy Did you progress with the issue? Feel free to ask if you need any help in implementing it :smile:

Slowly getting the grasp of Golang. But still learning about how to implement the twitter API in the bot, if you can provide any useful links for this, that'd be helpful!

PrimalPimmy commented 4 years ago

Okay, so I have made some progress.. Here's the tweet function that I created this function for the tweet.. Not showing my tokens for obvious reasons..

func tweet(ID int64) { //Initializing twitter API config := oauth1.NewConfig("consumerKey", "consumerSecret") token := oauth1.NewToken("accessToken", "accessSecret") httpClient := config.Client(oauth1.NoContext, token) Tclient := twitter.NewClient(httpClient)

tweets, resp, err := Tclient.Timelines.HomeTimeline(&twitter.HomeTimelineParams{
    Count: 1,
})
bot.Send(tbot.NewMessage(ID, tweets.Text))

}

But the error here is.. Screenshot from 2020-11-02 18-30-57

Now afaik, the type tweet in the twitter-go package does indeed contain a Text method, given here.. https://godoc.org/github.com/dghubble/go-twitter/twitter#Tweet

So this is the progress so far, but if you can check it out a little, that'd be great too, otherwise it's just almost done I guess.