Example #1
0
 def set_lang_id(self, chat_id, lang_id):
     if lang_id is None:
         lang_id = "en"
     Cache().invalidate_lang_cache(chat_id)
     try:
         self.cursor.execute(
             "INSERT INTO chats (chat_id, lang_id) VALUES(?, ?);",
             [chat_id, lang_id])
     except sqlite3.IntegrityError:
         self.cursor.execute(
             "UPDATE chats SET lang_id = ? WHERE chat_id = ?;",
             [lang_id, chat_id])
     self.connection.commit()
Example #2
0
from urllib.parse import urlencode
from hashlib import md5
import json
import re
import datetime
import os

from tornado import gen
from tornado.httpclient import AsyncHTTPClient as HTTPClient
from tornado.httpclient import HTTPRequest
import bs4.element
import requests

from util import Cache, unicode_type, bytes_type

cache = Cache()
jwc_domain = 'http://202.119.81.112:9080'


def login_data(username, password):
    if isinstance(password, unicode_type):
        password = password.encode('utf-8')
    data = {
        'method': 'verify',
        'USERNAME': username,
        'PASSWORD': md5(password).hexdigest().upper()
    }
    return data


def login_session(username, password):