Example #1
0
def editmsg_captopn(bot, update):
    chatid = update.message.chat_id
    text = update.message.text
    username = database.get_username(update.message.chat_id)
    message_id = database.get_message_id(update.message.chat_id)
    if message_id is None:
        update.message.reply_text("پیام شما قابل ادیت شدن نمی باشد")
    else:
        likes = database.get_like_dislike(message_id)
        button_list = [
            InlineKeyboardButton("👎🏻   " + str(likes[1]),
                                 callback_data="dislike"),
            InlineKeyboardButton("👍🏻   " + str(likes[0]),
                                 callback_data="like"),
        ]
        reply_markup = InlineKeyboardMarkup(build_menu(button_list, n_cols=2))
        bot.edit_message_caption(chat_id=config.channelid,
                                 message_id=message_id,
                                 caption=text + "\n\n" + username +
                                 "\n@twitter66bot",
                                 reply_markup=reply_markup)
        update.message.reply_text("پیام شما با موفقیت ادیت شد")
        logger.info(
            str(database.get_username(chatid)) +
            " Edited his/hers message caption -- " + " new text is : " + text +
            " -- chatid = " + str(chatid) + " -- TelUsername: "******" Edited his/hers message Caption -- " + " new text is : " + text +
            " -- chatid = " + str(chatid) + " -- TelUsername: " +
            str(update.message.from_user.username))
    return ConversationHandler.END
Example #2
0
def set(bot, update, args, chat_data):
    chat_id = update.message.chat_id
    try:
        # args[0] should contain the time for the timer in seconds
        given_username = str(args[0])
        if database.get_username(given_username) == given_username:
            update.message.reply_text("این یوزرنیم قبلا استفاده شده")
        elif given_username.startswith("#"):
            if database.get_username(chat_id) is None:
                database.add_shit(chat_id, given_username)
                update.message.reply_text(
                    "یوزرنیم شما ذخیره شد، میتوانید توییت بفرستید")
                telusername = update.message.from_user.username
                logger.info("telusername = "******"---chatid =" + str(chat_id) + " and username = "******" added to database")
                print("telusername = "******"---chatid =" +
                      str(chat_id) + " and username = "******" added to database")
                return
        else:
            update.message.reply_text('حتما باید با # شروع شه')
            return

    except (IndexError, ValueError):
        update.message.reply_text("""مثال:
        /set #حمید_رضایی""")
Example #3
0
def start(bot, update):
    chatid = str(update.message.chat_id)
    if database.get_username(chatid) is None:
        update.message.reply_text("""برای شما یوزرنیم ثبت نشده
لطفا با ارسال /username برای خود یکی بسازید""")
        return
    username = database.get_username(chatid)
    bot.send_message(chat_id=update.message.chat_id,
                     text="یوزرنیم شما:" + username +
                     "\nمیتوانید توییت خود را بفرستید...")
Example #4
0
def delete(bot, update, args, chat_data):
    chat_id = update.message.chat_id
    try:
        # args[0] should contain the time for the timer in seconds
        given_username = str(args[0])
        username = database.get_username(chat_id)
        if username == given_username:
            database.delete_shit(given_username)
            update.message.reply_text(
                "یوزرنیم شما پاک شد، برای فرستادن توییت با ارسال /username برای خود یوزرنیم بسازید "
            )
            telusername = update.message.from_user.username
            logger.info("telusername = "******"---chatid =" +
                        str(chat_id) + " and username = "******" deleted from database")
            return

        else:
            update.message.reply_text("""برای شما یوزرنیم ثبت نشده
                لطفا با ارسال /username برای خود یکی بسازید""")
            return

    except (IndexError, ValueError):
        update.message.reply_text("""مثال:
        /del #حمید_رضایی""")
Example #5
0
def get_users_tasks(db):

    username = request.query['username']
    user_id = database.get_user_data(db, username)['userID']
    task_list = database.position_list(db, user_id)
    registerd_tasks = tasks_registered_by_user(db)
    ret_val = []

    for x in task_list:

        is_registered = False

        for registered_task in registerd_tasks:
            if (registered_task['jobID'] == x[0]):
                is_registered = True

        status = status_dict[str(x[8])]

        ret_val.append({
            'id': x[0],
            'time': x[1],
            'owner': x[3],
            'title': x[4],
            'location': x[5],
            'description': x[6],
            'selectedUserID': x[7],
            'category': x[10],
            'ownerName': database.get_user_data(db, x[3])['name'],
            'cost': x[9],
            'isRegistered': is_registered,
            'status': status,
            'selectedUsername': database.get_username(db, x[7]),
        })

    return {'result': ret_val}
