def post(self): text = self.get_argument('text') text = escape.xhtml_escape(text) user = self.get_current_user() QUEUE.add('post', text=text, user=user) next = self.get_argument('next', '/') self.redirect(next)
def __init__( self, jid, password, server, port, debug=False, changelog_notifications=False, nickname='Bot', firstname='Cleartext Microblogging', avatar='data/avatar.jpg', max_tweet_length=None, ): QUEUE.set_bot(self) self.users = defaultdict(dict) # Cache for some user's info self._load_state() self.jid = jid self.domain = jid.split('.', 1)[1] self.xmpp = ComponentXMPP(jid, password, server, port) self.xmpp.add_event_handler("session_start", self.handle_xmpp_connected) self.xmpp.add_event_handler('presence_subscribe', self._handle_presence_subscribe) self.xmpp.add_event_handler('presence_probe', self._handle_presence_probe) self.xmpp.add_event_handler('presence_available', self._handle_presence_available) self.xmpp.add_event_handler('message', self._handle_message) for event in ['got_online', 'got_offline', 'changed_status']: self.xmpp.add_event_handler(event, self._handle_status_change) self.xmpp.add_event_handler('get_vcard', self._handle_get_vcard) ## BEGIN NEW self.xmpp.registerPlugin("xep_0030") self.xmpp.plugin['xep_0030'].identities['main'] = [ dict( category='client', type='pc', name=firstname, ) ] self.xmpp.registerPlugin("xep_0054") ## END NEW self.log = logging.getLogger('bot') self.debug = debug self.changelog_notifications = changelog_notifications self.nickname = nickname self.firstname = firstname self.avatar = avatar self.max_tweet_length = max_tweet_length
def __init__(self, jid, password, server, port, debug = False, changelog_notifications = False, nickname = 'Bot', firstname = 'Cleartext Microblogging', avatar = 'data/avatar.jpg', max_tweet_length = None, ): QUEUE.set_bot(self) self.users = defaultdict(dict) # Cache for some user's info self._load_state() self.jid = jid self.domain = jid.split('.', 1)[1] self.xmpp = ComponentXMPP(jid, password, server, port) self.xmpp.add_event_handler("session_start", self.handle_xmpp_connected) self.xmpp.add_event_handler('presence_subscribe', self._handle_presence_subscribe) self.xmpp.add_event_handler('presence_probe', self._handle_presence_probe) self.xmpp.add_event_handler('presence_available', self._handle_presence_available) self.xmpp.add_event_handler('message', self._handle_message) for event in ['got_online', 'got_offline', 'changed_status']: self.xmpp.add_event_handler(event, self._handle_status_change) self.xmpp.add_event_handler('get_vcard', self._handle_get_vcard) ## BEGIN NEW self.xmpp.registerPlugin("xep_0030") self.xmpp.plugin['xep_0030'].identities['main'] = [ dict( category = 'client', type = 'pc', name = firstname, ) ] self.xmpp.registerPlugin("xep_0054") ## END NEW self.log = logging.getLogger('bot') self.debug = debug self.changelog_notifications = changelog_notifications self.nickname = nickname self.firstname = firstname self.avatar = avatar self.max_tweet_length = max_tweet_length