[Plugin] xKervanKey (RSilkroad)

Since almost nothing will change and would be easily fixed, doesn’t matter if it’s public or not, even better public for phbot users from RSilkroad.

There are three methods to solve your kervankey (All are manually).

  1. Setting a temporal KervanKey at plugins tab to be used at same phBot
  2. Saving the KervanKey from plugins tab to be used for all phBot’s runnning
  3. Using a website (at this case google spreadsheets) to solve the KervanKey remotely
xKervanKey v0.0.10

The most recent version will be allocated here

from phBot import *
import phBotChat
import QtBind
import os
from time import sleep
import urllib.request

# SET YOUR CUSTOM "xkervankey.txt" PATH HERE.
# xkervankey_path = r"C:\Users\MyUser\Downloads\phBot\Plugins\xkervankey.txt" # EXAMPLE
xkervankey_path = ""

# Initializing GUI
gui = QtBind.init(__name__,'xKervanKey')
lblKey = QtBind.createLabel(gui,"KervanKey:",21,11)
tbxKey = QtBind.createLineEdit(gui,"",130,12,150,18)
btnKey = QtBind.createButton(gui, "btnKey_clicked","Save",300,11)

# Return kervankey file path
def getKervanKeyPath():
	if xkervankey_path:
		return xkervankey_path;
	return os.path.dirname(os.path.realpath(__file__))+"\\xkervankey.txt"

# Save the kervankey from phBot GUI to update all bots
def btnKey_clicked():
	key = QtBind.text(gui,tbxKey)
	if key:
		with open(getKervanKeyPath(), "w") as f:

# Load kervankey from file if exists, return result
def loadKervanKey():
	# Reading key from file
	key = ""
	if os.path.exists(getKervanKeyPath()):
		with open(getKervanKeyPath(),"r") as f:
			key = f.read()
		# Update if file is not empty
		if key:
			QtBind.setText(gui, tbxKey,key)
	# Load from GUI
	key = QtBind.text(gui,tbxKey)
	return key

# Return string containing the kervankey
def getKervanKey():
	# Getting KervanKey from GUI
	key = loadKervanKey()
	# Try to get KervanKey from url
	if not key:
		key = loadKervanKeyFromSite()
	# Checking success through phBot 
	if key:
		log("Plugin: KervanKey has been extracted ["+key+"]")
		log("Plugin: KervanKey not found")
	return key

# Load website to extract the key
def loadKervanKeyFromSite():
	# Emulating a quick browser to open google docs
	req = urllib.request.Request("https://docs.google.com/spreadsheets/d/1xhbP2qcBLscZ7j8D14QqkS44MU1kEkOQZqh24kwdfXQ/export?format=csv", headers={'User-Agent' : "Mozilla/5.0 (Windows NT 6.2; WOW64; rv:22.0) Gecko/20100101 Firefox/22.0"})
	# Getting stream
	resp = urllib.request.urlopen(req)
	# Getting data
	html = str(resp.read().decode("utf-8"))
	# Extracting data from excel (CSV format)
	index = html.find(',RSilkroad - KervanKey :,,,,')
	if index != -1:
		return html[index+28:].split(",")[0]
	return ""

# All chat messages received are sent to this function
def handle_chat(t, player, msg):
	if player:
		if player == "BotCheck" and "BotCheck" in msg:

# Success at loading
log("Plugin: xKervanKey v0.0.10 successfully loaded.")
getKervanKey() # Just for testing purpose

Note: If you want to participate to keep updating the answer at this website, just send me inbox with your Google mail address.


[email protected] this is my gmail addres . I want be admin. ( If you want to participate to keep updating the answer at this website, just send me inbox with your Google mail address.) ı play 7/24

Done! … I saw he change the system again :joy:
I’ll add some field to leave a note or something about your last kervan key edited instead image :male_detective:
Edit: Forget it, it already woks like that! :sweat_smile:


A new version doesn’t necessarily means deleting 50% of the code not used :unamused:

It has enough comments for editing it and not making it public.
If you are making it public, then it will be the best for future changes at that server or any others

1 Like

Yes youre right, i thought about you will feel sad, probably i would do too if i were you. Sorry for that. But i just needed the urllib part of your code, and i didnt want to create another plugin by copying part of yours.