Example #6
0
def unblacklist(bot, update, args, chat_data):
    chatid = str(update.message.chat_id)
    if chatid != config.admin_chatid:
        update.message.reply_text('برای انجام این عمل باید ادمین باشید')
        return
    else:
        try:
            # args[0] should contain the time for the timer in seconds
            given_username = str(args[0])
            bchatid = database.get_chatid(given_username)
            username = database.get_username(bchatid)
            if username == given_username:
                id_to_unblock = database.get_chatid(username)
                database.unblock(id_to_unblock)
                bot.send_message(chat_id=update.message.chat_id,
                                 text=username + "  REMOVED from blackllist")
                logger.info(username + " with the chat_id of: " +
                            id_to_unblock + " REMOVED from"
                            " blacklist")
                print(
                    str(username) + " with the chat_id of: " +
                    str(id_to_unblock) + " REMOVED from"
                    " blacklist")
                return

            else:
                update.message.reply_text('این یوزرنیم در سرور موجود نیست')
                return

        except (IndexError, ValueError):
            update.message.reply_text("یچیو اشتباه نوشتی")
Example #7
0
def get_user_tasks(db):
    user_id = get_user_id(db)
    task_list = database.position_list(db, user_id)
    ret_val = []

    for x in task_list:

        status = status_dict[str(x[8])]

        ret_val.append({
            'id': x[0],
            'time': x[1],
            'owner': x[3],
            'title': x[4],
            'location': x[5],
            'description': x[6],
            'selectedUserID': x[7],
            'category': x[10],
            'ownerName': database.get_user_data(db, x[3])['name'],
            'cost': x[9],
            'status': status,
            'selectedUsername': database.get_username(db, x[7]),
        })

    return {'result': ret_val}
Example #8
0
def rating(db):
    newRating = request.forms['rate']
    userID = request.forms['userID']
    if int(newRating) > 0:
        database.update_rating(db, newRating,
                               database.get_username(db, userID))
        return True
    ######################################################################
    # @Mohamed if theres a new rating update rating else return home
    redirect('/')
Example #9
0
def delete_last_post(bot, update):
    chatid = update.message.chat_id
    messageid = database.get_message_id(chatid)
    if messageid is None:
        update.message.reply_text("پیام شما یافت نشد")
    else:
        bot.delete_message(chat_id=config.channelid, message_id=messageid)
        bot.send_message(chat_id=chatid,
                         text="پیام شما با موفقیت پاک شد",
                         reply_markup=telegram.ReplyKeyboardRemove())
        logger.info(
            str(database.get_username(chatid)) +
            " deletet his/hers message: " + " -- chatid = " + str(chatid) +
            " -- TelUsername: "******" deletet his/hers message: " + " -- chatid = " + str(chatid) +
            " -- TelUsername: " + str(update.message.from_user.username))
        database.delete_liked_message(messageid)
Example #10
0
def make_username(bot, update):
    chatid = update.message.chat_id
    if database.get_username(chatid) is None:
        update.message.reply_text("""لطفا یک یوزرنیم انتخاب کنید
این یوزرنیم زیر پست هاتون نوشته میشه
حتما # بذارین اولش
برای ارسال یوزرنیم از دستور /set استفاده کنید
برای پاک کردن یوزرنیم از /del استفاده کنید
""")
        update.message.reply_text("""مثال:
/set #رضا_خوشحال
/del #رضا_ناراحت""")
    else:
        username = database.get_username(chatid)
        bot.send_message(chat_id=update.message.chat_id,
                         text="یوزرنیم شما:" + username +
                         "\nمیتوانید توییت خود را بفرستید")
        update.message.reply_text(
            """برای پاک کردن یوزرنیم از /del استفاده کنید""")
        update.message.reply_text("""مثال:
        /del #رضا_ناراحت""")
