Giter VIP home page Giter VIP logo

gbf-tweet-parser's Introduction

gbf-tweet-parser

Parser for Granblue Fantasy request backup tweets.

Installing

$ npm install @totoraj930/gbf-tweet-parser

Example

import { parse as parseGbfTweet } from '@totoraj930/gbf-tweet-parser';

/** Example 1 */
const gbfTweet = parseGbfTweet(
  `Help 1234ABCD :参戦ID\n参加者募集!\nLv150 プロトバハムート\nhttps://t.co/9OoqyqkmLc`
);
console.log(gbfTweet);
// ->
// {
//   battleId: '1234ABCD',
//   enemyName: 'プロトバハムート',
//   level: '150',
//   language: 'ja',
//   image: 'https://t.co/9OoqyqkmLc',
//   comment: 'Help'
// }

/** Example 2 */
const gbfTweet2 = parseGbfTweet(
  `ABCD1234 :Battle ID\nI need backup!\nHuanglong & Qilin (Impossible)`
);
console.log(gbfTweet2);
// ->
// {
//   battleId: 'ABCD1234',
//   enemyName: 'Huanglong & Qilin (Impossible)',
//   level: '???',
//   language: 'en'
// }

/** Example 3 */
const gbfTweet3 = parseGbfTweet('Other tweet');
console.log(gbfTweet3);
// -> null

Result format

type GbfTweet = {
  battleId: string;
  enemyName: string;
  level: string; // No data -> '???'
  language: 'ja' | 'en';
  image?: string;
  comment?: string;
};

Notes

If the tweet does not contain an enemy level, level is '???'.

Since level can be a string, the type is always a string.

License

MIT

Reona Oshima (totoraj)

@totoraj_game

gbf-tweet-parser's People

Contributors

totoraj930 avatar

Watchers

 avatar

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.