All Projects → mmgrt → Tweety

mmgrt / Tweety

Licence: mit
.NET Standard Library to help in managing Twitter Webhook APIs.

Projects that are alternatives of or similar to Tweety

Twitter Bot Bootstrap
Twitter bot bootstrap 👢 using node and twit 🐦
Stars: ✭ 220 (+1900%)
Mutual labels:  bot, twitter
Yii2 Authclient
Yii 2 authclient extension.
Stars: ✭ 430 (+3809.09%)
Mutual labels:  oauth, twitter
oauth
Allow users to log in with GitHub, Twitter, Facebook, and more!
Stars: ✭ 21 (+90.91%)
Mutual labels:  oauth, twitter
Tradingview Webhook Bot
⚙️ Send TradingView alerts to Telegram, Discord, Slack, Twitter and/or Email.
Stars: ✭ 135 (+1127.27%)
Mutual labels:  bot, twitter
Trump2cash
A stock trading bot powered by Trump tweets
Stars: ✭ 6,054 (+54936.36%)
Mutual labels:  bot, twitter
Mastodon Bot
a bot for mirroring Twitter/Tumblr accounts and RSS feeds on Mastodon
Stars: ✭ 158 (+1336.36%)
Mutual labels:  bot, twitter
Play Pac4j
Security library for Play framework 2 in Java and Scala: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 375 (+3309.09%)
Mutual labels:  oauth, twitter
Spam Bot 3000
Social media research and promotion, semi-autonomous CLI bot
Stars: ✭ 79 (+618.18%)
Mutual labels:  bot, twitter
Downloadthisvideo
Twitter bot for easily downloading videos/GIFs off tweets
Stars: ✭ 530 (+4718.18%)
Mutual labels:  bot, twitter
Auth
:atom: Social (OAuth1\OAuth2\OpenID\OpenIDConnect) sign with PHP
Stars: ✭ 457 (+4054.55%)
Mutual labels:  oauth, twitter
Dankenstein
Markov Chain Twitter Bot generator
Stars: ✭ 117 (+963.64%)
Mutual labels:  bot, twitter
Notify
A dead simple Go library for sending notifications to various messaging services.
Stars: ✭ 727 (+6509.09%)
Mutual labels:  bot, twitter
Twitterbot
Golang smart Twitter bot
Stars: ✭ 111 (+909.09%)
Mutual labels:  bot, twitter
Awesome Twitter Bots
🌟Resource repo for Twitter Bots 🐦
Stars: ✭ 170 (+1445.45%)
Mutual labels:  bot, twitter
Cat Facts
Daily cat facts! 🐱
Stars: ✭ 110 (+900%)
Mutual labels:  bot, twitter
Socialmanagertools Gui
🤖 👻 Desktop application for Instagram Bot, Twitter Bot and Facebook Bot
Stars: ✭ 293 (+2563.64%)
Mutual labels:  bot, twitter
Broid Kit
Bot framework powered by Broid
Stars: ✭ 58 (+427.27%)
Mutual labels:  bot, twitter
Likelo
Twitter auto like bot, Under Development👷, Pre Alpha
Stars: ✭ 64 (+481.82%)
Mutual labels:  bot, twitter
Buji Pac4j
pac4j security library for Shiro: OAuth, CAS, SAML, OpenID Connect, LDAP, JWT...
Stars: ✭ 444 (+3936.36%)
Mutual labels:  oauth, twitter
Integrations
Connect your App to Multiple Messaging Channels with the W3C Open standard.
Stars: ✭ 721 (+6454.55%)
Mutual labels:  bot, twitter

Tweety

Tweety is a server-side, .NET Standard Library to help managing Twitter Webhook APIs, Currently, Account Activity API is the only supported API, it provides Direct Messages webhook API. Read more about it: https://dev.twitter.com/webhooks.

NuGet

NuGet

Before you start

