def POST(self): i = web.input() s=model.unsubscribe(i.username,i.uploader) if s['subscribestatus']=="Unsubscribed": t=model.get_subscribestatus_count(i.uploader) sbs=t['Subscribers'] model.update_subscribestatus(i.uploader,sbs) if int(i.videoid)==0: raise web.seeother('/subscription') else: raise web.seeother('/play/'+i.videoid)
# -*- coding: utf-8 -*-
def POST(self): data=web.data() un=json.loads(data)['username'] upl=json.loads(data)['uploader'] s=model.unsubscribe(un,upl) return s
def users(update, context): """ List the subscribed users """ try: if str(update.effective_user.id) == settings.ADMIN_ID: users = model.users() # summary if update.message.text == "/users": text = u'<b>Subscribed users:</b> {0}\n\nUse /users_list for display the full list\nUse /users_detail for display detailed info (a lot of messages)'.format( len(users)) context.bot.send_message(chat_id=settings.ADMIN_ID, text=text, parse_mode=telegram.ParseMode.HTML, disable_web_page_preview=True) # full list elif update.message.text == "/users_list": text = "" for user in users: tmp = u'\U0001F539 {0} {1}\n @{2}\n'.format( user.cw_level, html.escape(user.cw_name), html.escape(user.username)) if len(text) + len( tmp) < telegram.constants.MAX_MESSAGE_LENGTH - 5: text += tmp else: context.bot.send_message(chat_id=settings.ADMIN_ID, text=text, disable_web_page_preview=True) text = "" if text: context.bot.send_message(chat_id=settings.ADMIN_ID, text=text, disable_web_page_preview=True) # detailed list elif update.message.text == "/users_detail": for user in users: text = "<b>id:</b> {0}\n<b>username:</b> {1}\n<b>full_name:</b> {2}\n<b>link:</b> {3}\n<b>cw_name:</b> {4}\n<b>cw_level:</b> {5}\n<b>updated:</b> {6}\n<b>crafting:</b> {7}\n\n<code>/craft_reset {0}</code>\n<code>/users_delete {0}</code>".format( user.id, html.escape(user.username), html.escape(user.full_name), html.escape(user.link), html.escape(user.cw_name), user.cw_level, html.escape(user.updated), html.escape(user.crafting)) context.bot.send_message( chat_id=settings.ADMIN_ID, text=text, parse_mode=telegram.ParseMode.HTML, disable_web_page_preview=True) # delete user elif update.message.text.split(" ")[0] == "/users_delete" and len( update.message.text.split(" ")) == 2: user = model.user_by_id(update.message.text.split(" ")[1]) if user: status = model.unsubscribe(user) context.bot.send_message( chat_id=settings.ADMIN_ID, text="User unsubscription operation [{1}]... for @{0}". format(html.escape(user.username), status), parse_mode=telegram.ParseMode.HTML, disable_web_page_preview=True) except Exception as e: utils._admin_error(context, "/users", error=str(e), trace=False)