def my_text(message): # We don't need this crap in channel if message.text == "/start": return tz = pytz.timezone(config.timezone) msg_to_channel = bot.send_message(config.channel_id, message.text, parse_mode="HTML") dbhelper.insert(message.text.replace("\n","<br />"), formatdate(datetime.timestamp(datetime.now(tz)), localtime=True), msg_to_channel.message_id) generate_feed()
def my_text(message): # We don't need this crap in channel if message.text == "/start": return tz = pytz.timezone(config.timezone) msg_to_channel = bot.send_message(config.channel_id, message.text, parse_mode="HTML") dbhelper.insert( message.text.replace("\n", "<br />"), formatdate(datetime.timestamp(datetime.now(tz)), localtime=True), msg_to_channel.message_id) generate_feed()
def create(self, params={}, fields=[], session={}): if '_id' in params and len(params) < 2 or '_id' not in params and len( params) < 1: return {"code": 301, "err": "The params is error."} return dbhelper.insert(self.table, params)
item = fg.add_entry() # Use message id to form valid URL (new feature in Telegram since Feb 2016) item.id("{!s}".format(entry["pid"])) item.link(href="{!s}/{!s}".format(config.bot_link, entry["pid"]), rel="alternate") # Set title and content from message text item.title(entry["ptext"]) item.content(entry["ptext"]) # Set publish/update datetime item.pubdate(entry["pdate"]) item.updated(entry["pdate"]) # Write RSS/Atom feed to file # It's preferred to have only one type at a time (or just create two functions) fg.atom_file('static/atom.xml') # fg.rss_file('static/rss.xml') if __name__ == '__main__': message = "It\'s <b>{!s}</b> o\'clock! (GMT)".format(gmtime().tm_hour) msg = bot.send_message(config.channel_id, message, disable_notification=True, parse_mode="HTML") tz = pytz.timezone(config.timezone) dbhelper.insert( message, formatdate(datetime.timestamp(datetime.now(tz)), localtime=True), msg.message_id) generate_feed()
fg.lastBuildDate(formatdate(datetime.timestamp(datetime.now(tz)), localtime=True)) fg.title(config.feed_title) # Set time-to-live (I really don't know why set this) fg.ttl(5) # Does this parameter mean anything? fg.language(config.feed_language) for entry in entries: item = fg.add_entry() # Use message id to form valid URL (new feature in Telegram since Feb 2016) item.id("{!s}".format(entry["pid"])) item.link(href="{!s}/{!s}".format(config.bot_link, entry["pid"]), rel="alternate") # Set title and content from message text item.title(entry["ptext"]) item.content(entry["ptext"]) # Set publish/update datetime item.pubdate(entry["pdate"]) item.updated(entry["pdate"]) # Write RSS/Atom feed to file # It's preferred to have only one type at a time (or just create two functions) fg.atom_file('static/atom.xml') # fg.rss_file('static/rss.xml') if __name__ == '__main__': message = "It\'s <b>{!s}</b> o\'clock! (GMT)".format(gmtime().tm_hour) msg = bot.send_message(config.channel_id, message, disable_notification=True, parse_mode="HTML") tz = pytz.timezone(config.timezone) dbhelper.insert(message, formatdate(datetime.timestamp(datetime.now(tz)), localtime=True), msg.message_id) generate_feed()
def insert(): if request.method == 'POST': id = request.form['id'] name = request.form['name'] return dbhelper.insert(id, name)