A PHP Error was encountered

Severity: 8192

Message: Function create_function() is deprecated

Filename: geshi/geshi.php

Line Number: 4698

Backtrace:

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 4698
Function: _error_handler

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 4621
Function: _optimize_regexp_list_tokens_to_string

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 1655
Function: optimize_regexp_list

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 2029
Function: optimize_keyword_group

File: /var/www/stikked/htdocs/application/libraries/geshi/geshi.php
Line: 2168
Function: build_parse_cache

File: /var/www/stikked/htdocs/application/libraries/Process.php
Line: 45
Function: parse_code

File: /var/www/stikked/htdocs/application/models/Pastes.php
Line: 517
Function: syntax

File: /var/www/stikked/htdocs/application/controllers/Main.php
Line: 693
Function: getPaste

File: /var/www/stikked/htdocs/index.php
Line: 315
Function: require_once

send IM - Gajim's Pastbin

send IM

From fanboi, 1 Year ago, written in Python, viewed 90 times. This paste will go to meet its maker in 1 Second.
URL https://paste.gajim.org/view/dc9960d4 Embed
Download Paste or View Raw
  1. #!/usr/bin/python3
  2. '''
  3.  
  4. send an XMPP instant message to somebody from Konsole
  5.  
  6. https://paste.gajim.org/view/d184a495#
  7.  
  8.  
  9. https://paste.gajim.org/view/58e35b40#t3WB86MWpD1FCjsHAjBYmAje1AtPPMSc
  10.  
  11.  
  12.  
  13.  
  14. '''
  15. import sys
  16. import os
  17. import nbxmpp
  18. import time
  19. import logging
  20.  
  21.  
  22. try:
  23.     from gi.repository import GObject as gobject
  24. except Exception:
  25.     import gobject
  26.  
  27. try:
  28.     from gi.repository import GLib    as glib
  29. except Exception:
  30.     import glib
  31.  
  32.  
  33.  
  34.  
  35. consoleloghandler = logging.StreamHandler()
  36. root_log = logging.getLogger('nbxmpp')
  37. #root_log.setLevel('DEBUG')
  38. root_log.addHandler(consoleloghandler)
  39.  
  40. if len(sys.argv) < 2:
  41.     print("Syntax: xsend JID text")
  42.     sys.exit(0)
  43.  
  44. to_jid = sys.argv[1]
  45. text = ' '.join(sys.argv[2:])
  46.  
  47. jidparams = {}
  48. if os.access(os.environ['HOME'] + '/.xsend', os.R_OK):
  49.     for ln in open(os.environ['HOME'] + '/.xsend').readlines():
  50.         if not ln[0] in ('#', ';'):
  51.             key, val = ln.strip().split('=', 1)
  52.             jidparams[key.lower()] = val
  53. for mandatory in ['jid', 'password']:
  54.     if mandatory not in jidparams.keys():
  55.         open(os.environ['HOME']+'/.xsend','w').write('#Uncomment fields before use and type in correct credentials.\n#JID=romeo@montague.net/resource (/resource is optional)\n#PASSWORD=juliet\n')
  56.         print('Please point ~/.xsend config file to valid JID for sending messages.')
  57.         sys.exit(0)
  58.  
  59. class Connection:
  60.     def __init__(self):
  61.         self.jid = nbxmpp.protocol.JID(jidparams['jid'])
  62.         self.password = jidparams['password']
  63.         self.sm = nbxmpp.Smacks(self) # Stream Management
  64.         self.client_cert = None
  65.  
  66.     def on_auth(self, con, auth):
  67.         if not auth:
  68.             print('could not authenticate!')
  69.             sys.exit()
  70.         print('authenticated using ' + auth)
  71.         self.send_message(to_jid, text)
  72.  
  73.     def on_connected(self, con, con_type):
  74.         print('connected with ' + con_type)
  75.         auth = self.client.auth(self.jid.getNode(), self.password, resource=self.jid.getResource(), sasl=1, on_auth=self.on_auth)
  76.  
  77.     def get_password(self, cb, mech):
  78.         cb(self.password)
  79.  
  80.     def on_connection_failed(self):
  81.         print('could not connect!')
  82.  
  83.     def _event_dispatcher(self, realm, event, data):
  84.         pass
  85.  
  86.     def connect(self):
  87.         idle_queue = nbxmpp.idlequeue.get_idlequeue()
  88.         self.client = nbxmpp.NonBlockingClient(self.jid.getDomain(), idle_queue, caller=self)
  89.         self.con = self.client.connect(self.on_connected, self.on_connection_failed, secure_tuple=('tls', '', '', None, None))
  90.  
  91.     def send_message(self, to_jid, text):
  92.         id_ = self.client.send(nbxmpp.protocol.Message(to_jid, text, typ='chat'))
  93.         print('sent message with id ' + id_)
  94.         # gobject.timeout_add(1000, self.quit)   #  PyGIDeprecationWarning: GObject.timeout_add is deprecated; use GLib.timeout_add instead
  95.         glib.timeout_add(     1000, self.quit)
  96.  
  97.     def quit(self):
  98.         self.disconnect()
  99.         ml.quit()
  100.  
  101.     def disconnect(self):
  102.         self.client.start_disconnect()
  103.  
  104.  
  105. con = Connection()
  106. con.connect()
  107. #ml = gobject.MainLoop()  ## PyGIDeprecationWarning: GObject.MainLoop is deprecated; use GLib.MainLoop instead
  108. ml  = glib.MainLoop(   )
  109.  
  110. ml.run()
  111.  

Reply to "send IM"

Here you can reply to the paste above