当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript SteamClient.on方法代码示例

本文整理汇总了TypeScript中steam.SteamClient.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SteamClient.on方法的具体用法?TypeScript SteamClient.on怎么用?TypeScript SteamClient.on使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在steam.SteamClient的用法示例。


在下文中一共展示了SteamClient.on方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: function

}, 5000);

var addPendingFriends = function ()
{
    _.each(bot.friends, function (relationship, steamID)
	{
        if (relationship == Steam.EFriendRelationship.RequestRecipient)
		{
            bot.addFriend(steamID);
            console.log(steamID + " was added as a friend");
        }
    });
};

bot.on('error', function (error)
{
	winston.error("Caught Steam error", error);
});

bot.on('loggedOn', function ()
{
	console.log("Success Fully logged on!");
	bot.setPersonaState(Steam.EPersonaState.Online); // to display your bot's status as "Online"
	bot.setPersonaName(STEAMNAME); // to change its nickname

});


bot.MsgToAll = function ( message )
{
	if (bot.loggedOn)
	{
开发者ID:azarus,项目名称:AdminReports,代码行数:32,代码来源:app.ts

示例2: function

MongoClient.connect("mongodb://localhost:27017/gamerscointipbotdb", function(err: any, db: mongodb.Db) {
if (err)
	throw err
var Collections: {
	Users: mongodb.Collection;
	Tips: mongodb.Collection;
	Donations: mongodb.Collection;
	Blacklist: mongodb.Collection;
	Errors: mongodb.Collection;
	OldUsers: mongodb.Collection;
} = {
	Users: db.collection("users"),
	Tips: db.collection("tips"),
	Donations: db.collection("donations"),
	Blacklist: db.collection("blacklist"),
	Errors: db.collection("errors"),
	OldUsers: db.collection("oldusers")
};

var bot = new Steam.SteamClient();
bot.logOn(credentials.steam);
bot.on("loggedOn", function(): void {
	console.log("Logged in as " + credentials.steam.accountName);
	bot.setPersonaState(Steam.EPersonaState.Online) // to display your bot's status as "Online"
	console.log("SteamID: " + bot.steamID);
	
	bot.joinChat(GamersTipGroupID);
	//bot.sendMessage(GamersTipGroupID, "gamerstippingbot is back online");

	unClaimedTipCheck();
	setInterval(unClaimedTipCheck, 1000 * 60 * 60); // Check every hour
});

function getNameFromID(steamID: string): string {
	if (bot.users[steamID])
		return bot.users[steamID].playerName;
	else
		return undefined;
}
function reportError(err: any, context: string, justID: boolean = false) {
	var errorID: string = crypto.randomBytes(16).toString("hex");
	Collections.Errors.insert({
		"id": errorID,
		"timestamp": Date.now(),
		"time": new Date().toString(),
		"error": err,
		"context": context || "No context reported"
	}, {w:0}, function(): void {});
	if (justID) {
		return errorID;
	} else {
		return "An error occurred! Don't worry, it has been reported. To receive support with this error, please include the error code of '" + errorID + "'. Sorry for the inconvenience.";
	}
}
function getHTTPPage(url: string, callback: (err: Error, content: string) => void): void {
	requester(url, function (err, response, body) {
		if (err) {
			err.URL = url;
			callback(err, null);
			return;
		}
		callback(null, body);
	});
}
var prices = {
	"BTC/USD": null,
	"GMC/BTC": null,
	"GMC/USD": null,
	"LastUpdated": null
};
function getPrices(): void {
	async.parallel([
		function(callback) {
			// Coinbase BTC/USD price
			getHTTPPage("https://coinbase.com/api/v1/currencies/exchange_rates", callback);
		},
		function(callback) {
			// Mintpal GMC/BTC price
			getHTTPPage("https://api.comkort.com/v1/public/market/summary?market_alias=gmc_btc", callback);
		}
	], function(err: Error, results: any[]): void {
		if (err) {
			reportError(err, "Getting current prices");
			return;
		}
		try {
			prices["BTC/USD"] = parseFloat(JSON.parse(results[0])["btc_to_usd"]);
			prices["GMC/BTC"] = parseFloat(JSON.parse(results[1]).markets["GMC/BTC"].last_price);
		}
		catch(e) {
			return;
		}
		prices["GMC/USD"] = prices["BTC/USD"] * prices["GMC/BTC"];
		// Return to strings with .toFixed(8)
		prices.LastUpdated = Date.now();
	});
}
getPrices();
// Both API's are updated every minute so update every 5 minutes
setInterval(getPrices, 1000 * 60 * 5);
//.........这里部分代码省略.........
开发者ID:hilmysyarif,项目名称:GamersSteamTipBot,代码行数:101,代码来源:bot.ts


注:本文中的steam.SteamClient.on方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。