• Stars
    star
    502
  • Rank 85,936 (Top 2 %)
  • Language
    Python
  • License
    MIT License
  • Created over 9 years ago
  • Updated 12 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

[deprecated] Python library for building bots that live on Snapchat

This repo is deprecated due to changes in Snapchat's unofficial API.

SnapchatBot

SnapchatBot: A library for making bots that live on Snapchat

Introducing SnapchatBot, an easy way to program Snapchat accounts to do anything you want. SnapchatBot can be used to create image-based notification services, chatbots, search interfaces, and any kind of intelligent agent that uses picture messages as its interaction mode.

Bots Included

The Reflector Bot

(source at examples/reflectorbot.py)

Sends back everything you send it.

The Storifier Bot

(source at examples/storifierbot.py)

Takes all the snaps sent to it and adds them to its story. It can be used to collect responses from multiple people around a single theme, much like a Twitter hashtag.

The Capture Bot (by EthanBlackburn)

(source at examples/capturebot.py)

Saves all snaps received to the current working directory.

The Auto-Welcomer Bot

(source at examples/autowelcomebot.py)

Sends you an auto-welcome message when you add it to your friends.

The Reporter Bot

(source at examples/reporterbot.py)

Sends you a snap when breaking news happen. Follows the BBC Breaking News twitter account.

The Googler Bot

(source at examples/googlerbot.py)

When sent an image, sends back the most similar image to that picture on the web. Uses Google Image Search.

The GIF Bot

(source at examples/gifbot.py)

Posts popular GIFs taken from the Giphy home page to its story.

The Connector Bot

(source at examples/connectorbot.py)

When you add the Connector to your friends, it links you with a stranger who's also added it. Every snap sent to the Connector will then arrive at the stranger's inbox, and all snaps sent from the stranger to the Connector will come to you. It's like ChatRoulette on Snapchat.

The Rando Bot (by PhlexPlexico)

(source at examples/randobot.py)

When you add RandoBot to your friends, it throws you in a list of people who've also added it. When you send it a snap, it will send your snap to a random person in the list. Similar to the Rando app.

Installation

$ python setup.py install

You also need to have ffmpeg, ImageMagick, and libjpeg installed.

How to build your own bots

SnapchatBot currently supports the following methods:

  • SnapchatBot#send_snap(recipients, snap) -- sends snap snap to the list of usernames recipients
  • SnapchatBot#add_friend(username) -- adds user with username username to the bot's friends
  • SnapchatBot#delete_friend(username) -- deletes user with username username from the bot's friends
  • SnapchatBot#block(username) -- blocks user with username username
  • SnapchatBot#get_snaps(mark_viewed = True) -- gets snaps in the bot's inbox that haven't been viewed yet (use mark_viewed = False as a keyword argument if you don't want the bot to mark every snap received as viewed)
  • SnapchatBot#get_my_stories() -- gets all snaps in the bot's story
  • SnapchatBot#get_friend_stories() -- gets all the stories of the bot's friends
  • SnapchatBot#clear_stories() -- deletes all the bot's stories
  • SnapchatBot#mark_viewed(snap) -- marks snap as viewed
  • SnapchatBot#get_friends() -- gets the bot's friends
  • SnapchatBot#get_added_me() -- gets all users that have added the bot to their friends
  • SnapchatBot#listen() -- listens to events (and triggers on_snap, on_friend_add, or on_friend_delete, if they are defined)

To create a snap to send with your bot, either use Snap.from_file(path_to_file) with a path to an image or a video, or create an image with PIL and then use Snap.from_image(img).

To define behaviors for your bot in response to various events (right now only incoming snaps, friend additions, and friend deletions are supported) subclass SnapchatBot and define any subset of the following methods:

  • initialize -- run when the bot is created
  • on_snap -- run when the bot bot receives a snap
  • on_friend_add -- run when a Snapchat user adds the bot
  • on_friend_delete -- run when a Snapchat user deletes the bot

To begin listening to events, use the SnapchatBot#listen method.