Example #11
0
def get_weekly_proposed_meals():
    db = current_app.config["db"]
    today = datetime.date(datetime.today())
    end = today - timedelta(days=7)
    meal_student_ids = db.get_between_meals(str(end), str(today), "average", 0)
    list = [[0 for x in range(2)] for y in range(len(meal_student_ids))]
    db = current_app.config["db"]
    for i in range(len(meal_student_ids)):
        current_m = current_meal.Current_Meal()
        current_m.meal(meal_student_ids[i][0])
        current_m.get_average_rates()
        current_m.get_vote_counter()
        current_m.get_food_calories()
        current_m.id = meal_student_ids[i][0]
        current_m.get_score()
        list[i][0] = current_m
        list[i][1] = db.get_username(meal_student_ids[i][1])

    return list
Example #12
0
 def log_in(self, rfid):
   if self.account_type == AccountManager.GUEST:
     return False
   if rfid == settings.TESTING_RFID:
     self.account_type = AccountManager.TEST
     self.username = settings.TESTING_USERNAME
     self.rfid = rfid
     self.balance = settings.TESTING_BALANCE
     return True
   else:
     self.rfid = rfid
     self.username = get_username(rfid)
     if self.username == None:
       print "Invalid credentials"
       print "RFID = " + rfid
       return False
     self.account_type = AccountManager.SRND
     self.balance = get_balance(rfid)
     return True
Example #13
0
def main(userid):
    welcome = "###################################################################\n"\
              "# This is a simple crawler to get images from twitter account and #\n"\
              "# convert them to several videos with recognized label on it.     #\n"\
              "# author: Yuxuan Su([email protected])                                #\n"\
              "###################################################################\n"
    print(welcome)
    is_success, outputs = get_username(userid)
    if not is_success:
        print("get username failed. exit!")
        sys.exit(-1)
    print("Welcome! %s" % outputs[1])
    while True:
        op = input("Press [C] to start a task, Press [I] to view collective statistics, Press [Q] to quit:")
        if op in ("C", "c"):
            start_task(userid)
        elif op in ("Q", "q"):
            sys.exit(0)
        elif op in ("I", "i"):
            pass
Example #14
0
def most_liked(bot, update):
    chatid = str(update.message.chat_id)
    if chatid != config.admin_chatid:
        update.message.reply_text('برای انجام این عمل باید ادمین باشید')
        return
    else:
        data = database.get_most_liked()

        class topmsg:
            def __init__(self, chatid, msgid, likes, dislikes):
                self.chatid = chatid
                self.msgid = msgid
                self.likes = likes
                self.dislikes = dislikes

            def __repr__(self):
                return repr(
                    (self.chatid, self.msgid, self.likes, self.dislikes))

        def getkey(topmsg):
            return topmsg.likes

        list = [
            topmsg(data[0][0], data[0][1], data[0][2], data[0][3]),
            topmsg(data[1][0], data[1][1], data[1][2], data[1][3]),
            topmsg(data[2][0], data[2][1], data[2][2], data[2][3]),
            topmsg(data[3][0], data[3][1], data[3][2], data[3][3]),
            topmsg(data[4][0], data[4][1], data[4][2], data[4][3])
        ]
        list.sort(key=getkey)
        bot.send_message(
            chat_id=config.channelid,
            text=" کسانی که بیشترین تعداد لایک را در یک پیام داشتند:")
        for x in range(4, -1, -1):
            msgtext = "\nUsername: "******"\nLikes: " + str(list[x].likes) + "\nDislikes: " + str(list[x].dislikes)
            bot.send_message(chat_id=config.channelid,
                             reply_to_message_id=list[x].msgid,
                             text=msgtext)
Example #15
0
def start_crawl(userid, target, nums, taskid):
    is_success, outputs = get_username(userid)
    if not is_success:
        print("get userinfo failed. exit!")
        return False, "crawl failed"
    twitter_auth_file = os.path.join(RES_DIR, str(userid), outputs[3])
    google_auth_file = os.path.join(RES_DIR, str(userid), outputs[4])

    print("authorize Twitter...")
    api = twitter.twitter_OAuth_login(twitter_auth_file)
    print("start grabbing tweets...")
    # Twitter can only return maximum 3000+ tweets
    twitter.download_tweets(api, target, int(nums))
    print("start downloading images...")
    urls = twitter.extract_images_url(file_name=target + '_tweets.json')
    image_count = len(urls)
    twitter.download_images(target, urls)

    images_src = os.path.join('./download_images', target)
    images_dst = os.path.join(images_src, 'add_labels')
    os.mkdir(images_dst)
    image_client = GVision.get_image_client(google_auth_file)
    GVision.draw_labels_on_images(image_client, images_src, images_dst)

    selfFFMPEG.convert_images_to_video(images_dst, images_src)
    image_location = images_src
    video_location = images_src

    # update task info
    is_success, outputs = update_task({'id': taskid,
                                       'image': image_location,
                                       'video': video_location,
                                       'image_count': image_count})
    if not is_success:
        print(outputs)
        return False, "crawl failed"

    return True, "crawl success"
