예제 #1
0
 def get_moderators(self):
     with dbapi2.connect(app.config['dsn']) as connection:
         cursor = connection.cursor()
         query = """SELECT ID, NICKNAME, PASSWORD FROM MODERATORS
             ORDER BY ID"""
         cursor.execute(query)
         modTable = [(id, Moderator(nickname, password))
                     for id, nickname, password in cursor]
         connection.commit()
         cursor.close()
     return modTable
예제 #2
0
def signup_page():
    if request.method == 'GET':
        return render_template('signup.html')
    else:
        nickname = str(request.form['nickname'])
        password = str(request.form['password'])
        hashed = pwd_context.encrypt(password)
        moderator = Moderator(nickname, hashed)
        app.moderatorlist.add_moderator(moderator)
        modid = app.moderatorlist.get_moderator(nickname)

        login_user(moderator)
        return redirect(url_for('site.home_page'))
예제 #3
0
def mod_add_page():
    if not current_user.nickname == 'admin':
        abort(401)
    if request.method == 'GET':
        return render_template('modedit.html')
    else:
        nickname = str(request.form['nickname'])
        password = str(request.form['password'])
        hashed = pwd_context.encrypt(password)
        moderator = Moderator(nickname, hashed)
        current_app.moderatorlist.add_moderator(moderator)
        modid = current_app.moderatorlist.get_moderator(moderator.nickname)
        message = 'Moderator is added.'
        return redirect(url_for('mods.moderators_page'))
예제 #4
0
 def get_moderatorObj(self, mod_name):  # def get_user
     empty = 'Empty'
     with dbapi2.connect(app.config['dsn']) as connection:
         cursor = connection.cursor()
         query = """SELECT PASSWORD FROM MODERATORS WHERE (NICKNAME = (%s))"""
         cursor.execute(query, (mod_name, ))
         mod_pass = cursor.fetchone()
         connection.commit()
         if mod_pass is None:
             mod = None
         else:
             mod = Moderator(mod_name, mod_pass[0])  #[0]
         cursor.close()
         return mod
예제 #5
0
def main():
    """
    Program Driver.
    Adds a moderator to the fam class and sets up a user
    """
    driver = Fam(Moderator())

    while True:
        try:
            option = input('Test user? (y/n)')
            if option.lower() == 'y':
                driver.moderator.load_test_user()
            elif option.lower() == 'n':
                driver.moderator.load_user()
            else:
                continue

        except ValueError:
            print('Please check parameters!')
            continue
        else:
            break
    driver.main_menu()
예제 #6
0
def test():
    # ウツロのかけら初期デッキとホノカのかけら初期デッキを設定
    moderator = Moderator(utsuro_no_kakera_1, honoka_no_kakera_1)

    # 決闘開始
    moderator.start_battle()
예제 #7
0
loop = asyncio.get_event_loop()
loop.set_task_factory(context.task_factory)


def get_proxy_data():
    if config.PROXY_URL and config.PROXY_LOGIN and config.PROXY_PASSWORD:
        proxy = config.PROXY_URL
        if proxy.startswith('socks5'):
            import aiosocksy
            logger.info('Socks5 proxy enabled.')
            proxy_auth = aiosocksy.Socks5Auth(login=config.PROXY_LOGIN, password=config.PROXY_PASSWORD)
        else:
            import aiohttp
            logger.info('HTTP proxy enabled.')
            proxy_auth = aiohttp.BasicAuth(login=config.PROXY_LOGIN, password=config.PROXY_PASSWORD)
    else:
        logger.info('Proxy disabled.')
        proxy = None
        proxy_auth = None

    return proxy, proxy_auth


# vars and instances
url, auth = get_proxy_data()
bot = Bot(token=config.TELEGRAM_TOKEN, loop=loop, proxy=url, proxy_auth=auth, parse_mode=types.ParseMode.HTML)
dp = Dispatcher(bot, storage=MemoryStorage(), run_tasks_by_default=True)
cb = Chatbase(api_key=config.CHATBASE_KEY, loop=loop, platform='Telegram', task_mode=True,
              pool_size=config.CHATBASE_POOL_SIZE)
moder = Moderator(bot, cb)
예제 #8
0
 def as_dict(self):
     d = Moderator.as_dict(self)
     d["another_additional_attribute"] = self.another_additional_attribute
     return d
예제 #9
0
 def __init__(self, id=None, name=None, email=None, password=None, additional_attribute=None,
              another_additional_attribute=None):
     Moderator.__init__(self, id, name, email, password, additional_attribute)
     self.another_additional_attribute = another_additional_attribute
예제 #10
0
 def load(self, file_object):
     object_as_dict = Moderator.load(self, file_object)
     self.another_additional_attribute = object_as_dict["another_additional_attribute"]
     return object_as_dict
예제 #11
0
# Ex 9-8

from moderator import Moderator

mod = Moderator('John', 'Doe')
mod.privileges.show_privileges()

    
예제 #12
0
파일: main.py 프로젝트: bouttier/sms
#!/usr/bin/python
# -*- coding: utf-8 -*-

from sender import Sender
from moderator import Moderator
from receiver import receive


s = Sender()
m = Moderator(s.send)

m.start()
s.start()

receive(m.moderate, s.send)
예제 #13
-31
from moderator import Moderator
from admin import Admin
name = (raw_input("Write your username: "))
if __name__ == '__main__':
    player1 = Player(name)
    player1.register()
    player1.login()
    player1.init_money()
    player1.give_money(USD, 1000)
    player1.give_money(USD, 2000)
    player1.give_money(GOLD, 20)
    player1.take_money(GOLD, 50)
    player1.logout()
    print(player1.sessions)
    print(player1.player_as_dict())
    moder1 = Moderator(name)
    moder1.register()
    moder1.login()
    moder1.give_a_ban()
    moder1.take_a_ban()
    moder1.logout()
    print(moder1.moderator_as_dict())
    admin1 = Admin(name)
    admin1.register()
    admin1.login()
    admin1.make_a_moderator()
    import MySQLdb

    con = MySQLdb.connect('localhost', 'root', 'root', 'classes');

    with con: