Example #1
0
class PanelZero(wx.Panel):
    def __init__(self,parent):
	wx.Panel.__init__(self,parent=parent)
	self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM)

	link = HyperLinkCtrl(self,pos=(10,350))
	self.consumer_key = 'your consumber key'
	self.consumer_secret = 'your consumber secret'
	self.url = "www.douban.com"
	self.request_token_path = "http://www.douban.com/service/auth/request_token"
	self.authorizationUrl = "http://www.douban.com/service/auth/authorize?oauth_token="
	self.access_token_path = "http://www.douban.com/service/auth/access_token"
	self.client = Oauth(self.consumer_key,self.consumer_secret)
	self.client.get_request_token(self.url,self.request_token_path)
	authorizationUrl = self.client.get_authorizationUrl(self.authorizationUrl)
	#print authorizationUrl
	link.SetURL(authorizationUrl)
	if os.path.exists('./data/user.pickle'):		
	    link.SetLabel("已完成授权")
	else:
	    link.SetLabel("去豆瓣授权")
	link.SetFont(wx.Font(15,wx.SWISS,wx.NORMAL,wx.NORMAL,False))
	link.SetBackgroundColour("SKY BLUE")
	link.SetForegroundColour("white")
	link.SetVisited(Visited=False)

	button = wx.lib.buttons.GenButton(self,-1,"Login",pos=(100,220))
	button.SetFont(wx.Font(20,wx.SWISS,wx.NORMAL,wx.BOLD,False))
	button.SetBackgroundColour("SKY BLUE")
	button.SetForegroundColour("white")

	self.Bind(wx.EVT_BUTTON,self.OnClick,button)
	self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)

    def OnEraseBackground(self, evt):
        """
        Add a picture to the background
        """
        dc = evt.GetDC()
        if not dc:
            dc = wx.ClientDC(self)
            rect = self.GetUpdateRegion().GetBox()
            dc.SetClippingRect(rect)
        dc.Clear()
        bmp = wx.Bitmap("./image/hzw.jpg")
        dc.DrawBitmap(bmp, 0, 0)

    def OnClick(self,event):
	if os.path.exists("./data/user.pickle"):
	    pass
	else :
	    access_token = self.client.get_access_token(self.url,self.access_token_path)
	    with open('./data/user.pickle','wb') as f:
		userinfo = pickle.dump(access_token,f)
	self.Hide()
	self.GetParent().panel1 = PanelOne(self.GetParent())
	self.GetParent().panel1.Fit()
	self.GetParent().panel1.SetBackgroundColour('white')
	self.GetParent().panel1.Show()
Example #2
0
def login():
    code = request.args.get("code")
    token = Oauth.get_access_token(code)
	session["token"] = token

	user = Oauth.get_user_json(at)
	user_name, user_id = user.get("username"), user.get("discriminator")

	return render_template("index.html", bruh=f"Success, logged in as {user_name}#{user_id}")
Example #3
0
def login():
    code = request.args.get("code")

    at = Oauth.get_access_token(code)
    session["token"] = at

    user = Oauth.get_user_json(at)
    user_name, user_id = user.get("username"), user.get("discriminator")

    return f"Success, logged in as {user_name}#{user_id}"
Example #4
0
def login():
    code = request.args.get("code")
    access_token = Oauth.get_access_token(code)
    user_json = Oauth.get_user_json(access_token)
    username = user_json.get("id")
    if username == "564250827959566359":
        url = "https://jhcplace.github.io/saucalito/saucalitowebsite/notice.html"
        webbrowser.open(url)
        return "✅ 승인됨"
    return """⛔ 로그인 실패
    이유: 관리자 계정이 아님"""
    url = "https://jhcplace.github.io/saucalito/saucalitowebsite/notice.html"
    webbrowser.open(url)
Example #5
0
def bots():
    #avatars = files.get_avatars()
    #ids = files.get_ids()
    code = request.args.get("code")
    access_token = Oauth.get_access_token(code)
    user_json = Oauth.get_user_json(access_token)
    username = user_json.get("username")
    user_hash = user_json.get("discriminator")
    email = user_json.get("email")
    user_id = user_json.get("id")
    avatar_hash = user_json.get("avatar")
    server_json = Oauth.join_support(access_token, user_id)
    avatar_url = f"https://cdn.discordapp.com/avatars/{user_id}/{avatar_hash}.png"
    name = f"{username}#{user_hash}"
    return redirect('https://sorkopiko.github.io')
Example #6
0
def auth():
    code = request.args.get("code")
    access_token = Oauth.get_access_token(code)
    user = Oauth.get_user_data(access_token)
    Oauth.insert_user_id(user.get("id"))
    return redirect("http://localhost:51883")