本文整理汇总了TypeScript中steam.SteamClient.logOn方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SteamClient.logOn方法的具体用法?TypeScript SteamClient.logOn怎么用?TypeScript SteamClient.logOn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类steam.SteamClient
的用法示例。
在下文中一共展示了SteamClient.logOn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: TryConnect
// Continuously try to connect if disconnected
function TryConnect()
{
console.log("Trying to connect!");
bot.logOn({
accountName: USERNAME,
password: PASSWORD
});
};
示例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);
//.........这里部分代码省略.........