Hambergo / 9kmmrbot

MIT License
104 stars 29 forks source link

dota2.schema.lookupEnum is not a function #43

Closed Satont closed 5 years ago

Satont commented 5 years ago

Actual behavior: After npm install, when trying to run via node index get followed error:

C:\Projects\9kmmrbot\lib\dota.js:185
handlers[dota2.schema.lookupEnum('EDOTAGCMsg').values.k_EMsgGCSpectateFriendGame
Response] = function onSpectateFriendGameResponse(message) {
                      ^
TypeError: dota2.schema.lookupEnum is not a function

Version: master https://github.com/Hambergo/9kmmrbot/commit/91eb931907cf11554572bb2bde97206ddf67b96f

Hambergo commented 5 years ago

I don't have time to look currently, but try reverting package.json to the previous commit

Satont commented 5 years ago

Yes it helped

Hambergo commented 5 years ago

commenting out lines 181 to 188 should fix it without reverting package.json (downgrading dependencies)

the functions requestServerSteamId and timeoutSpectateFriendGame in lines 173 and 60 respectively are affected, but currently aren't being called by anything and can be removed

Satont commented 5 years ago

Commented suggested lines, reverted deps to dota: ^7.0.3, steam: ^1.4.1, gettings this:

TypeError: Cannot read property 'toString' of undefined
    at C:\Projects\aibt\index.js:123:374
    at Array.map (<anonymous>)
    at C:\Projects\aibt\index.js:123:157
    at processTicksAndRejections (internal/process/task_queues.js:85:5)

Actual line #123:

let endedGames = games[1].matches.filter(game => !game.players.some(p => p.hero_id == 0) && !games[0].matches.some(g => g.lobby_id == game.lobby_id)).map(game => ({ players: game.players.map(player => ({ account_id: player.account_id, hero_id: player.hero_id })), lobby_id: game.lobby_id, game_mode: game.game_mode, createdAt: game.createdAt, match_id: game.match_id.toString() }))
Satont commented 5 years ago

Well i guess it's because i comented match_id: match.match_id.toString(), on line 99 for temporary fix

Hambergo commented 5 years ago

If it's still not working, a workaround for now would be deleting the old games, and will need to add a check for if there is a match_id

Satont commented 5 years ago

Well now mine index.js exactly same as yours master, dota.js same as yours expect i commented out lines 60-69, 181-188, 172. Added some logging to index.js#94

matches = matches.map(match => {
console.log(match)

Example match i've got:

{
  server_steam_id: '90128497588085768',
  lobby_id: '26282751846208518',
  lobby_type: 7,
  delay: 120,
  game_mode: 2,
  average_mmr: 7668,
  players: [
    { account_id: 124801257, hero_id: 0 },
    { account_id: 129071882, hero_id: 0 },
    { account_id: 114933489, hero_id: 0 },
    { account_id: 876750908, hero_id: 0 },
    { account_id: 155687088, hero_id: 0 },
    { account_id: 176486370, hero_id: 0 },
    { account_id: 90180366, hero_id: 0 },
    { account_id: 91971075, hero_id: 0 },
    { account_id: 202148694, hero_id: 0 },
    { account_id: 34519567, hero_id: 0 }
  ],
  league_id: 0,
  weekend_tourney_skill_level: null,
  weekend_tourney_bracket_round: null,
  specific_games: false
}

My "dota2": "^7.0.3", "steam": "^1.4.1", (for sure i'm did rm -rf node_modules; npm i after changing package.json) I can publish mine fork so you can check something? If you have time ofc. https://github.com/Satont/aibt

Satont commented 5 years ago

Checked additional info from you about #44 issue, you said check node_modules/dota2/proto/dota_gcmessages_client_watch.proto, but it's actualy in node_modules/steam-resources/protobufs/dota2/dota_gcmessages_client_watch.proto, and as i see it already has optional uint64 match_id = 12;

Hambergo commented 5 years ago

I don't really have time to be in front of a computer to check it, But did you try removing the documents in the games collection? (documents added with the old dota dependencies don't have the match ID that make it crash) And adding the match_id=12 was for the old dota2 dependency (6.x dota had their own protobufs, 7.x dota get protobufs from steam-resources)

Satont commented 5 years ago

Yes, removed rps and games collections

Satont commented 5 years ago

ok, finally seems i win https://github.com/Satont/aibt/commit/a66011e5941319959850a935d8691a5b5a16985a

{
  server_steam_id: '90128499222276096',
  lobby_id: '26282767056676931',
  lobby_type: 7,
  delay: 120,
  game_mode: 22,
  average_mmr: 5830,
  players: [
    { account_id: 239665791, hero_id: 84 },
    { account_id: 1003349135, hero_id: 1 }
  ],
  league_id: 0,
  match_id: '4982857882',
  weekend_tourney_skill_level: null,
  weekend_tourney_bracket_round: null,
  specific_games: false
}
Satont commented 5 years ago

You need update master branch i think

Satont commented 5 years ago

Latest problem for me it's !score showing 0-0 even game was found (np). I can create separate issue for that if you want

Hambergo commented 5 years ago

Score only updates after a game was played and finished, and assuming the api is working (which I heard today is very buggy)

Satont commented 5 years ago

Yea, game finished, right now api working good i guess? but score still showing 0-0

Satont commented 5 years ago

I see !score command using

let lastGames = mongoDb().collection('last games').find({ 'players.account_id': { $in: accounts }, createdAt: { $gte: stream_start }, lobby_type: { $in: [0, 1, 7] }, game_mode: { $in: [1, 2, 3, 4, 5, 8, 12, 16, 17, 18, 19, 20, 22, 23] } }).toArray()

Debugging via console.log(lastGames) and it's empty array ([]), but i manually checked some past match id for that stream:

db['last games'].find({match_id:'4983120627'})
{ "_id" : ObjectId("5d60472943fdfe197d966fda"), "players" : [ { "account_id" : 295977625, "hero_id" : 53 }, { "account_id" : 77894287, "hero_id" : 34 }, { "account_id" : 58737711, "hero_id" : 9 }, { "account_id" : 175299893, "hero_id" : 31 }, { "account_id" : 170910439, "hero_id" : 42 }, { "account_id" : 835889876, "hero_id" : 44 }, { "account_id" : 82709673, "hero_id" : 114 }, { "account_id" : 383718819, "hero_id" : 84 }, { "account_id" : 132062102, "hero_id" : 25 }, { "account_id" : 410951280, "hero_id" : 21 } ], "createdAt" : ISODate("2019-08-23T20:05:31.417Z"), "game_mode" : 22, "lobby_id" : "26282832731809243", "match_id" : "4983120627" }

Also mine stream_start = 1566584452

seems like lobby_type is missed for games and last games collections, i'll add this and will post results

Satont commented 5 years ago

Still same behavior :(

Satont commented 5 years ago

Ok, i got it to fix!

Step1: actually Score.js missed steamApi import, so lets import it by

const steamApi = require('../steamApi')

Step2: lastGames is empty array because we just not found any game from db , even they exists, so here is some js problem. I fixed it by:

createdAt: { $gte: stream_start }

->>>

createdAt: { $gte: new Date(stream_start * 1000) }

And finally !score started working. But seems showing incorrect info. I'll try flush last games, game details, games, rps

Satont commented 5 years ago

All is fixed.