def command(msg): """Doodle that Doodle""" content_type, chat_type, chat_id = telepot.glance(msg) session = db.Session() doodle_entry = session.query(db.Doodle).filter_by(chat_id=chat_id).first() if not doodle_entry: bot.sendMessage(chat_id, "No doodle saved") return chat_entry = session.query(db.Chat).filter_by(chat_id=chat_id).first() poll = doodle.Doodle(doodle_entry.url) message = DoodleMessage(poll=poll, chat_entry=chat_entry).get_message() reply_markup = None if not poll.is_open: if show_calendar_link: ical_url = get_ical_url_from_db(chat_id=chat_id) if not ical_url: ical_url = DropBoxUploader(poll).get_url() doodle_to_db(url=doodle_entry.url, chat_id=doodle_entry.chat_id, ical_url=ical_url) reply_markup = InlineKeyboardMarkup(inline_keyboard=[ [dict(text='Add to calendar', url=ical_url)] ]) bot.sendMessage(chat_id, message, parse_mode="Markdown", disable_web_page_preview=True, reply_markup=reply_markup) session.close()
# Run this file for combined verbal experiment (longVerbal+shortverbal+longVerbal+shortVerbal) #-------------------imports-------------------------------------------------------------------- import Short_Verbal, Long_Verbal, doodle, setup, variables,newPoints import os, datetime, json from psychopy import event import functions as fc import SQL_call as sql #-------------make necessary objects------------------------------ myPoints = newPoints.NewPoints() var = variables.Variables() doo = doodle.Doodle() dbc = fc.dbconnect() mouse = event.Mouse(setup.mywin) #---------------Main Function------------------------------------- def verbal_odd(var,doo,mouse,myPoints,dbc): expName = os.path.basename(__file__)[:-3] # get expName of this file expDate = datetime.datetime.now().strftime("%Y-%m-%d_T%H_%M_%S") # get expDate [rate_ans, dt_ans, chhist_ans]=fc.survey(doo) # survey subjects' recent time and money scarcity d = {'answer': rate_ans, 'decisionTime': dt_ans, 'choiceHistory': chhist_ans} # record the survey result to database quest = json.dumps(d) fc.about_to_start(doo) # show the get ready instruction var.points = 0 # set total points to 0 for short verbal experiments p_net,points_short1,trials_short1,trialsCorrect_short1 = Short_Verbal.ShortVerbal(var,doo,myPoints,dbc,mouse) # run short verbal session #1 p_num = sql.r_subjid(dbc,p_net) # connect to next session in database fc.block_break(var,doo) # show the break instruction to subject p_net,pick1,pay_delay1,pay_num1,trials_long1,points_long1 = Long_Verbal.LongVerbal(var,doo,myPoints,dbc,mouse,getName=False,sub_id=p_net,gettrialn=0) # run the first long verbal session and record the returned info ses1id = sql.r_sessid(dbc,p_num) numl1 = sql.r_countChoice(dbc,ses1id) # count the number of trials in the first long verbal session fc.block_break(var,doo) # show the break instruction to subject Short_Verbal.ShortVerbal(var,doo,myPoints,dbc,mouse,getName=False,sub_id=p_net,pre_points=points_short1,pre_trials=trials_short1,pre_trialsCorrect=trialsCorrect_short1) # run short verbal session #1 fc.block_break(var,doo) # show the break instruction to subject