Discord Bot C# Twitch API Integration - c#

I am Currently working on a Discord Bot for my Twitch Channel. This is the first use of C# I have had so I am learning on the way.(I have had prior experience in C and C++.)
The Bot currently will run into the Discord server and when I type a command it will return what I have set it to return.
The next thing that I am wanting to implement is a Twitch Alert in the Announcement Channel that will alert the channel when my channel goes live. I am just getting any where on how to implement the Twitch API so that I can check for the event of me going online.
My question is: How do I connect to the Twitch channel so that I can look for an event indicating the channel has gone Live?

Did you read the twitch api documentation or even search for this yourself? I have no idea about twitch or what they provide for api integrations and i figured this out with 5 minutes of googling.
Twitch has no plan to support webhooks, as mentioned here. Which means you'll have to poll for it (check the streams api to see if a channel is live or not, maybe every minute or so depending on how accurate you want it to be).
Their developer api will talk about how to determine if a channel is live or not - specifically the streams api that lives here.
To summarise what it says there, what you should send a query to the url like the following:
https://api.twitch.tv/kraken/streams/[CHANNEL_ID]
Replacing CHANNEL_ID with the id of the channel you're interested in, and including your developer client id in the headers of the request. (more on this in the docs page i linked)
It will return null if the channel is offline, or a stream object if they are streaming.
When you make this request, you will need to check if the new value is different than the last value that you received when you queried before - if so, the channel state (live/offline) has changed and you should post a message to your discord channel.
I'm not going to code it for you, but you should be able to figure this out now. Search up on how to send a HTTP request, and how to add a custom http header (for the twitch client id header), how to parse JSON etc.

Related

C# Discord get my own messages in real time

I am familiar with Discord Api and I handling requests using a Bot.
However, I need now just to get my user messages (not a bot), and handle the corresponding events.
I am using discord .net but I am not able to find a clear example for this task, that should be simple...
For a bot, I need to create an application in the dev portal. Do I need the same if I just want it for my user?
Discord gateway https://discord.com/developers/docs/topics/gateway is the best option I guess. This example uses javascript with websockets, and no other configuration is required beside the auth token of the guild: https://www.youtube.com/watch?v=uo7ugT_XQKk
Any example about how to read the own user messages in C#?

Botframework reminder chatbot

Does anyone know how they made bot like this and this? I am using BotFramework V4 and C# and i need to make a reminder feature like this.Does this use proactive bot? and if yes can someone explain in layman how proactive bot works? Thanks!
Update:
That likely uses proactive messaging, yes. I'm not sure if either of those use Bot Framework, but to do that in Bot Framework, you'll need proactive messaging.
Samples:
C#
Node
A proactive message is generally either:
A message sent to a user that hasn't spoken with the bot before (this is how Teams defines it), or
A message sent to a user that the bot has spoken with previously, but the message being sent is not really a part of the previous conversation (this is more how Bot Framework defines it)
Please see the docs linked above for more detail.
The gist of it, however, is that when a user talks with the bot, you save a reference to that conversation. At any future date that you want to talk to that user, you use that reference of the conversation (because it contains all of the pertinent user data) to message the user.
The tricky part with something like a reminder, however, is having the bot perform it at a particular time. Something like Task.Delay doesn't work very well at scale over long periods of time. The best thing to do for long, time-based delays would be set up some kind of other server to keep track of the time. Once that time expires, send a request to the bot to send the proactive message. The Proactive Sample does something kind of like the last part of that by accepting requests at api/notify.

Instagram Mention API - not able to retrieve media details in DEV mode

Since the existing instagram APIs are deprecated, I am switching to the graph api.
Below is what i want to achieve and what the issue is.
Requirement.
I would like to track the number of likes and comments on instagram posts in which my business account is mentioned using #. I have setup the faccebook and instagram accounts along with the webhook. The webhook is going to send me the "mediaid" in which i my business account is tagged.
Since the app is in the development mode i am not receiving the webhooks if i mention the business account in any of the post, but i am able to send the test webhook from the developer account console. So i assume once the app is in LIVE mode it will start sending the webhooks to my server.
Once the "mediaid" is received i would like to make a call to another api https://developers.facebook.com/docs/instagram-api/reference/user/mentioned_media
in order to get the number of likes and comments.
I am facing an issue on the 2nd part. Whenever i call the api mentioned in the 2nd part i am getting the error
This api call works fine when i pass the mediaid that my instagram business account owns. But as soon as i pass the mediaid of the post which mentioned my business i am getting the above error.
I just wanted to check if this is also a limitation of my facebook app being in a development mode ? Please suggest a solution to achieve this scenario.
I tried the same what you did but with a live facebook app. From the webhook, I got an event when any other user mentioned my instagram business handle in caption and am able to fetch the mentioned media details using the mentioned media API https://developers.facebook.com/docs/instagram-api/reference/user/mentioned_media.
As you didn't share the webhook event payload, I am just assuming you are using the correct user id while making the API call. The JSON path of the user id in event payload is entry[0].id

Bot Framework on Messenger: Requesting thread control from Page Inbox not working

I have developed a bot and set it as the Primary Receiver on my Page, and set the Inbox as the Secondary Receiver. Everything is working okay except that when I manually send a conversation from "Done" to the Inbox, after a user sends a new message it automatically resends the conversation to the Done folder and for the bot to answer.
This does not happen if I use the "pass_thread_control" graph API request, on these cases the handover works as expected.
I found this documentation: https://developers.facebook.com/docs/messenger-platform/handover-protocol/request-thread-control#page_inbox
And it says that the Primary Receiver has to honor the request thread control event. My question is, how do I ensure this?
I am using the Azure Bot Framework, with .NET.
Facebook Handover is not currently supported by the Bot Framework, and is not on the roadmap, however, it is something they might be able to look into in the future if there’s enough demand.

How to programmatically Login and Retrieve data from Google SMS channel Service using C#

I want to programmatically login and access the data in Google SMS channels using C#. Eg. I want to retrieve data from http://labs.google.co.in/smschannels/channel/wordoftheday. How do I go about it. I looked at Google ClientLogin, but am unable to get it working.
CodeGlobe has an article about how to programmatically login to way2sms.com and send an SMS message. You may be able to use the same technique for the Google SMS channel. I haven't tried this, but it may help you.
Here is the full article on sending SMS messages using C# with way2sms: http://codeglobe.blogspot.com/2010/02/way2sms-send-sms-c-code.html
Well Its been a long time the question has been asked, but anyway google sms channel does not have an api so you wont be able to get the feeds programmatically but if you know the account user you can ask him for rss feeds and parse them using .NET or something.
There is no other way, but you know i hacked around google sms channels to send sms programmatically i just keep updating a .xml file and all the people subscribed to my channel get the sms.

Categories