當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript hubot.Response類代碼示例

本文整理匯總了TypeScript中hubot.Response的典型用法代碼示例。如果您正苦於以下問題:TypeScript Response類的具體用法?TypeScript Response怎麽用?TypeScript Response使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Response類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: onResponse

async function onResponse(res: Response): Promise<void> {
    const posts = await getCirclejerk(25);
    const post = res.random(posts.data.children).data;

    const messages = [post.title];
    const extraField = post.domain.startsWith('self') ? post.selftext : post.url;
    if (extraField !== '') {
        messages.push(extraField);
    }

    res.send(...messages);
}
開發者ID:mattvperry,項目名稱:DonkeyBot,代碼行數:12,代碼來源:jerk.ts

示例2: loadState

    robot.on('roll', (res: Response, roll: number, max: number) => {
        // If someone rolled out of something other than 100, they are
        // either not playing sniperino or trying to cheat.
        if (max !== 100) {
            return;
        }

        // If there are no active games then this was just an ordinary roll
        const state = loadState(robot.brain);
        const { name, id } = res.message.user;
        const snipe = state.games[id];
        if (snipe === undefined) {
            return;
        }

        const {
            gamesPlayed = 0,
            gamesWon = 0
        } = state.stats[id] || {};

        // Play game
        const event = playGame(roll, snipe);
        state.stats[id] = {
            gamesPlayed: (event !== GameEvent.Draw ? gamesPlayed + 1 : gamesPlayed),
            gamesWon: (event === GameEvent.Win ? gamesWon + 1 : gamesWon),
            userId: id,
        };

        res.send(stringFns[event]({ name, roll }));

        delete state.games[id];
    });
開發者ID:mattvperry,項目名稱:DonkeyBot,代碼行數:32,代碼來源:sniperino.ts

示例3: ilevelList

async function ilevelList(res: Response) {
    res.send(await makeRanking(
        getIlvl,
        i => i.ilvlEquip,
        c => `${c.name}: ${c.ilvlEquip} (${c.ilvl})`,
    ));
}
開發者ID:mattvperry,項目名稱:DonkeyBot,代碼行數:7,代碼來源:wow.ts

示例4: affixes

async function affixes(res: Response) {
    const resp = await Axios.get<{ title: string }>(`${raiderIOUrl}/mythic-plus/affixes`, {
        params: { region: 'us' },
    });

    res.send(resp.data.title);
}
開發者ID:mattvperry,項目名稱:DonkeyBot,代碼行數:7,代碼來源:wow.ts

示例5: raiderioScore

async function raiderioScore(res: Response) {
    res.send(await makeRanking(
        getRaiderIO,
        i => i.mythic_plus_scores.all,
        c => `${c.name}: ${c.mythic_plus_scores.all}`,
    ));
}
開發者ID:mattvperry,項目名稱:DonkeyBot,代碼行數:7,代碼來源:wow.ts

示例6: addUserToTeam

async function addUserToTeam(
  robot: AugmentedRobot,
  response: Response,
  teamId: string,
  otherUserId: string,
  otherUsername: string,
  userId: string,
) {
  const res = await robot.client.addUserToTeam(teamId, otherUserId, userId)
  if (res.statusCode === 400) {
    return response.reply(`Sorry, ${otherUsername} is already in another team and must leave that team first.`)
  }

  if (res.statusCode === 403) {
    return response.reply(`Sorry, you don't have permission to add people to your team.`)
  }

  response.reply('Done!')
}
開發者ID:Codesleuth,項目名稱:hubot-hackbot,代碼行數:19,代碼來源:add_username_to_my_team.script.ts

示例7:

 robot.hear(/hello/i, (res: Response) => {
   res.reply("world")
 })
開發者ID:namikingsoft,項目名稱:hubot-sandbox,代碼行數:3,代碼來源:hello.ts


注:本文中的hubot.Response類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。