Last active 1478979036

Randomises an emoji at the end of a twitter user name

Revision 3701edfccf78e2aa443269a9fca76af2c027b4fd

updatename.py Raw
1#!/usr/bin/env python
2import tweepy
3import json
4import random
5
6with open(".twitter_config.json") as f:
7 # a json file containing {"ckey": "", "csec": "", "utok": "", "usec": ""}
8 config = json.load(f)
9
10auth = tweepy.OAuthHandler(config["ckey"], config["csec"])
11auth.set_access_token(config["utok"], config["usec"])
12api = tweepy.API(auth)
13
14with open("emoji.dat") as f:
15 # generated using the other snippet below
16 d = [i.encode('utf-8') for i in json.load(f)]
17
18api.update_profile("Steven Smith " + random.choice(d))
zemojigen.py Raw
1#!/usr/bin/env python
2from requests import get
3from bs4 import BeautifulSoup as Soup
4soup = Soup(get("http://apps.timwhitlock.info/emoji/tables/unicode").text)
5emojis = [str(a.text).decode("string_escape") for a in soup.findAll("td", {"class": "code"})[1::2]]
6o = [_ for _ in emojis if len(_) == 4]
7from json import dump
8with open("emoji.dat", "w") as f:
9 dump(o, f)