Example #16
0
def output_board(board,page,u413):
	if board==403:
		u413.type("Access denied.")
		return
	output=''
	if board==0:
		u413.type("Retrieving all topics...")
		c=db.count("posts","topic=TRUE AND PARENT IN (SELECT id FROM boards WHERE onall=TRUE)")
		if c==0 or page<1:
			page=1
		elif page>math.ceil(c/10.0):
			page=math.ceil(c/10.0)
		t=db.query("SELECT *,id AS t FROM posts WHERE topic=TRUE AND parent IN (SELECT id FROM boards WHERE onall=TRUE) ORDER BY (SELECT MAX(posted) FROM posts WHERE topic=FALSE AND parent=t OR topic=TRUE AND id=t) DESC LIMIT %i,10;"%((page-1)*10))
		t.reverse()
		pages=math.ceil(c/10.0)
		if pages==0:
			pages=1
		output+=header.format(0,'BOARD ALL',page,int(math.ceil(c/10.0)))
		output+='<table>'
		for topic in t:
			r=db.count("posts","parent=%i AND topic=FALSE"%int(topic["id"]))
			last=''
			if r!=0:
				last=db.last_post(topic["id"])
				lastu=db.get_username(last["owner"])
				last=lastby.format(lastu,util.ago(last["posted"]))
			u=db.get_username(topic["owner"])
			output+=alltopic.format(topic["parent"],topic["id"],topic["title"],u,util.ago(topic["posted"]),r,last)
		if page==1:
			u413.set_context("BOARD ALL")
		else:
			u413.set_context("BOARD ALL %i"%page)
	else:
		b=db.query("SELECT * FROM boards WHERE id=%i;"%board)
		if len(b)==0:
			u413.type("Board %i does not exist."%board)
			return
		else:
			b=b[0]
		c=db.count("posts","topic=TRUE AND parent=%i;"%board)
		if c==0 or page<1:
			page=1
		elif page>math.ceil(c/10.0):
			page=math.ceil(c/10.0)
		t=db.query("SELECT *,id as t FROM posts WHERE topic=TRUE AND parent=%i ORDER BY (SELECT MAX(posted) FROM posts WHERE topic=FALSE AND parent=t OR topic=TRUE AND id=t) DESC LIMIT %i,10;"%(board,(page-1)*10))
		t.reverse()
		u413.type("Retrieving board topics...")
		if c==0:
			output+=header.format(board,b["name"],page,1)
		else:
			output+=header.format(board,b["name"],page,int(math.ceil(c/10.0)))
		output+='<table>'
		if board==4:
			for topic in t:
				anons=db.anons(topic["id"])
				r=db.count_posts(topic["id"])
				last=''
				if r!=0:
					last=db.last_post(topic["id"])
					lastu=util.anoncode(anons,last["owner"],topic["owner"])
					last=anonlastby.format(lastu,util.ago(last["posted"]))
				output+=anontopic.format(int(topic["id"]),topic["title"],util.ago(topic["posted"]),r,last)
		else:
			for topic in t:
				r=db.count_posts(topic["id"])
				last=''
				if r!=0:
					last=db.last_post(topic["id"])
					lastu=db.get_username(last["owner"])
					last=lastby.format(lastu,util.ago(last["posted"]))
				u=db.get_username(topic["owner"])
				output+=ftopic.format(int(topic["id"]),topic["title"],u,util.ago(topic["posted"]),r,last)
		if page==1:
			u413.set_context("BOARD %i"%board)
		else:
			u413.set_context("BOARD %i %i"%(board,page))
	u413.donttype(output)
	if board==666:
		u413.exec_js('$("#frame").addClass("hell");$(".backgroundImage").attr("src","content/hellbg.png").css("opacity",0.9);','$("#frame").removeClass("hell");$(".backgroundImage").attr("src","content/background.jpg").css("opacity",0.1);')
	u413.clear_screen()
Example #17
0
def output_page(topic, page, u413):
    t = db.select_topic(topic)
    if t == None:
        u413.type("Invalid topic ID.")
        return
    b = db.get_boardname(t["parent"])
    c = db.count_posts(topic)
    if page == 0 and page > 1 or page != 0 and page > math.ceil(c / 10.0):
        page = math.ceil(c / 10.0)
    if page < 1:
        page = 1
    r = db.query(
        "SELECT * FROM posts WHERE parent=%i ORDER BY id LIMIT %i,10;" %
        (topic, (page - 1) * 10))  #replies
    u413.type("Retrieving topic...")
    if t["parent"] == '4':
        u413.donttype(
            header.format(4, b, topic, t["title"], 'OP',
                          util.ago(t["posted"])))
        editor = db.get_username(t["editor"])
        e = ''
        if editor != None:
            if t["editor"] != t["owner"]:
                e = edited.format(editor, util.ago(t["edited"]))
            else:
                e = edited.format('OP', util.ago(t["edited"]))
        u413.donttype(bbcode.bbcodify(t["post"]) + '<br/>' + e)
    else:
        u = db.get_username(t["owner"])
        u413.donttype(
            header.format(int(t["parent"]), b, topic, t["title"], u,
                          util.ago(t["posted"])))
        editor = db.get_username(t["editor"])
        e = ''
        if editor != None:
            e = edited.format(editor, util.ago(t["edited"]))
        u413.donttype(bbcode.bbcodify(t["post"]) + '<br/>' + e)
    if c == 0:
        u413.donttype('Page 1/1<br/>')
    else:
        u413.donttype('Page %i/%i<br/>' % (page, math.ceil(c / 10.0)))
    if c == 0:
        u413.type("There are no replies.")
    else:
        if t['parent'] == '4':
            anons = db.anons(topic)
            for reply in r:
                owner = util.anoncode(anons, reply["owner"], t["owner"])
                editor = db.get_username(reply["editor"])
                e = ''
                if editor != None:
                    if reply["editor"] != reply["owner"]:
                        e = edited.format(editor, util.ago(reply["edited"]))
                    else:
                        e = edited.format(owner, util.ago(reply["edited"]))
                u413.donttype(
                    post.format(owner, int(reply["id"]),
                                bbcode.bbcodify(reply["post"]),
                                util.ago(reply["posted"]), e))
        else:
            for reply in r:
                owner = db.get_username(reply["owner"])
                editor = db.get_username(reply["editor"])
                e = ''
                if editor != None:
                    e = edited.format(editor, util.ago(reply["edited"]))
                u413.donttype(
                    post.format(owner, int(reply["id"]),
                                bbcode.bbcodify(reply["post"]),
                                util.ago(reply["posted"]), e))
        if c == 0:
            u413.donttype('Page 1/1<br/>')
        else:
            u413.donttype('Page %i/%i<br/>' % (page, math.ceil(c / 10.0)))
    if page == 1:
        u413.set_context("TOPIC %i" % topic)
    else:
        u413.set_context("TOPIC %i %i" % (topic, page))
    u413.clear_screen()