As of July, 20th 2017 - You have to request access to the webhook APIs from Twitter using this Form, the process will take few day. Anyways, check this page before you start: https://dev.twitter.com/webhooks/account-activity.

How it works

You Register a webhook by url, that's your server, to Handle incoming messages. Then you Subscribe to a webhook by Webhook Id, then your server will recieve Events for any incoming OR outgoing direct message for/ from the signed in/ subscribed user (in most cases, the user is a bot).

What for?

Well, I'd say mainly for Bots, the WebhooksManager and the SubscriptionsManager will be used once, mostly to register and subscribe your bot twitter account to your server, so you can get any DM as an event and handle it.

Tweety APIs

  • WebhooksManager: Register a webhook, Get a list of registered webhooks and Unregister a webhook.

  • SubscriptionsManager: Subscribe to a webhook, Unsubscribe, or Check if the user is already subscribed or not.

  • WebhookInterceptor: Handles the Challenge Response Check (CRC) ref requests from Twitter and invoking Action<DirectMessageEvent> if received a direct message webhook event after chcecking if the event is really from Twitter or not ref.. will return a InterceptionResult, if IsHandled is true, then return the response to the client, otherwise, you've to handle the request.

  • TweetyAuthContext: Containes the needed information to perform authorizerd Twitter requests, i.e. Consumer Key/ Secret, Access Token/ Secret.

  • DirectMessageSender: Provides an easy way to send Direct Messages to a Twitter user by screen name.

Example: Registerig a Webhook:

     TweetyAuthContext authContext = new Tweety.Authentication.TweetyAuthContext()
     {
          AccessSecret = ACCESS_TOKEN_SECRET,
          AccessToken = ACCESS_TOKEN,
          ConsumerKey = CONSUMER_KEY,
          ConsumerSecret = CONSUMER_SECRET
     };
            
     WebhooksManager webhooksManager = new WebhooksManager(authContext);
     Result<WebhookRegistration> result = webhooksManager.RegisterWebhook("https://something.com/Twitbot");
  
     if (result.Success)
     {
            Console.WriteLine($"Webhook Id {result.Data.Id}");
     }
     else
     {
           Console.WriteLine($"Failed to register webhook, Error: {result.Error.ToString()}");
     }

Example: Subscribing to a Webhook:

     SubscriptionsManager subManager = new SubscriptionsManager(authContext);
     Result<bool> result = await subManager.Subscribe(webhookId);
   
     if(result.Success && result.Data)
     {
           Console.WriteLine($"Successfully subscribed to {webhookId}");
     }
     else
     {
          Console.WriteLine($"Failed to subscribe to a webhook, Error: {result.Error?.ToString() ?? "Error isn't available"}");
     }

Example: Intercepting server request:

I've used Webhook Azure Function to test it, follow Setup Azure Function below if you're interested.

      WebhookInterceptor interceptor = new WebhookInterceptor(CONSUMER_SECRET);
      InterceptionResult result = await interceptor.InterceptIncomingRequest(requestMessage, onMessage);
          
      if (result.IsHandled)
      {
           return result.Response;
      }
      else
      {
           //handle req
      }
      //..
      
      private void onMessage(DirectMessageEvent message)
      {
           Console.WriteLine($"Recieved {message.MessageText} from {message.Sender.Name}.");
      }

Setup Azure Function

  • Go to Azure Portal.
  • Create Azure Function App.
  • Create a Generic Webhook Function.
  • Import Tweety.dll:
    • Clone this repo.
    • Compile using Visual Studio 2017.
    • Create a 'bin' folder in your function folder (same level as run.csx).
    • Upload Tweety.dll to the bin folder.
    • Insert #r "Tweety.dll" at the head of the run.csx file (before the using statements).
  • In the Run method, intercept incoming requests, see the sample: Intercepting server request.

Todo

  • [ ] Provide better documentation.
  • [ ] Do the todos in the code :).

Find me

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].