當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。