<commit_before>h1. Skype Utils

An Adhearsion component that provides a collection of methods for the dialplan for interacting with the Skype for Asterisk channel.

h2. Features

  - Provide an automatic translation betwen Skype Username and Asterisk Extension
  - Obtain all unique Skype Channel Variables when a Skype call arrives
  - Track all Skype buddy statuses in memory or in the database

h2. Requirements

  - Adhearsion v0.8.x+
  - Rails v2.2.2+
  - Hobo v0.8.5+
  - mislav-will_paginate v2.3.8+ (from Github)
  - sqlite3-ruby v1.2.4+ (or the gem for whichever database you would like to use)

h2. Installation

In your ~ahn-project/components directory do:

    git clone git://github.com/jsgoecke/skype_utils.git 

Then cd to ~ahn-project/components/skype_utils/gui and do:

    rake db:migrate RAILS_ENV="production"
    script/server -e production (refer to Rails howtos for daemonizing as you wish)

Then login to http://yourserver:3000 and configure your users. Lastly, connect your Adhearsion
application to the Rails GUI by editing ~ahn-project/config/startup.rb:

    config.enable_rails :path => 'components/skype_utils/gui', :env => :production

h2. Dialplan Examples

<pre><code>
    #Example of dialing an Asterisk extension and then converting to a 
    #Skype user to dial out over the Skype for Asterisk channel
    outbound_extension {
  
      skype_user = skype_user_translation({ :translate => 'to_skype', :value => extension })
      if skype_user
        dial "Skype/" + skype_user
      end
  
    }

    #Example of an inbound call from the Skype network that shows the Skype 
    #channel variables available, then translates to an Asterisk extension
    #based on the Skype username
    inbound_skype_call {
  
      skype_channel_variables = fetch_skype_channel_variables
      ahn_log.skype.info skype_channel_variables.inspect
  
      asterisk_extension = skype_user_translation({ :translate => 'to_asterisk', :value => callerid })
      if asterisk_user
        dial "SIP/" + asterisk_extension
      end  
  
    }</code></pre>

h2. Skype Channel Variables

Here is what is available:

  - skype_languages - A space-separated list of language identifiers
  - skype_topic - A user-provided string that can identify the 'topic'
  - skype_token - Similar to skype_topic
  - skype_about - 'about' profile entry
  - skype_birthday - Birthday
  - skype_gender - Gender
  - skype_homepage - Home page URL
  - skype_homephone - Home phone number
  - skype_officephone - Office phone number
  - skype_mobilephone - Mobile phone number
  - skype_city - City name
  - skype_province - State/Province name
  - skype_country - Country name

And here is an example of what is returned with the component method 'fetch_skype_channel_variables':<commit_msg>Updated the README<commit_after>h1. Skype Utils

An Adhearsion component that provides a collection of methods for interacting with the Skype for Asterisk channel.

h2. Features

  - Provide an automatic translation betwen Skype Username and an Asterisk Extension for dialing in and out
  - Obtain all unique Skype Channel Variables when a Skype call arrives (a wealth of info here, see below)
  - Track all Skype buddy statuses in memory or in the database or both
	- Statuses may be queried in the dialplan, in events or even over RPC (DRb, REST and STOMP)!

h2. Requirements

  - Adhearsion v0.8.x+
  - Rails v2.2.2+
  - Hobo v0.8.5+
  - mislav-will_paginate v2.3.8+ (from Github)
  - sqlite3-ruby v1.2.4+ (or the gem for whichever database you would like to use)

h2. Installation

In your ~ahn-project/components directory do:

    git clone git://github.com/jsgoecke/skype_utils.git 

Then cd to ~ahn-project/components/skype_utils/gui and do:

    rake db:migrate RAILS_ENV="production"
    script/server -e production (refer to Rails howtos for daemonizing as you wish)

Then login to http://yourserver:3000 and configure your users. Lastly, connect your Adhearsion
application to the Rails GUI by editing ~ahn-project/config/startup.rb:

    config.enable_rails :path => 'components/skype_utils/gui', :env => :production

h2. Dialplan.rb Example

<pre><code>
    #Example of dialing an Asterisk extension and then converting to a 
    #Skype user to dial out over the Skype for Asterisk channel
    outbound_extension {
  
      skype_user = skype_user_translation({ :translate => 'to_skype', :value => extension })
      if skype_user
        dial "Skype/" + skype_user
      end
  
    }

    #Example of an inbound call from the Skype network that shows the Skype 
    #channel variables available, then translates to an Asterisk extension
    #based on the Skype username
    inbound_skype_call {
  
      #Get all of the relevant channel variables and log them
      skype_channel_variables = fetch_skype_channel_variables
      ahn_log.skype.info skype_channel_variables.inspect
  
      asterisk_extension = skype_user_translation({ :translate => 'to_asterisk', :value => callerid })
      if asterisk_user
        dial "SIP/" + asterisk_extension
      end 
      
      #Log the status of the Skype caller
      ahn_log.dialplan.info skype_user_status? callerid 

 	  #Log all statuses that are available
      ahn_log.diaplan.info skype_user_statuses
  
    }</code></pre>

h2. Events.rb Example

	<pre><code>
  	# Standard statuses
  	# Online - user is online
  	# Skype Me - user is available and asking to be 'Skyped'
  	# Away - the user is away from their Skype client
  	# Not Available - the user is not available for a call
  	# Do Not Disturb - the user does not want to be disturbed
  	# Offline (Voicemail Enabled) - the user is offline and has voicemail
  	# Offline (Voicemail Disabled) - the user is offline and has no voicemail

		#Drop this into your events.rb file to track Skype users statuses
		events.asterisk.manager_interface.each do |event|
  		  if event.name == 'SkypeBuddyStatus'
    	    skype_status_update(event)
  		  end
		end
	</code></pre>

h2. Skype Channel Variables

Here is what is available:

  - skype_languages - A space-separated list of language identifiers
  - skype_topic - A user-provided string that can identify the 'topic'
  - skype_token - Similar to skype_topic
  - skype_about - 'about' profile entry
  - skype_birthday - Birthday
  - skype_gender - Gender
  - skype_homepage - Home page URL
  - skype_homephone - Home phone number
  - skype_officephone - Office phone number
  - skype_mobilephone - Mobile phone number
  - skype_city - City name
  - skype_province - State/Province name
  - skype_country - Country name

And here is an example of what is returned with the component method 'fetch_skype_channel_variables':
{'fraction_non_alphanumeric': 0.0654387541179994, 'fraction_numerical': 0.0076370170709793355, 'mean_word_length': 3.320181112548512, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6385680', 'n_tokens_mistral': 2128, 'n_tokens_neox': 2004, 'n_words': 746}