For example, here is the code for the ReflectorBot, which simply responds to a snap by sending it back to the user who sent it:

class ReflectorBot(SnapchatBot):
  # when receiving a snap, sends the same snap back to the sender
  def on_snap(self, sender, snap):
    self.send_snap([sender], snap)

  # when someone adds the bot, the bot adds them back
  def on_friend_add(self, friend):
    self.add_friend(self, friend)

  # when someone deletes the bot, the bot deletes them too
  def on_friend_delete(self, friend):
    self.delete_friend(self, friend)

Then to run the bot:

bot = ReflectorBot(<account username>, <account password>)
bot.listen()

More Repositories

1

autosub

[NO LONGER MAINTAINED] Command-line utility for auto-generating subtitles for any video file
Python
4,054
star
2

livepython

Visually trace Python code in real-time.
JavaScript
2,550
star
3

pigeon

🐦 Quickly annotate data from the comfort of your Jupyter notebook
Python
744
star
4

thingscoop

Search and filter videos based on objects that appear in them using convolutional neural networks
Python
357
star
5

videodigest

Automatic video summaries
Python
262
star
6

TranscriptBot

Auto-transcribe your meetings to Slack in real time
Python
152
star
7

Antipersona

Don't be yourself, be everyone else
Objective-C
76
star
8

100daysofdapps

100 Days of Ðapps
JavaScript
35
star
9

facebook-godot

HTML
31
star
10

OpenGPT-2

Python
21
star
11

pix2pix-tpu

Train pix2pix on Google Cloud TPUs (based on @affinelayer's implementation)
Python
16
star
12

SPADE-COCO

Python
16
star
13

SocialConditioning

Using weather effects to represent people's emotions in augmented reality
C#
11
star
14

Welcome_Programmable_Human

Performance piece generated with code.
Python
10
star
15

pix2pixHD-runway

Python
9
star
16

population-infinite

NYU ITP Fall 2019
5
star
17

Braincast

Broadcast your brainwaves online.
JavaScript
5
star
18

BigGAN

BigGAN in Runway
Python
5
star
19

gym-drawobjects

An OpenAI Gym environment for drawing objects
Python
5
star
20

fall-break

video improvisation experiment
CoffeeScript
4
star
21

tf-flyby

Tensorflow ITP Flyby
Python
4
star
22

Periscope.py

Python listener class for new public Periscope streams
Python
4
star
23

gym-omegle

OpenAI Gym Environment for Omegle
Python
3
star
24

DeepLabV3

DeepLabV3 ported to Runway
Python
3
star
25

android-gps-ui

A Google maps interface for sending GPS updates to the Android emulator.
CoffeeScript
3
star
26

argmax-clj

argmax & argmin macros for clojure
Clojure
3
star
27

Pattern

An unofficial mirror for the Pattern web mining module.
Python
3
star
28

inpainting_gmcnn

Image Inpainting via Generative Multi-column Convolutional Neural Networks
Python
3
star
29

EmotionsFolder

Your emotions, archived.
C++
2
star
30

runway-deepdream

Runway port of DeepDream
Python
2
star
31

today-in-faces

Python
2
star
32

ResNet50-Features

Extracting features from images using a pre-trained ResNet50 network
Python
2
star
33

runway-keras-ocr

Runway port of Keras-OCR
Python
2
star
34

runway-fast-neural-style

Python
2
star
35

.emacs.d

GNU Emacs configuration files
Emacs Lisp
1
star
36

pyalphaclock

Simple Pythonic library for manipulating the screen of the Alpha Clock Five
Python
1
star
37

squeezenet

SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <0.5MB model size
Python
1
star
38

ClinVar

Python
1
star
39

AttnGAN

Python
1
star
40

essays

1
star
41

cobrowser

an implementation of the DOM & HTML5 spec in node.js
C
1
star
42

runway-face-aligner

Python
1
star
43

BeMoreOriginal

Browser extension that prevents you from posting unoriginal tweets
JavaScript
1
star
44

node-xml-generator

Ultra-simple Coffeescript DSL for generating XML.
CoffeeScript
1
star