def __init__(self, bot, plugin_root): super(RavingMarkov, self).__init__(bot, plugin_root) db_file = Settings.cache_directory / '{}.sqlite'.format(self.plugin_root) self.pickle_file = Settings.cache_directory / '{}.pickle'.format(self.plugin_root) self.pickle_file.touch(0o666) db.bind('sqlite', str(db_file.absolute()), create_db=True) db.generate_mapping(create_tables=True)
def init_db(): """ Init search queries log db """ orm.sql_debug(True) db.bind(application.config['DB_TYPE'], application.config['DB_STRING'], create_db=True) db.generate_mapping(create_tables=True) print("Database initialized")
CAT_KEYBOARD = ReplyKeyboardMarkup(_grid, selective=True) DB_NAME = 'bot.sqlite' state = dict() logging.basicConfig( format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', level=logging.INFO) logger = logging.getLogger(__name__) u = Updater(TOKEN) dp = u.dispatcher db.bind('sqlite', DB_NAME, create_db=True) db.generate_mapping(create_tables=True) with db_session: if len(select(a for a in Admin if a.id is 10049375)) is 0: # Create initial admin account Admin(id=10049375, first_name="Jannes", super_admin=True) if len(select(a for a in Admin if a.id is 46348706)) is 0: # Create initial admin account Admin(id=46348706, first_name="Jackson", super_admin=True) # pass botan = False if BOTAN_TOKEN: botan = Botan(BOTAN_TOKEN) help_text = "This bot keeps a database of known scammers by recording their " \
import praw import re import time from random import random from ImageScript import build_image, delete_image from config import MEMORABLE_QUOTE_REGEX, source, start, stop from config import bot_username, delete_threshold, already_stopped, stopped from config import started, stopauto, startauto, PMme, numfigs from database import Comment, Bannedsub, Banneduser, Message, Historicalfigure from database import db from pony.orm import db_session, select, delete # connect to the database db.bind(provider='sqlite', filename='database.db') db.generate_mapping(create_tables=False) # connect to the account reddit = praw.Reddit('memorable_quote_bot') # open a single database session @db_session def main(): number_comments = 0 check_inbox() delete_if_downvoted() comments = reddit.subreddit('test').comments(limit=100) for comment in comments: regex = re.search(MEMORABLE_QUOTE_REGEX, comment.body) subname = comment.subreddit.display_name
import import telebot from time import sleep import conts from database import db, insert_wallet, user_exist, insert_deposito, insert_saque, create_user #INSTANCIA MAPEAMENTO SEM CRIAR TABELAS db.bind(provider='sqlite', filename='database.sqlite') db.generate_mapping() #API DO BOT COM TELEGRAM bot = telebot.TeleBot(conts.API_TOKEN) x=2000.00000000 Salcon=--(-x+x)#+(0.5/100) #INICIO DO BOT/ BOTÕES E DATABASE @bot.message_handler(commands=['start']) def handle_start (message): if not user_exist(message.from_user.id): create_user(message.from_user.id, message.chat.id, message.from_user.first_name, carteira="") #BOTÕES DO BOT user_markup = telebot.types.ReplyKeyboardMarkup(True, True) user_markup.row(' NST {:.8f} '.format(Salcon)) user_markup.row('Iniciar', 'Deposito') user_markup.row('Wallet NST', 'Saque', 'Suporte') user_markup.row('Ajuda') bot.send_message(message.from_user.id, 'Seu cadastro foi criado com sucesso! \n' ' Seja, Bem vindo {} ! ao melhor Bot de investimento.'.format(message.from_user.first_name), reply_markup=user_markup)
def init_db(app): db.bind(app.config['DB_TYPE'], app.config['DB_STRING'], create_db=False) db.generate_mapping()
# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import json from telegram.ext import Updater from telegram.contrib.botan import Botan from game_manager import GameManager from database import db import user_setting # required to generate db mapping db.bind('sqlite', 'uno.sqlite3', create_db=True) db.generate_mapping(create_tables=True) gm = GameManager() with open("config.json","r") as f: config = json.loads(f.read()) updater = Updater(token=config.get("token"), workers=config.get("workers", 32)) dispatcher = updater.dispatcher if config.get("botan_token"): botan = Botan(config.get("botan_token")) else: botan = None