Example #18
0
def output_page(topic,page,u413):
	t=db.select_topic(topic)
	if t==None:
		u413.type("Invalid topic ID.")
		return
	b=db.get_boardname(t["parent"])
	c=db.count_posts(topic)
	if page==0 and page>1 or page!=0 and page>math.ceil(c/10.0):
		page=math.ceil(c/10.0)
	if page<1:
		page=1
	r=db.query("SELECT * FROM posts WHERE parent=%i ORDER BY id LIMIT %i,10;"%(topic,(page-1)*10))#replies
	u413.type("Retrieving topic...")
	if t["parent"]=='4':
		u413.donttype(header.format(4,b,topic,t["title"],'OP',util.ago(t["posted"])))
		editor=db.get_username(t["editor"])
		e=''
		if editor!=None:
			e=edited.format(editor,util.ago(t["edited"]))
		u413.donttype(bbcode.bbcodify(t["post"])+'<br/>'+e)
	else:
		u=db.get_username(t["owner"])
		u413.donttype(header.format(int(t["parent"]),b,topic,t["title"],u,util.ago(t["posted"])))
		editor=db.get_username(t["editor"])
		e=''
		if editor!=None:
			e=edited.format(editor,util.ago(t["edited"]))
		u413.donttype(bbcode.bbcodify(t["post"])+'<br/>'+e)
	if c==0:
		u413.donttype('Page 1/1<br/>')
	else:
		u413.donttype('Page %i/%i<br/>'%(page,math.ceil(c/10.0)))
	if c==0:
		u413.type("There are no replies.")
	else:
		if t['parent']=='4':
			anons=db.anons(topic)
			for reply in r:
				owner=util.anoncode(anons,reply["owner"],t["owner"])
				editor=db.get_username(reply["editor"])
				e=''
				if editor!=None:
					e=edited.format(editor,util.ago(reply["edited"]))
				u413.donttype(post.format(owner,int(reply["id"]),bbcode.bbcodify(reply["post"]),util.ago(reply["posted"]),e))
		else:
			for reply in r:
				owner=db.get_username(reply["owner"])
				editor=db.get_username(reply["editor"])
				e=''
				if editor!=None:
					e=edited.format(editor,util.ago(reply["edited"]))
				u413.donttype(post.format(owner,int(reply["id"]),bbcode.bbcodify(reply["post"]),util.ago(reply["posted"]),e))
		if c==0:
			u413.donttype('Page 1/1<br/>')
		else:
			u413.donttype('Page %i/%i<br/>'%(page,math.ceil(c/10.0)))
	if page==1:
		u413.set_context("TOPIC %i"%topic)
	else:
		u413.set_context("TOPIC %i %i"%(topic,page))
	u413.clear_screen()
Example #19
0
def output_board(board,page,u413):
	if board==403:
		u413.type("Access denied.")
		return
	output=''
	if board==0:
		u413.type("Retrieving all topics...")
		c=db.count("posts","topic=TRUE AND PARENT IN (SELECT id FROM boards WHERE onall=TRUE)")
		if c==0 or page<1:
			page=1
		elif page>math.ceil(c/10.0):
			page=math.ceil(c/10.0)
		t=db.query("SELECT *,id AS t FROM posts WHERE topic=TRUE AND parent IN (SELECT id FROM boards WHERE onall=TRUE) ORDER BY (SELECT MAX(posted) FROM posts WHERE topic=FALSE AND parent=t OR topic=TRUE AND id=t) DESC LIMIT %i,10;"%((page-1)*10))
		t.reverse()
		pages=math.ceil(c/10.0)
		if pages==0:
			pages=1
		output+=header.format(0,'BOARD ALL',page,int(math.ceil(c/10.0)))
		output+='<table>'
		for topic in t:
			r=db.count("posts","parent=%i AND topic=FALSE"%int(topic["id"]))
			last=''
			if r!=0:
				last=db.last_post(topic["id"])
				lastu=db.get_username(last["owner"])
				last=lastby.format(lastu,util.ago(last["posted"]))
			u=db.get_username(topic["owner"])
			output+=alltopic.format(topic["parent"],topic["id"],topic["title"],u,util.ago(topic["posted"]),r,last)
		if page==1:
			u413.set_context("BOARD ALL")
		else:
			u413.set_context("BOARD ALL %i"%page)
	else:
		b=db.query("SELECT * FROM boards WHERE id=%i;"%board)
		if len(b)==0:
			u413.type("Board %i does not exist."%board)
			return
		else:
			b=b[0]
		c=db.count("posts","topic=TRUE AND parent=%i;"%board)
		u413.donttype(str(c)+' '+str(board)+' '+str(page))
		if c==0 or page<1:
			page=1
		elif page>math.ceil(c/10.0):
			page=math.ceil(c/10.0)
		u413.donttype(str(c)+' '+str(board)+' '+str(page))
		t=db.query("SELECT *,id as t FROM posts WHERE topic=TRUE AND parent=%i ORDER BY (SELECT MAX(posted) FROM posts WHERE topic=FALSE AND parent=t OR topic=TRUE AND id=t) ASC LIMIT %i,10;"%(board,(page-1)*10))
		u413.type("Retrieving board topics...")
		if c==0:
			output+=header.format(board,b["name"],page,1)
		else:
			output+=header.format(board,b["name"],page,int(math.ceil(c/10.0)))
		output+='<table>'
		if board==4:
			for topic in t:
				anons=db.anons(topic["id"])
				r=db.count_posts(topic["id"])
				last=''
				if r!=0:
					last=db.last_post(topic["id"])
					lastu=util.anoncode(anons,last["owner"],topic["owner"])
					last=anonlastby.format(lastu,util.ago(last["posted"]))
				output+=anontopic.format(int(topic["id"]),topic["title"],util.ago(topic["posted"]),r,last)
		else:
			for topic in t:
				r=db.count_posts(topic["id"])
				last=''
				if r!=0:
					last=db.last_post(topic["id"])
					lastu=db.get_username(last["owner"])
					last=lastby.format(lastu,util.ago(last["posted"]))
				u=db.get_username(topic["owner"])
				output+=ftopic.format(int(topic["id"]),topic["title"],u,util.ago(topic["posted"]),r,last)
		if page==1:
			u413.set_context("BOARD %i"%board)
		else:
			u413.set_context("BOARD %i %i"%(board,page))
	u413.donttype(output)
	if board==666:
		u413.exec_js('$("#frame").addClass("hell");$(".backgroundImage").attr("src","content/hellbg.png").css("opacity",0.9);','$("#frame").removeClass("hell");$(".backgroundImage").attr("src","content/background.jpg").css("opacity",0.1);')
	u413.clear_screen()
