Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/akalinux/cisco_spark-perl
Cisco Spark AnyEvent Implementation for perl
https://github.com/akalinux/cisco_spark-perl
Last synced: 2 months ago
JSON representation
Cisco Spark AnyEvent Implementation for perl
- Host: GitHub
- URL: https://github.com/akalinux/cisco_spark-perl
- Owner: akalinux
- Created: 2018-03-06T04:55:18.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-03-11T07:52:10.000Z (almost 2 years ago)
- Last Synced: 2024-08-03T16:08:20.587Z (6 months ago)
- Language: Perl
- Size: 43.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: Changes
Awesome Lists containing this project
- awesome-webex - cisco_spark-perl - Asynchronous Bot and HTTP Client Library (by akalinux). (Client SDKs / REST API clients)
README
# Cisco SparkBot implementation
This bundle includess the following libraries:
| Module | Function |
|--------|----------|
| AnyEvent::SparkBot | Asyncrnous AnyEvent loop implementation of the Spark Bot |
| AnyEvent::HTTP::Spark | Dual Nature Syncrnous/Asyncrnous AnyEvent friendly Spark v1 HTTP Client library |
| AnyEvent::SparkBot::SharedRole | Shared library used by AnyEvent::SparkBot and AnyEvent::HTTP::Spark |Once installed it you should be able to use perldoc to view the pod.
## Basic Example
This example shows how to connect to spark and respond to text messages.
```
use Modern::Perl;
use Data::Dumper;
use AnyEvent::SparkBot;
use AnyEvent::Loop;
$|=1;my $obj=new AnyEvent::SparkBot(token=>$ENV{SPARK_TOKEN},on_message=>\&cb);
$obj->que_getWsUrl(sub { $obj->start_connection});
$obj->agent->run_next;
AnyEvent::Loop::run;sub cb {
my ($sb,$result,$eventType,$verb,$json)=@_;
return unless $eventType eq 'conversation.activity' and $verb eq 'post';
if($result) {
my $data=$result->get_data;
my $response={
roomId=>$data->{roomId},
personId=>$data->{personId},
text=>"ya.. ya ya.. I'm on it!"
};
print Dumper($data);
$sb->spark->que_createMessage(sub {},$response);
$sb->agent->run_next;
} else {
print "Error: $result\n";
}
}
```## To Build:
```
perl MakeFile.PL
make
make test
make install
```## For more extensive unit testing
If you want to test this object with your token
```
export SPARK_TOKEN=myToken
export TEST_USER='Firstname LastName'
export RUN_HTTP_TESTS=1
export TEST_USER_WC='User%'
export TEST_EMAIL='User%'
export TEST_PERSON_ID=xxxxx
export TEST_MSG_ID=xxx
export TEST_TEAM=TeamX
export TEST_ROOM=RoomX
perl MakeFile.PL
make
make test
make install
```# Licence
The Perl 5 License (Artistic 1 & GPL 1 or later)