Merge pull request from Dpeta/master

Commited to wrong branch accidentally, whoops.
This commit is contained in:
Dpeta 2020-10-04 18:35:48 +00:00 committed by GitHub
commit 3f2e5f23a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 32 deletions

View file

@ -1,8 +1,15 @@
# Pesterchum Alternate Servers # Pesterchum Alternate Servers
Normal pesterchum documentation is in "README-pesterchum.mkdn", and the one for Karxi's fork is README-karxi.mkdn. A mirror of pesterchum with added functionality to connect to alternative servers in response to the offical servers shutting down on 01-01-2021. (And with an edited setup.py file)
Normal pesterchum documentation is in "README-pesterchum.mkdn" and the one for Karxi's fork is README-karxi.mkdn.
## Servers ## Servers
Currently promts the user on launch to choose a server. The implementation of this very much done incorrectly, but it seems to function in it's current state. Currently promts the user on launch to choose a server. The implementation of this isn't very pretty, but it seems to function in it's current state.
Currently lets you choose between:
* ghostDunk's server
* My server
* @chaoticCharacte's server
## Building ## Building
Just simply running "python setup.py build" seems to be working for me for building on windows now. Just simply running "python setup.py build" seems to be working for me for building on windows now.

View file

@ -1,5 +1,6 @@
# pesterchum # pesterchum
import os, shutil, sys, getopt import os, shutil, sys, getopt
import configparser
if os.path.dirname(sys.argv[0]): if os.path.dirname(sys.argv[0]):
os.chdir(os.path.dirname(sys.argv[0])) os.chdir(os.path.dirname(sys.argv[0]))
import logging import logging
@ -136,7 +137,6 @@ BOTNAMES.extend(CUSTOMBOTS)
_CONSOLE_ENV = AttrDict() _CONSOLE_ENV = AttrDict()
_CONSOLE_ENV.PAPP = None _CONSOLE_ENV.PAPP = None
class waitingMessageHolder(object): class waitingMessageHolder(object):
def __init__(self, mainwindow, **msgfuncs): def __init__(self, mainwindow, **msgfuncs):
self.mainwindow = mainwindow self.mainwindow = mainwindow
@ -3043,6 +3043,38 @@ class MainProgram(QtCore.QObject):
options = self.oppts(sys.argv[1:]) options = self.oppts(sys.argv[1:])
# Choose a server by qt message box.
# Writes the result to server.ini
msgBox = QtGui.QMessageBox()
msgBox.setIcon(QtGui.QMessageBox.Information)
msgBox.setWindowTitle("Choose a server.")
msgBox.setText("Which server do you want to connect to?")
msgBox.addButton(QtGui.QPushButton("ghostDunk's server (Official)"), QtGui.QMessageBox.YesRole)
msgBox.addButton(QtGui.QPushButton("turntechCatnip's server"), QtGui.QMessageBox.NoRole)
msgBox.addButton(QtGui.QPushButton('kaliope.ddns.net'), QtGui.QMessageBox.RejectRole)
ret = msgBox.exec_()
reply = msgBox.buttonRole(msgBox.clickedButton())
config = configparser.ConfigParser()
config.read('server.ini')
if (reply==QtGui.QMessageBox.YesRole):
print("Server is: irc.mindfang.org")
config['SERVER']['server'] = 'irc.mindfang.org'
if (reply==QtGui.QMessageBox.NoRole):
print("Server is: 178.84.124.125")
config['SERVER']['server'] = '178.84.124.125'
if (reply==QtGui.QMessageBox.RejectRole):
print("Server is: kaliope.ddns.net")
config['SERVER']['server'] = 'kaliope.ddns.net'
#Write result to server.ini
with open('server.ini', 'w') as configfile:
config.write(configfile)
def doSoundInit(): def doSoundInit():
# TODO: Make this more uniform, adapt it into a general function. # TODO: Make this more uniform, adapt it into a general function.
if pygame and pygame.mixer: if pygame and pygame.mixer:

View file

@ -14,6 +14,8 @@ from mood import Mood
from dataobjs import PesterProfile, pesterQuirk, pesterQuirks from dataobjs import PesterProfile, pesterQuirk, pesterQuirks
from parsetools import convertTags, addTimeInitial, themeChecker, ThemeException from parsetools import convertTags, addTimeInitial, themeChecker, ThemeException
import configparser # For loading server.ini
_datadir = ostools.getDataDir() _datadir = ostools.getDataDir()
class PesterLog(object): class PesterLog(object):
@ -285,35 +287,10 @@ class userConfig(object):
def server(self): def server(self):
if hasattr(self.parent, 'serverOverride'): if hasattr(self.parent, 'serverOverride'):
return self.parent.serverOverride return self.parent.serverOverride
# Okay, so I tried to use qt to promt the user to choose a server via a message box. # Get chosen server from server.ini
# It seems to ...work... but I know that this isn't the proper way to implement something like this at all. config = configparser.ConfigParser()
# But, uh, I have no clue how to properly use qt. config.read('server.ini')
# If anyone knows how to actually implement something like this please feel free to fix this. return self.config.get('server', config['SERVER']['server'])
# HOPEFULLY this is a temporary solution
msgBox = QtGui.QMessageBox()
msgBox.setIcon(QtGui.QMessageBox.Information)
msgBox.setWindowTitle("Choose a server.")
msgBox.setText("Which server do you want to connect to?")
msgBox.addButton(QtGui.QPushButton("ghostDunk's server (Official)"), QtGui.QMessageBox.YesRole)
msgBox.addButton(QtGui.QPushButton("turntechCatnip's server"), QtGui.QMessageBox.NoRole)
msgBox.addButton(QtGui.QPushButton('kaliope.ddns.net'), QtGui.QMessageBox.RejectRole)
ret = msgBox.exec_()
#pressed_button = msgBox.clickedButton()
reply = msgBox.buttonRole(msgBox.clickedButton())
if (reply==QtGui.QMessageBox.YesRole):
print("Server is: irc.mindfang.org")
return self.config.get('server', 'irc.mindfang.org')
if (reply==QtGui.QMessageBox.NoRole):
print("Server is: 178.84.124.125")
return self.config.get('server', '178.84.124.125')
if (reply==QtGui.QMessageBox.RejectRole):
print("Server is: kaliope.ddns.net")
return self.config.get('server', 'kaliope.ddns.net')
#print(reply)
#return self.config.get('server', 'irc.mindfang.org')
def port(self): def port(self):
if hasattr(self.parent, 'portOverride'): if hasattr(self.parent, 'portOverride'):
return self.parent.portOverride return self.parent.portOverride

2
server.ini Normal file
View file

@ -0,0 +1,2 @@
[SERVER]
server = 178.84.124.125