Example #20
0
def twiiter(bot, update):
    #region likes and dislikes
    dislikes = 0
    likes = 0

    button_list = [
        InlineKeyboardButton("👎🏻   " + str(dislikes), callback_data="dislike"),
        InlineKeyboardButton("👍🏻   " + str(likes), callback_data="like"),
    ]
    reply_markup = InlineKeyboardMarkup(build_menu(button_list, n_cols=2))

    #endregion
    chatid = update.message.chat_id
    blocked = database.get_blocked_id(chatid)
    username = database.get_username(chatid)
    telusername = update.message.from_user.username
    if blocked is None:
        if database.get_username(chatid) is None:
            update.message.reply_text(
                'اول برای خود با ارسال /username یوزرنیم بسازید')
        elif update.message.photo:
            caption = update.message.caption + "\n\n" + username + "\n@twitter66bot"
            msgid = bot.send_photo(chat_id=config.channelid,
                                   photo=update.message.photo[-1].file_id,
                                   caption=caption,
                                   reply_markup=reply_markup)
            bot.send_message(chat_id=update.message.chat_id,
                             text="توییت در کانال قرار گرفت",
                             reply_markup=telegram.ReplyKeyboardMarkup(
                                 [['/edit_caption'], ['/delete']],
                                 resize_keyboard=True))
            logger.info(username + " Sendphoto: --caption " +
                        update.message.caption + " -- chatid = " +
                        str(chatid) + " -- TelUsername: "******" Sendphoto: --caption " +
                  update.message.caption + " -- chatid = " + str(chatid) +
                  " -- TelUsername: "******"\n\n" + username + "\n@twitter66bot"
            msgid = bot.send_document(chat_id=config.channelid,
                                      document=update.message.document.file_id,
                                      caption=caption,
                                      reply_markup=reply_markup)
            bot.send_message(chat_id=update.message.chat_id,
                             text="توییت در کانال قرار گرفت",
                             reply_markup=telegram.ReplyKeyboardMarkup(
                                 [['/edit_caption'], ['/delete']],
                                 resize_keyboard=True))
            logger.info(username + " SendGIF: --caption " +
                        update.message.caption + " -- chatid = " +
                        str(chatid) + " -- TelUsername: "******" SendGif: --caption " + update.message.caption +
                  " -- chatid = " + str(chatid) + " -- TelUsername: "******"توییت در کانال قرار گرفت",
                                     reply_markup=telegram.ReplyKeyboardMarkup(
                                         [['/edit'], ['/delete']],
                                         resize_keyboard=True))
                    msgid = bot.send_message(chat_id=config.channelid,
                                             text=msgtext + "\n\n" + username +
                                             "\n@twitter66bot",
                                             reply_markup=reply_markup)
                    database.add_like_msgid(update.message.chat_id,
                                            msgid.message_id)
                    get_hashtags(msgtext)
                    logger.info(username + " twited: " + msgtext +
                                " -- chatid = " + str(chatid) +
                                " -- TelUsername: "******" twited: " + msgtext + " -- chatid = " +
                          str(chatid) + " -- TelUsername: "******"شما از طرف ادمین بلاک شدید")