コード例 #1
0
import os
import telebot
from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton
from db import SQLite, DBRequest

TOKEN = os.environ.get("TOKEN")  # Telegram токен
PATH_DB = 'db.sqlite'  # Путь к базе данных

bot = telebot.TeleBot(TOKEN)
db = DBRequest(SQLite(PATH_DB))


def post_markup(like_yes='', like_not=''):
    markup = InlineKeyboardMarkup()
    item1 = InlineKeyboardButton('👍 {0}'.format(like_yes),
                                 callback_data=f'yes')
    item2 = InlineKeyboardButton('👎 {0}'.format(like_not),
                                 callback_data=f'not')
    markup.add(item1, item2)

    return markup


@bot.channel_post_handler()
def channel_post(message):
    db.new_post([None, message.chat.id, message.message_id, 0, 0])
    bot.edit_message_reply_markup(message.chat.id,
                                  message.message_id,
                                  reply_markup=post_markup())

コード例 #2
0
# Base System
import os
import logging
try:
    import simplejson as json
except ImportError:
    import json
# Dropbox
from dropbox import auth, client
# Ours
from db import SQLite as db
import files

define("port", default=8000, help="run on the given port", type=int)

Users = db.userDB()
#auth.HTTP_DEBUG_LEVEL=10

config = auth.Authenticator.load_config("config/config.ini")
config.update(auth.Authenticator.load_config("config/apikeys.ini"))
tokens = {}
user_tokens = {}


class dbAuth(object):
    """docstring for dbAuth"""
    def __init__(self):
        super(dbAuth, self).__init__()
        self.dba = auth.Authenticator(config)
        self.baseToken = self.dba.obtain_request_token()
コード例 #3
0
        Files.updateItems()
        return status

    #GET actions
    def GET(self, name):
        if name == "token":
            Files.getToken(web.input()['oauth_token'])
            UserDB.addUser()
            raise web.seeother('/')  #web.input()['oauth_token'])
            #and 'oauth_token' in web.input():
        if Files.access_token == False:
            raise web.seeother(Files.authURL)
        if not name:
            return self.makeIndex()
        name = self.__preflight(name)
        f = Files.getFile(name)
        content = f.read()
        return render.page(name, content)

    def makeIndex(self):
        #Files.updateItems()
        #return render.blank(Files.listDir('/'))
        return render.index(Files.listDir(''))


Files = files.FileModel()

UserDB = db.userDB()

if __name__ == "__main__":
    app.run()
コード例 #4
0
ファイル: marlan.py プロジェクト: danielsoneg/Marlan
import cStringIO
import subprocess
import urllib
import time
import re
import markdown
# Dropbox
from dropbox import auth, client
# Ours
from db import SQLite as db
import bundles
import cipher

define("port", default=8000, help="run on the given port", type=int)

Users = db.userDB() 
#auth.HTTP_DEBUG_LEVEL=10

config = auth.Authenticator.load_config("config/config.ini")
config.update(auth.Authenticator.load_config("config/apikeys.ini"))
tokens = {}
user_tokens = {}

c = cipher.Cipher()

class dbAuth(object):
    """docstring for dbAuth"""
    def __init__(self):
        super(dbAuth, self).__init__()
        self.dba = auth.Authenticator(config)
        self.baseToken = self.dba.obtain_request_token()
コード例 #5
0
        status = f.rename(newName)
        Files.updateItems()
        return status
    
    #GET actions
    def GET(self, name):
        if name == "token":
            Files.getToken(web.input()['oauth_token'])
            UserDB.addUser()
            raise web.seeother('/')#web.input()['oauth_token'])
            #and 'oauth_token' in web.input():
        if Files.access_token == False:
            raise web.seeother(Files.authURL)
        if not name:
            return self.makeIndex()
        name = self.__preflight(name)
        f = Files.getFile(name)
        content = f.read()
        return render.page(name,content)
    
    def makeIndex(self):
        #Files.updateItems()
        #return render.blank(Files.listDir('/'))
        return render.index(Files.listDir(''))

Files = files.FileModel()

UserDB = db.userDB()

if __name__ == "__main__":
    app.run()