Git Product home page Git Product logo

jeududicobot's Introduction

Jeu du Dico Bot

A Twitter bot that tweets a definition of a rare french word and a poll with several words, one being the actual definition's word.

The Twitter bot is @JeuDuDicoBot

How it works

The program looks for a word in the rare words database and for three other words with close lexical properties. The tweet is the definition of the first word, the poll choices are made of all the words shuffled. The program then posts the poll and the tweet containing the poll, and stores the tweet's id and the right word for the poll in a database. Next time the program is run, it will begin by tweeting the right answer for the poll in reply to the poll's tweet.

Post a Twitter poll: not possible anymore

Posting a Twitter poll is currently not supported in the official Twitter Rest API, so you'll need to hack your way to post one this bot is not reproducible anymore. I left the old documentation below for archive purpose if you're curious.

Post a Twitter poll: how it was working before

For that, you must have OAuth Access Tokens for an official Twitter application that supports polls, for instance Twitter for iPhone or Twitter for Android. In this program I used Android, but @fourtonfish has made a good example for iPhone in Python.

  1. Create your Twitter bot's account
  2. Use Twitter's PIN-based authorization with the chosen app's consumer keys and your bot's account to get your official app's OAuth Tokens
  3. Create a Twitter application for your bot and get your app's OAuth Tokens
  4. Create the card_data parameter of your call that looks like this:
  card = {
	'twitter:string:choice1_label': 'choice1',
	'twitter:string:choice2_label': 'choice2',
	'twitter:string:choice3_label': 'choice3',
	'twitter:string:choice4_label': 'choice4',
	'twitter:long:duration_minutes': 1440,
	'twitter:api:api:endpoint': '1',
	'twitter:card': 'poll4choice_text_only', // pollXchoice_text_only if you have X choices (2 <= X <= 4)
    }
  1. Don't forget to stringify (or JSON encode) the card object.
  2. When you make the call to https://caps.twitter.com/v2/cards/create.json, use the user-agent of the official app you chose (in my example: TwitterAndroid/6.45.0 Nexus 4/17 (LGE;mako;google;occam;0))

Databases

It uses two databases:

  • a database of rare french words with their definitions and lexical informations (part of speech, gender and number)
  • a database to store the id of a tweet containing the current poll and the right word for this poll

License

The source code of this bot is available under the terms of the MIT license.

jeududicobot's People

Contributors

whitefangs avatar

Stargazers

 avatar Rowan Lupton avatar Baptiste Fontaine avatar  avatar Code Ruby avatar

Watchers

James Cloos avatar  avatar

jeududicobot's Issues

Actually works?

Hello, is it possible that the system does not work to obtain the official tokens?
I've tried it with android, iphone and more but it always returns "Error 401 unauthorized"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.