added support for non top200 permanent games

This commit is contained in:
2019-07-19 10:17:20 +02:00
parent 12c02eed22
commit 4e4b3889d4
3 changed files with 49 additions and 29 deletions

View File

@@ -6,6 +6,7 @@ from threading import Timer
import requests
from mumo_module import (commaSeperatedIntegers, MumoModule)
from tools.SteamApps import SteamApps
from tools.Utils import find_create_channel, get_empty_channels, get_subchannels, get_user_for_channel
@@ -43,14 +44,7 @@ class autochannel(MumoModule):
else:
self.top_list = None
# Load wordlist
r = requests.get("https://raw.githubusercontent.com/dwyl/english-words/master/words.txt")
if r.status_code == 200:
self.wordlist = r.text.splitlines()
self.log().info("Loaded {} words".format(len(self.wordlist)))
else:
self.wordlist = None
self.glist = SteamApps.get_instance()
Timer(60 * 60, self.update_timer).start()
@@ -101,10 +95,7 @@ class autochannel(MumoModule):
self.add_random_channel(server)
def add_random_channel(self, server):
word = self.wordlist[random.randint(0, len(self.wordlist))]
while not word.isalnum():
word = self.wordlist[random.randint(0, len(self.wordlist))]
word = chr(945 + random.randint(0, 24))
self.log().info("Added new channel " + word)
server.addChannel(word, self.random_root.id)
@@ -124,10 +115,15 @@ class autochannel(MumoModule):
for pgame in self.game_channel_permanent:
if pgame:
game = self.top_list[str(pgame)]
if str(pgame) in self.top_list:
game = self.top_list[str(pgame)]
if game:
games[game["name"]] = game
if game:
games[game["name"]] = game
else:
game = self.glist.appid2game(pgame)
if game:
games[game["name"]] = game
channels = get_subchannels(server, self.game_root.id)
games_matched = []