Created
January 9, 2014 07:01
-
-
Save shiumachi/8330455 to your computer and use it in GitHub Desktop.
すごくシンプルな hipchat bot。リストに登録したメッセージを一定間隔でランダムに出力する。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import hypchat | |
import ConfigParser | |
import time | |
import random | |
config = ConfigParser.RawConfigParser() | |
config.read("config.ini") | |
TOKEN = config.get("account", "token") | |
ROOM_ID = config.get("room", "id") | |
hc = hypchat.HypChat(TOKEN) | |
room = hc.get_room(ROOM_ID) | |
#デフォルト: 30分間隔 | |
INTERVAL = 30 * 60 * 1000 | |
MESSAGES = [u"こんにちは", | |
u"さようなら", | |
u"ありがとう", | |
] | |
LEN_MESSAGES = len(MESSAGES) | |
while True: | |
room.message(MESSAGES[random.randint(0, LEN_MESSAGES - 1)]) | |
time.sleep(INTERVAL) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment