def post_forum(): if 'username' in session: form = forumForm(request.form) retrieve_forum_count = root.child('forumCount').get() forumCount = int(retrieve_forum_count['forumCount']) if request.method == 'POST': text = form.forumText.data type = form.forumType.data newForum = Forum(text, type) increaseCount = forumCount + 1 newCount = root.child('forumCount/forumCount').set(increaseCount) newForum_db = root.child('Forum') newForum_db.push({ 'count': str(increaseCount), 'text': newForum.get_text(), 'type': newForum.get_type(), 'time': newForum.get_date(), 'username': session['username'], 'response': { 'response': 'empty' }, 'responseCount': 0 }) return redirect(url_for('forum')) return render_template('postForum.html', form=form) else: return redirect(url_for('login'))
def main(): # pubg forum f = Forum(id, token, username) f.run() ## currently a little buggy. # pubg reddit #r = Reddit(id, token, username) #r.run() #sqlite3 conn.close()
def details(): request_data = get_json(request) if "related" not in request_data: request_data["related"] = None code, response = Forum.details(request_data["forum"], request_data["related"]) return json.dumps({"code": code, "response": response})
def main(): from sys import argv import pickle from pprint import pprint if argv[1] == 'fetch': f = Forum(argv[2], argv[3]) d = f.get_thread(argv[4]) pickle.dump(d, open(argv[5], 'wb')) elif argv[1] == 'diff': old = pickle.load(open(argv[2], 'rb')) new = pickle.load(open(argv[3], 'rb')) for i in diff(old, new): print(i) elif argv[1] == 'new': d = pickle.load(open(argv[2], 'rb')) for i in diff(None, d): print(i) elif argv[1] == 'dump': pprint(pickle.load(open(argv[2], 'rb'))) elif argv[1] == 'merge': data0 = pickle.load(open(argv[2], 'rb')) data1 = pickle.load(open(argv[3], 'rb')) data2 = pickle.load(open(argv[4], 'rb')) d = [] merge_diff(d, None, data0) for i in d: print(i) print() merge_diff(d, data0, data1) for i in d: print(i) print() merge_diff(d, data1, data2) for i in d: print(i) print()
def create(): request_data = get_json(request) request_data["name"] = request_data["name"].encode("utf-8") columns = ", ".join(request_data.keys()) values = get_values(request_data) code, response = Forum.insert(columns, values, request_data["short_name"]) return json.dumps({"code": code, "response": response})
def post_forum(): form = forumForm(request.form) if request.method == 'POST': text = form.forumText.data type = form.forumType.data newForum = Forum(text,type) newForum_db = root.child('Forum') newForum_db.push( { 'text' : newForum.get_text(), 'type' : newForum.get_type(), 'time' : newForum.get_date() }) return redirect(url_for('forum')) return render_template('postForum.html',form=form)
db.commit() run += 1 rest += 1 if rest > 50: print(f'{run} Finished!') time.sleep(5) rest = 0 db.close() #----------------------=-----------------# #----------------------=-----------------# #----------------------=-----------------# #----------------------=-----------------# bot = Flask(__name__) Forum = Forum(bot) trade.init(bot) print(os.listdir('/home/runner/Pokezira/templates/static/')) socketio = SocketIO(bot) @bot.route('/profile') def profile(): session.clear() return 'hi' @bot.route('/cdn/sounds/music/<file>') def music(file): return send_file(f'./sounds/music/{file}') @bot.route('/cdn/sprite/<folder>/<sprite>')
root_dir = config['root_dir'] logger_file = config['logger_file'] or None database_file = config['database_file'] utils.read_file = partial(utils.read_file, root_dir) utils.construct_http_response = partial(utils.construct_http_response, HttpServer.SUPPORTED_HTTP_VERSION) server = HttpServer( root_dir=root_dir, host=host, port=int(port), logger_file=logger_file ) server._db = LoginDatabase(database_file) server._forum = Forum(server._db, "forum/") server._db.add_user("Admin", "", properties={ "uid": 1, "role": "admin", "threads": 0, "threads_ref": [], "posts": 0, "posts_ref": [], "reputation": 0, "reputation_content": {}, "ip": "127.0.0.1", "biography": "", "inbox": [] })
def main(): # pubg forum f = Forum(config.id, config.token, config.bot_name) f.run()
from exceptions import PermissionDenied from forum import Forum from thread import Thread from post import Post # This file does not need to contain any code. The marker runs program.py and tests the # classes imported above. You can put any testing code (that won't be run by the marker) # in the block below. if __name__ == '__main__': # Test your code here. This will not be checked by the marker. # Here is the example from the question. forum = Forum() thread = forum.publish('Battle of Zela', 'Veni, vidi, vici!', 'Caesar') thread.set_tags(['battle', 'brag'], 'Caesar') thread.publish_post(Post('That was quick!', 'Amantius')) thread.publish_post(Post('Hardly broke a sweat.', 'Caesar')) thread.publish_post(Post('Any good loot?', 'Amantius')) # Search by author print("The contents of Caesar's posts:") caesar_posts = forum.search_by_author('Caesar') print(sorted([p.get_content() for p in caesar_posts])) print() # Edit content of an existing post existing = thread.get_posts()[0] existing.set_content('I came, I saw, I conquered!', 'Caesar') # Upvote a post: existing.upvote('Cleopatra')
#!usr/bin/python3.9 from forum import Forum import logging import datetime from helper import open_file from settings import api_settings if __name__ == '__main__': logging.basicConfig(level=logging.INFO) logging.info('initializing forum connection') f = Forum(api_settings['forum_url'], api_settings['api_name'], api_settings['api_key']) logging.info('testing connectivity') f.check_connection() todayday = datetime.datetime.today().weekday() message = "" t_id = 0 logging.info('checking day') topics = [dic for dic in f.get_latest_topics(5)['topic_list']['topics'] if dic['pinned'] is False][:10] if todayday == 2: votes_tn = open_file("tn.train") if votes_tn: message = "Votes for this TN:\n" for item in votes_tn: message += item['who'] + ": " + item['where'] + "\n" else: message = "No votes from Chats for this FM :( \n" t_id = next(item['id'] for item in topics if "Tuesdayness" in item['title'])
#!usr/bin/python3.9 from forum import Forum import requests import logging import dateutil.parser as DP from settings import api_settings, bot_settings, route_settings if __name__ == '__main__': logging.basicConfig(level=logging.INFO) logging.info('initializing forum connection') f = Forum(api_settings['forum_url'], api_settings['api_name'], api_settings['api_key']) logging.info('testing connectivity') f.check_connection() logging.info('getting new topics') dif = f.compare_topics(5, ['id'], ['slug'], ['excerpt'], ['tags'], ['created_at'], ['title'], ['event', 'start']) if dif: logging.info(str(len(dif)) + 'new topics found, iterating through') for item in dif: tag_txt = start_txt = "" if len(item['excerpt']) == 100: item['excerpt'] = item['excerpt'][:97] + "..." if item['tags']: tag_txt = "(Tags: " + str(item['tags']) + ")" if item['event, start']: start_txt = "*Wann:* " + str(DP.parse( item['event, start']))[:20] + "\n"
def retrieve_posts(user, course): forum = Forum(user=user, host=host, db=db) return forum.post_contents(attr, table, course)