How to use the monochrome-bot.Navigation function in monochrome-bot

To help you get started, we’ve selected a few monochrome-bot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mistval / kotoba / bot / src / discord / jisho_search.js View on Github external
chapterForEmojiName[STROKE_ORDER_EMOTE] =
      strokeOrderNavigationChapterInformation.navigationChapter;
  }

  /* Create the examples (E) chapter */

  const examplesNavigationChapter = createNavigationChapterInformationForExamples(
    authorName,
    word,
  );

  chapterForEmojiName[EXAMPLES_EMOTE] = examplesNavigationChapter;

  /* Create the navigation. */

  return new Navigation(authorId, true, JISHO_EMOTE, chapterForEmojiName);
}
github mistval / kotoba / src / discord_commands / pronounce.js View on Github external
function createFoundResult(msg, pronounceInfo, navigationManager, logger) {
  const navigationDataSource = new PronunciationDataSource(
    msg.author.username,
    pronounceInfo,
    logger,
  );

  const navigationChapter = new NavigationChapter(navigationDataSource);
  const chapterForEmojiName = { a: navigationChapter };
  const hasMultiplePages = pronounceInfo.entries.length > 1;
  const authorId = msg.author.id;
  const navigation = new Navigation(authorId, hasMultiplePages, 'a', chapterForEmojiName);
  return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
github mistval / kotoba / bot / src / discord_commands / pronounce.js View on Github external
function createFoundResult(msg, pronounceInfo, navigationManager, logger) {
  const navigationDataSource = new PronunciationDataSource(
    msg.author.username,
    pronounceInfo,
    logger,
  );

  const navigationChapter = new NavigationChapter(navigationDataSource);
  const chapterForEmojiName = { a: navigationChapter };
  const hasMultiplePages = pronounceInfo.entries.length > 1;
  const authorId = msg.author.id;
  const navigation = new Navigation(authorId, hasMultiplePages, 'a', chapterForEmojiName);
  return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
github mistval / kotoba / src / common / jisho_search.js View on Github external
word,
    false,
  );
  if (strokeOrderNavigationChapterInformation.hasAnyPages) {
    chapterForEmojiName[STROKE_ORDER_EMOTE] =
      strokeOrderNavigationChapterInformation.navigationChapter;
  }

  const examplesNavigationChapter = createNavigationChapterInformationForExamples(
    authorName,
    word,
    false,
  ).navigationChapter;
  chapterForEmojiName[EXAMPLES_EMOTE] = examplesNavigationChapter;

  const navigation = new Navigation(authorId, true, JISHO_EMOTE, chapterForEmojiName);
  return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
github mistval / kotoba / src / common / jisho_search.js View on Github external
function createNavigationForKanji(msg, authorName, authorId, kanji, navigationManager) {
  const navigationChapterInformation = createNavigationChapterInformationForKanji(
    authorName,
    kanji,
    true,
    msg.prefix,
  );

  const chapterForEmojiName = {};
  chapterForEmojiName[KANJI_EMOTE] = navigationChapterInformation.navigationChapter;

  const navigation = new Navigation(
    authorId,
    navigationChapterInformation.hasMultiplePages,
    KANJI_EMOTE,
    chapterForEmojiName,
  );

  return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
github mistval / kotoba / bot / src / common / yourei_search.js View on Github external
async function createNavigationForExamples(authorName, authorId, keyword, msg, navigationManager) {
  const searchResults = await scrapeWebPage(keyword);

  if (searchResults.data.sentences.length === 0) {
    return throwPublicErrorInfo('用例.jp', `I didn't find any results for **${keyword}**.`, 'No results');
  }

  const chapters = {};
  chapters[SENTENCES_EMOTE] = createNavigationChapterForSentences(searchResults, authorName, false);
  chapters[FULLTEXT_EMOTE] = createNavigationChapterForSentences(searchResults, authorName, true);
  chapters[USAGE_EMOTE] = createNavigationChapterForUsage(searchResults, authorName);

  const navigation = new Navigation(authorId, true, SENTENCES_EMOTE, chapters);
  return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}
github mistval / kotoba / src / common / jisho_search.js View on Github external
function createNavigationForExamples(msg, authorName, authorId, word, navigationManager) {
  const navigationChapterInformation =
    createNavigationChapterInformationForExamples(authorName, word, true);

  const chapterForEmojiName = {};
  chapterForEmojiName[EXAMPLES_EMOTE] = navigationChapterInformation.navigationChapter;
  const navigation = new Navigation(authorId, true, EXAMPLES_EMOTE, chapterForEmojiName);

  return navigationManager.show(navigation, constants.NAVIGATION_EXPIRATION_TIME, msg.channel, msg);
}