我正在尝试制作paladins stat bot ..我得到了会话和console.log中的响应......但是如何从该控制台获取值以嵌入discord ..我无法获得该值的值..
import sys
from itertools import product
from PyQt5.QtWidgets import (QWidget, QToolTip,
QPushButton, QApplication)
from PyQt5.QtGui import QFont
def bruteForce():
user_password = 'test'.upper()
found = False
BFcounter = 0
BFclearCounter = 0
passwordAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*"
for length in range(1, 10): # it isn't reasonable to try a password more than this length
password_to_attempt = product(passwordAlphabet, repeat=length)
for attempt in password_to_attempt:
attempt = ''.join(attempt) # <- Join letters together
BFcounter += 1
BFclearCounter += 1
if BFcounter < 9999999:
if BFclearCounter > 21546: # The higher the number, the faster the program runs.
print("Attempt Number:", BFcounter, "with attempt of", attempt)
BFclearCounter = 0
elif BFcounter > 20000000 & BFcounter < 10000000:
if BFclearCounter > 145665: # The higher the number, the faster the program runs.
print("Attempt Number:", BFcounter, "with attempt of", attempt)
BFclearCounter = 0
elif BFcounter > 20000001:
if BFclearCounter > 29999956: # The higher the number, the faster the program runs.
print("Attempt Number:", BFcounter, "with attempt of", attempt)
BFclearCounter = 0
else:
print("Attempt Number:", BFcounter, "with attempt of", attempt)
if attempt == user_password:
print("Attempt Number:", BFcounter, "with attempt of", attempt)
print("Your password is: "+ attempt + " and was found in" , BFcounter, "attempts!")
found = True
break
if found:
break
class BruteForceMenu(QWidget):
def __init__(self):
super().__init__()
self.initUI()
def initUI(self):
QToolTip.setFont(QFont('SansSerif', 10))
self.setToolTip('This is a <b>QWidget</b> widget')
bruteForce = QPushButton('Brute Force', self)
bruteForce.setToolTip('This is a <b>QPushButton</b> widget')
bruteForce.resize(bruteForce.sizeHint())
bruteForce.move(50, 50)
bruteForce.clicked.connect(self.callingbruteForce)
self.setGeometry(300, 300, 300, 200)
self.setWindowTitle('Main Menu!')
self.show()
def callingbruteForce(self):
bruteForce()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = BruteForceMenu()
sys.exit(app.exec_())
这是我写的代码......我在控制台得到了结果..
var platform=args[1].toUpperCase();
var player=args[2];
var sessionId;
pal.connect('PC', (err, res) => {
if(!err) {
sessionId = res;
}
pal.getPlayer(sessionId, platform,player,(err,res) => {
if(!err)
var data=res;
// var created=data.value(Created_Datetime);
var embed=new Discord.RichEmbed()
.setAuthor(data.Name)
.addField("created", data.Created_Datetime)
message.channel.sendMessage(embed);
console.log(data);
});
});
我如何嵌入它,即使用RichEmbed()将数据中的这个单独值嵌入? 我对每个领域都没有定义......怎么回事?帮我解决这个问题..我需要完成这个项目..
Created_Datetime: '2/13/2017 2:35:18 PM',
Id: 7221980,
Last_Login_Datetime: '4/14/2018 4:57:36 PM',
Leaves: 37,
Level: 266,
Losses: 1667,
MasteryLevel: 36,
Name: 'HEIMDALL2304',
Personal_Status_Message: '',
RankedConquest:
{ Leaves: 4,
Losses: 23,
Name: 'Conquest',
Points: 0,
PrevRank: 0,
Rank: 0,
Rank_Stat_Conquest: null,
Rank_Stat_Duel: null,
Rank_Stat_Joust: null,
Season: 2,
Tier: 15,
Trend: 0,
Wins: 24,
player_id: null,
ret_msg: null },
Region: 'Southeast Asia',
TeamId: 0,
Team_Name: '',
Tier_Conquest: 15,
Total_Achievements: 54,
Total_Worshippers: 239779435,
Wins: 1734,
ret_msg: null } ]
答案 0 :(得分:0)
由于数据似乎是数组,您是否尝试data[0].Created_Datetime
?
答案 1 :(得分:0)
正如Xzandro上面所说,输出是一个数组,因此data[0].Name
和data[0].Created_Datetime
应该运行良好。
只需使用。如果需要,操作员可以进一步嵌套。
例如,要获得Ranked Conquest中的胜利,请data[0].RankedConquest.Wins
未定义仅表示您尚未指向有效的变量键。所以试试上面的内容,让我们知道它是否有效。