Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Version 2.2

  • Loading branch information...
commit c4d36562ed5650f70ff3207038dd6722c6e1f5e3 1 parent 2a42229
@PrasannaVenkadesh authored
Showing with 32 additions and 14 deletions.
  1. +1 −1  README.txt
  2. +31 −13 chat.rb
View
2  README.txt
@@ -4,7 +4,7 @@ This is a team work of
S. Sathianarayanan(http://sathia27.wordpress.com/) &
S. Prasanna Venkadesh (http://prasopensource.wordpress.com/)
-md5Checksum - fc3f95f8dbb6ec09b2ec13930d405505 chat.rb
+md5Checksum - bf7ed3306ab115750a94d9c541f8e16f chat.rb
Step 1: Download the file 'chat.rb' from the repository
View
44 chat.rb 100644 → 100755
@@ -1,7 +1,7 @@
-
+#!/usr/bin/env ruby1.8
=begin
Application Name: Whiz-Chat
- Version: 2.01
+ Version: 2.2
License: GPL V2.0
=end
@@ -10,14 +10,39 @@
require 'colorize' #gem used to set colors to text and backgrounds
require 'xmpp4r-simple' #Simple XML Protocol for Jabber API
require "highline/import" #for password protection
+ require 'gmail' #for gmail access
system('clear')
system('espeak "Welcome. Dude" >/dev/null 2>&1')
- puts "Whiz Chat Version - 2.01\nDeveloped by- S. Sathianarayanan (sathia2704@gmail.com)\nImproved by- S. Prasanna Venkadesh (prasmailme@gmail.com)\nGithub Repository: https://github.com/PrasannaVenkadesh/Whiz-Chat\n".colorize( :blue ).underline
+ puts "Whiz Chat Version - 2.2".colorize(:yellow)
+ puts "Developed by- S. Sathianarayanan (sathia2704@gmail.com)\nImproved by- S. Prasanna Venkadesh (prasmailme@gmail.com)\nGithub Repository: https://github.com/PrasannaVenkadesh/Whiz-Chat\n".colorize( :blue ).underline
print 'Enter the username :'
username = gets.chomp #Get input from username for user-id
#gets password for mail account, ask from higline gem
password = ask("Enter the password :" ) { |p| p.echo = "*" }
+
+ def quit
+ #type 'bye' in terminal after logging in, you will be logged out.
+ system('reset')
+ puts "You are now Disconnected"
+ system('espeak "Bye Dude" >/dev/null 2>&1')
+ exit()
+ end
+
+ begin
+ puts "Want to Chat or check Mail?\nc - chat\nm - mail\nq - quit"
+ @opt = gets.chomp
+ if(@opt == 'm')
+ Gmail.connect(username, password) do |gmail|
+ system('clear')
+ puts "You have "+ gmail.inbox.count(:unread).to_s + " unread mails"
+ end
+ end
+ if(@opt == 'q')
+ quit()
+ end
+ end while(@opt!='c')
+
print 'To username: '
@to_username = gets.chomp #prompt for userid to whom you want to chat with
puts "Connecting to jabber server.."
@@ -25,7 +50,7 @@
system('clear') #to clear the console screen to keep the screen clean.
system('espeak "Connected.." >/dev/null 2>&1')
- puts " Do you want to set Status Message (y) or (n)"
+ puts "Do you want to set Status Message (y) or (n)"
@choic = gets.chomp
if(@choic == 'y')
puts 'Whats in your mind: '.colorize(:red)
@@ -37,15 +62,6 @@
puts "You can now start chatting\nType bye to quit" #note you need to type 'bye' at terminal to quit the app.
@mess #a variable to get input message from you and also to quit from this chat.
- #method to exit
- def quit
- #type 'bye' in terminal after logging in, you will be logged out.
- system('clear')
- puts "Disconnected..."
- system('espeak "Bye Dude" >/dev/null 2>&1')
- exit()
- end
-
#method to get input from you and to send to person you are in chat with.
def send
while @mess!="bye" do #repeat until the user want to quit
@@ -96,6 +112,8 @@ def receive
rescue Jabber::ClientAuthenticationFailure
print "Invalid username / password\n".colorize(:red) + "Run again\n".colorize(:yellow)
+ rescue Net::IMAP::BadResponseError
+ print "Invalid username / password\n".colorize(:green) + "Run again\n".colorize(:yellow)
#To handle interrupts
rescue Interrupt
Please sign in to comment.
Something went wrong with that request. Please try again.