Last active 1478979036

Randomises an emoji at the end of a twitter user name

Steven Smith revised this gist 1479015036. Go to revision

2 files changed, 3 insertions, 15 deletions

updatename.py

@@ -2,17 +2,14 @@
2 2 import tweepy
3 3 import json
4 4 import random
5 + from emoji import unicode_codes
6 + emoji = [e.encode('utf-8') for e in unicode_codes.EMOJI_UNICODE.values() if len(e.encode('utf-8')) == 4]
5 7
6 8 with open(".twitter_config.json") as f:
7 - # a json file containing {"ckey": "", "csec": "", "utok": "", "usec": ""}
8 9 config = json.load(f)
9 10
10 11 auth = tweepy.OAuthHandler(config["ckey"], config["csec"])
11 12 auth.set_access_token(config["utok"], config["usec"])
12 13 api = tweepy.API(auth)
13 14
14 - with 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 -
18 - api.update_profile("Steven Smith " + random.choice(d))
15 + api.update_profile("Steven Smith " + random.choice(emoji))

zemojigen.py (file deleted)

@@ -1,9 +0,0 @@
1 - #!/usr/bin/env python
2 - from requests import get
3 - from bs4 import BeautifulSoup as Soup
4 - soup = Soup(get("http://apps.timwhitlock.info/emoji/tables/unicode").text)
5 - emojis = [str(a.text).decode("string_escape") for a in soup.findAll("td", {"class": "code"})[1::2]]
6 - o = [_ for _ in emojis if len(_) == 4]
7 - from json import dump
8 - with open("emoji.dat", "w") as f:
9 - dump(o, f)

Steven Smith revised this gist 1479014227. Go to revision

2 files changed, 27 insertions

updatename.py(file created)

@@ -0,0 +1,18 @@
1 + #!/usr/bin/env python
2 + import tweepy
3 + import json
4 + import random
5 +
6 + with open(".twitter_config.json") as f:
7 + # a json file containing {"ckey": "", "csec": "", "utok": "", "usec": ""}
8 + config = json.load(f)
9 +
10 + auth = tweepy.OAuthHandler(config["ckey"], config["csec"])
11 + auth.set_access_token(config["utok"], config["usec"])
12 + api = tweepy.API(auth)
13 +
14 + with 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 +
18 + api.update_profile("Steven Smith " + random.choice(d))

zemojigen.py(file created)

@@ -0,0 +1,9 @@
1 + #!/usr/bin/env python
2 + from requests import get
3 + from bs4 import BeautifulSoup as Soup
4 + soup = Soup(get("http://apps.timwhitlock.info/emoji/tables/unicode").text)
5 + emojis = [str(a.text).decode("string_escape") for a in soup.findAll("td", {"class": "code"})[1::2]]
6 + o = [_ for _ in emojis if len(_) == 4]
7 + from json import dump
8 + with open("emoji.dat", "w") as f:
9 + dump(o, f)
Newer Older